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
|
package Plugin::Autojoin;
use strict;
use warnings;
my $config;
sub configure {
my $self = shift;
shift; # cmdref
shift; # run_command
$config = shift;
shift; # root config
return $self;
}
sub on_001_welcome {
my ($self, $logger, $server, $message, $irc) = @_;
$irc->yield(join => $_) for @{$config->{channels}};
return;
}
sub on_kick {
my ($self, $logger, $kicker, $where, $kickee, $why, $irc) = @_;
if ($kickee eq $irc->nick_name) {
$logger->("I was kicked from $where. Rejoining now...");
$irc->yield(join => $where);
}
return;
}
sub on_invite {
my ($self, $logger, $who, $where, $irc) = @_;
$irc->yield(join => $where) if (grep {$_ eq $where} @{$config->{channels}});
return;
}
1;
|