html/autostuff.pl


   1 use strict;
   2 use vars qw($VERSION %IRSSI);
   3 
   4 $VERSION = '0.02';
   5 %IRSSI = (
   6     authors     => 'Juerd',
   7     contact	=> '#####@juerd.nl',
   8     name        => 'autostuff',
   9     description	=> 'Save current servers, channels and windows for autoconnect and autojoin',
  10     license	=> 'Public Domain',
  11     url		=> 'http://juerd.nl/site.plp/irssi',
  12     changed	=> '2010-03-24 14:35',
  13 );
  14 
  15 use Irssi qw(command_bind servers channels windows command);
  16 
  17 command_bind autostuff => sub {
  18     my ($data, $server, $window) = @_;
  19     for (servers) {
  20         my $chatnet = $_->{chatnet} || $_->{tag};
  21         command "/network add $chatnet";
  22         command "/server add -auto -network $chatnet $_->{address} $_->{port} $_->{password}";
  23     }
  24     for (channels) {
  25         my $chatnet = $_->{server}->{chatnet} || $_->{server}->{tag};
  26         command "/channel add -auto $_->{name} $chatnet $_->{key}";
  27     }
  28     command "/layout save";
  29     command "/save";
  30 };
  31 
  32 command_bind "window clean" => sub {
  33     for (sort { $b->{refnum} <=> $a->{refnum} } windows) {
  34         next if $_->{active};
  35         next if $_->{immortal};
  36         next if $_->{name};
  37         command "/window close $_->{refnum}";
  38     }
  39 };