2015-06-12 13:40:15 -04:00
|
|
|
# automatically rejoin to channel after kick
|
|
|
|
# delayed rejoin: Lam 28.10.2001 (lam@lac.pl)
|
2002-02-16 08:06:57 -05:00
|
|
|
|
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);
|
2015-06-12 13:40:15 -04:00
|
|
|
$VERSION = "1.0.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",
|
|
|
|
description => "Automatically rejoin to channel after being kick, after a (short) user-defined delay",
|
|
|
|
license => "GPLv2",
|
|
|
|
changed => "10.3.2002 14:00"
|
2002-03-10 16:28:38 -05:00
|
|
|
);
|
2000-02-25 12:03:17 -05:00
|
|
|
|
2000-04-28 07:00:53 -04:00
|
|
|
|
2015-06-12 13:40:15 -04:00
|
|
|
# How many seconds to wait before the rejoin?
|
|
|
|
# TODO: make this a /setting
|
|
|
|
my $delay = 5;
|
|
|
|
|
|
|
|
my @tags;
|
|
|
|
my $acttag = 0;
|
|
|
|
|
|
|
|
sub rejoin {
|
|
|
|
my ( $data ) = @_;
|
|
|
|
my ( $tag, $servtag, $channel, $pass ) = split( / +/, $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 );
|
|
|
|
Irssi::timeout_remove( $tags[$tag] );
|
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 };
|
|
|
|
|
|
|
|
Irssi::print "Rejoining $rejoinchan in $delay seconds.";
|
|
|
|
$tags[$acttag] = Irssi::timeout_add( $delay * 1000, "rejoin", "$acttag $servtag $rejoinchan $password" );
|
|
|
|
$acttag++;
|
|
|
|
$acttag = 0 if ( $acttag > 60 );
|
2000-02-25 12:03:17 -05:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:40:15 -04:00
|
|
|
Irssi::signal_add( 'event kick', 'event_rejoin_kick' );
|