-
Notifications
You must be signed in to change notification settings - Fork 2
/
cpanbot.pl
executable file
·68 lines (58 loc) · 1.81 KB
/
cpanbot.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/home/bingos/perl5.10.0/bin/perl
use strict;
use warnings;
use Carp;
BEGIN { eval "use Event;"; }
use POE qw(Component::IRC Component::EasyDBI);
use lib './lib';
use Connector;
use CPANBot;
use PoEBot;
use POE::Component::IRC::Plugin::BotAddressed;
my $nickname = 'GumbyNET2';
my $username = 'cpanbot';
my $server = '127.0.0.1';
my $port = 9091;
my $channel = '#PoE';
my $groups = [ 'perl.cpan.testers', 'perl.poe' ];
POE::Component::EasyDBI->new(
alias => 'dbi',
dsn => 'DBI:mysql:gumbynet:localhost',
username => '******',
password => '**********',
);
my ($irc) = POE::Component::IRC->spawn( debug => 0 );
POE::Session->create(
inline_states => {
_start => \&init_session,
_default => \&handle_default,
},
);
$poe_kernel->run();
exit 0;
sub init_session {
my ($kernel, $heap, $session) = @_[KERNEL, HEAP, SESSION];
$irc->yield( register => 'all' );
$irc->plugin_add( 'BotAddressed', POE::Component::IRC::Plugin::BotAddressed->new() );
$irc->plugin_add( 'Connector', Connector->new() );
$irc->plugin_add( 'CPANBot', CPANBot->new( botnick => $nickname, poll => 30, groups => [ $groups->[0] ], dbi => 'dbi' ) );
$irc->plugin_add( 'PoEBot', PoEBot->new( botnick => $nickname, poll => 30, groups => [ $groups->[1] ], dbi => 'dbi' ) );
warn "Starting connection to $server:$port\n";
$irc->yield( connect => { Nick => $nickname, Server => $server, Port => $port, Username => $username } );
undef;
}
sub handle_default {
my ( $event, $args ) = @_[ ARG0 .. $#_ ];
print "$event: ";
return 0 if $event eq 'nntp_220';
foreach (@$args) {
if ( ref($_) eq 'ARRAY' ) {
print "[", join ( ", ", @$_ ), "] ";
}
else {
print "'$_' ";
}
}
print "\n";
return 0; # Don't handle signals.
}