bbbb0ed8640a1e71fe195c06707a68feee2d289b
[crypto.git] / apps / irssi / scripts / autorejoin.pl
1 # automatically rejoin to channel after kicked
2
3 # NOTE: I personally don't like this feature, in most channels I'm in it
4 # will just result as ban. You've probably misunderstood the idea of /KICK
5 # if you kick/get kicked all the time "just for fun" ...
6
7 use Irssi;
8 use Irssi::Irc;
9 use strict;
10
11 sub event_rejoin_kick {
12         my ($server, $data) = @_;
13         my ($channel, $nick) = split(/ +/, $data);
14
15         return if ($server->{nick} ne $nick);
16
17         # check if channel has password
18         my $chanrec = $server->channel_find($channel);
19         my $password = $chanrec->{key} if ($chanrec);
20
21         # We have to use send_raw() because the channel record still
22         # exists and irssi won't even try to join to it with command()
23         $server->send_raw("JOIN $channel $password");
24 }
25
26 Irssi::signal_add('event kick', 'event_rejoin_kick');