2000-03-02 13:09:13 -05:00
|
|
|
# Quit with a random quit message read from ~/.irssi/irssi.quit
|
|
|
|
|
|
|
|
use Irssi;
|
|
|
|
|
|
|
|
$quitfile = "$ENV{HOME}/.irssi/irssi.quit";
|
|
|
|
|
|
|
|
sub cmd_quit {
|
|
|
|
my ($data, $server, $channel) = @_;
|
|
|
|
|
|
|
|
open (f, $quitfile) || return;
|
|
|
|
$lines = 0; while(<f>) { $lines++; };
|
|
|
|
|
|
|
|
$line = int(rand($lines))+1;
|
|
|
|
|
|
|
|
seek(f, 0, 0); $. = 0;
|
|
|
|
while(<f>) {
|
|
|
|
next if ($. != $line);
|
|
|
|
|
|
|
|
chomp;
|
|
|
|
$quitmsg = $_;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
close(f);
|
|
|
|
|
|
|
|
@servers = Irssi::servers;
|
|
|
|
foreach $server (@servers) {
|
2000-03-10 15:16:43 -05:00
|
|
|
$server->command("/disconnect ".$server->values()->{'tag'}." $quitmsg");
|
2000-03-02 13:09:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Irssi::command_bind('quit', '', 'cmd_quit');
|