in reply to Bot::BasicBot forkit - help needed
Nothing spectacular, but it seems to work:
#!/usr/bin/perl use strict; use warnings; package SVNBot; use base 'Bot::BasicBot'; use SVN::Log; use Tie::File; my $repo_url = "file:///parrot/trunk/languages/perl6"; tie my @last_rev, 'Tie::File', 'last_revision' or die "Can't tie file last_revision: $!"; sub tick { my $self = shift; # warn "Rertrieving from r$last_rev[0]"; my $revs = SVN::Log::retrieve( $repo_url, $last_rev[0], 'HEAD', ); # the first revision was already printed in the last run splice @$revs, 0, 1; if (scalar @$revs > 5){ splice @$revs, 0, 5 - scalar(@$revs); } for my $r (@$revs){ my ($rn, $author, $msg) = ($r->{revision}, $r->{author}, $r->{message}); # no warnings 'uninitialized'; if (length $msg == 0){ $self->say( channel => '#perl6', body => "r$rn | $author | [no commit message]\n +", ); print "r$rn | $author | [no commit message]\n", } else { for (split /\n/, $msg){ $self->say( channel => '#perl6', body => "r$rn | $author++ | $_\n", ); print "r$rn | $author++ | $_\n", } } $last_rev[0] = $rn; } return 20; } package main; my $bot = SVNBot->new( server => 'irc.freenode.org', channels => ['#perl6'], nick => 'rakudo_svn', alt_nicks => ['rakudosvn', 'rakudo_svn2'], username => 'SVNBot', name => 'pugs SVN bot', charset => 'utf-8', ); $bot->run(); # vim: sw=4 ts=4 expandtab
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Bot::BasicBot forkit - help needed
by rpetre (Sexton) on Jul 20, 2009 at 17:29 UTC | |
by moritz (Cardinal) on Jul 20, 2009 at 17:31 UTC | |
by neilwatson (Priest) on Jun 26, 2015 at 15:16 UTC |