2017-10-25 10:23:14 -04:00
|
|
|
# automatically rejoin to channel after kicked
|
2015-06-12 13:40:15 -04:00
|
|
|
# delayed rejoin: Lam 28.10.2001 (lam@lac.pl)
|
2002-02-16 08:06:57 -05:00
|
|
|
|
2017-10-25 10:23:14 -04:00
|
|
|
# /SET autorejoin_channels #channel1 #channel2 ...
|
|
|
|
# /SET autorejoin_delay 5
|
|
|
|
|
2000-02-25 12:03:17 -05:00
|
|
|
# NOTE: I personally don't like this feature, in most channels I'm in it
|
|
|
|
# will just result as ban. You've probably misunderstood the idea of /KICK
|
2000-03-02 13:09:13 -05:00
|
|
|
# if you kick/get kicked all the time "just for fun" ...
|
2000-02-25 12:03:17 -05:00
|
|
|
|
2002-03-10 16:28:38 -05:00
|
|
|
use Irssi;
|
2002-02-16 08:06:57 -05:00
|
|
|
use Irssi::Irc;
|
2002-03-10 16:28:38 -05:00
|
|
|
use strict;
|
|
|
|
use vars qw($VERSION %IRSSI);
|
2017-10-25 10:23:14 -04:00
|
|
|
$VERSION = "1.1.0";
|
2002-03-10 16:28:38 -05:00
|
|
|
%IRSSI = (
|
2015-06-12 13:40:15 -04:00
|
|
|
authors => "Timo 'cras' Sirainen, Leszek Matok",
|
|
|
|
contact => "lam\@lac.pl",
|
|
|
|
name => "autorejoin",
|
2017-10-25 10:23:14 -04:00
|
|
|
description => "Automatically rejoin to channel after being kicked, after a (short) user-defined delay",
|
2015-06-12 13:40:15 -04:00
|
|
|
license => "GPLv2",
|
|
|
|
changed => "10.3.2002 14:00"
|
2002-03-10 16:28:38 -05:00
|
|
|
);
|
2000-02-25 12:03:17 -05:00
|
|
|
|
2015-06-12 13:40:15 -04:00
|
|
|
sub rejoin {
|
|
|
|
my ( $data ) = @_;
|
2017-10-25 10:23:14 -04:00
|
|
|
my ( $servtag, $channel, $pass ) = @{$data};
|
2002-02-16 08:06:57 -05:00
|
|
|
|
2015-06-12 13:40:15 -04:00
|
|
|
my $server = Irssi::server_find_tag( $servtag );
|
|
|
|
$server->send_raw( "JOIN $channel $pass" ) if ( $server );
|
2002-02-16 08:06:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
sub event_rejoin_kick {
|
2015-06-12 13:40:15 -04:00
|
|
|
my ( $server, $data ) = @_;
|
|
|
|
my ( $channel, $nick ) = split( / +/, $data );
|
|
|
|
|
|
|
|
return if ( $server->{ nick } ne $nick );
|
|
|
|
|
|
|
|
# check if channel has password
|
|
|
|
my $chanrec = $server->channel_find( $channel );
|
|
|
|
my $password = $chanrec->{ key } if ( $chanrec );
|
|
|
|
my $rejoinchan = $chanrec->{ name } if ( $chanrec );
|
|
|
|
my $servtag = $server->{ tag };
|
|
|
|
|
2017-10-25 10:23:14 -04:00
|
|
|
# check if we want to autorejoin this channel
|
|
|
|
my $chans = Irssi::settings_get_str( 'autorejoin_channels' );
|
|
|
|
|
|
|
|
if ( $chans ) {
|
|
|
|
my $found = 0;
|
|
|
|
foreach my $chan ( split( /[ ,]/, $chans ) ) {
|
|
|
|
if ( lc( $chan ) eq lc( $channel ) ) {
|
|
|
|
$found = 1;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return unless $found;
|
|
|
|
}
|
|
|
|
|
|
|
|
my @args = ($servtag, $rejoinchan, $password);
|
|
|
|
my $delay = Irssi::settings_get_int( "autorejoin_delay" );
|
|
|
|
|
|
|
|
if ($delay) {
|
|
|
|
Irssi::print "Rejoining $rejoinchan in $delay seconds.";
|
|
|
|
Irssi::timeout_add_once( $delay * 1000, "rejoin", \@args );
|
|
|
|
} else {
|
|
|
|
rejoin( \@args );
|
|
|
|
}
|
2000-02-25 12:03:17 -05:00
|
|
|
}
|
|
|
|
|
2017-10-25 10:23:14 -04:00
|
|
|
Irssi::settings_add_int('misc', 'autorejoin_delay', 5);
|
|
|
|
Irssi::settings_add_str('misc', 'autorejoin_channels', '');
|
2015-06-12 13:40:15 -04:00
|
|
|
Irssi::signal_add( 'event kick', 'event_rejoin_kick' );
|