reconnect.pl
use strict;
use Irssi 20020324 qw(command signal_add_first command_set_options signal_stop);
use vars qw(%IRSSI $VERSION);
$VERSION = "0.3";
%IRSSI = (
authors => 'Valentin Batz',
contact => 'senneth@irssi.org',
name => 'reconnect',
description => 'adds the -full option to the reconnect command and does a full reconnect when you supply the option',
url => 'http://www.oberkommando.org/~senneth/irssi/scripts/',
license => 'GPLv2',
revision => '$LastChangedRevision: 368 $',
changed => '$LastChangedDate: 2006-01-31 22:29:39 +0100 (Tue, 31 Jan 2006) $',
version => $VERSION,
);
sub reconnect_server {
my $server = shift;
return if not ref($server); # make sure there is a server
return if not $server->{'connected'}; # make sure it's connected
my $tag = $server->{'tag'};
my $addr = $server->{'address'};
my $port = $server->{'port'};
my $pw = $server->{'password'};
command('disconnect ' . $tag . ' Reconnecting');
# prefer address, since server might not have been added with /network add /server add
command('connect '.$addr.' '.$port.' '.$pw );
}
sub cmd_reconnect {
my ($data, $server, $item) = @_;
my ($cmdoption, $tag, $msg) = split( / /, $data, 3);
if (lc $cmdoption eq '-full') {
signal_stop();
if ($tag ne '') {
if (lc $tag eq 'all') {
foreach my $server (Irssi::servers()) {
reconnect_server($server);
}
return;
}
my $connserver = Irssi::server_find_tag($tag);
reconnect_server($connserver);
} else {
reconnect_server($server);
}
}
}
command_set_options('reconnect', "full");
signal_add_first('command reconnect',\&cmd_reconnect);