archive

- Random tools & helpful resources for IRC
git clone git://git.acid.vegas/archive.git
Log | Files | Refs | Archive

rejoin.pl (979B)

      1 use Irssi;
      2 use Irssi::Irc;
      3 use strict;
      4 
      5 my $delay  = 1;
      6 my $acttag = 0;
      7 my @tags;
      8 
      9 sub rejoin {
     10     my ( $data ) = @_;
     11     my ( $tag, $servtag, $channel, $pass ) = split( / +/, $data );
     12     my $server = Irssi::server_find_tag( $servtag );
     13     $server->send_raw( "JOIN $channel $pass" ) if ( $server );
     14     Irssi::timeout_remove( $tags[$tag] );
     15 }
     16 
     17 sub event_rejoin_kick {
     18     my ( $server, $data ) = @_;
     19     my ( $channel, $nick ) = split( / +/, $data );
     20     return if ( $server->{ nick } ne $nick );
     21     my $chanrec = $server->channel_find( $channel );
     22     my $password = $chanrec->{ key } if ( $chanrec );
     23     my $rejoinchan = $chanrec->{ name } if ( $chanrec );
     24     my $servtag = $server->{ tag };
     25     Irssi::print "Rejoining $rejoinchan in $delay seconds.";
     26     $tags[$acttag] = Irssi::timeout_add( $delay * 1000, "rejoin", "$acttag $servtag $rejoinchan $password" );
     27     $acttag++;
     28     $acttag = 0 if ( $acttag > 60 );
     29 }
     30 
     31 Irssi::signal_add('event kick', 'event_rejoin_kick');