2000-03-02 13:09:13 -05:00
|
|
|
# Quit with a random quit message read from ~/.irssi/irssi.quit
|
|
|
|
|
|
|
|
use Irssi;
|
2000-10-18 16:50:12 -04:00
|
|
|
use Irssi::Irc;
|
2001-07-16 16:22:45 -04:00
|
|
|
use strict;
|
2000-03-02 13:09:13 -05:00
|
|
|
|
2001-07-16 16:22:45 -04:00
|
|
|
my $quitfile = glob "~/.irssi/irssi.quit";
|
2000-03-02 13:09:13 -05:00
|
|
|
|
|
|
|
sub cmd_quit {
|
|
|
|
my ($data, $server, $channel) = @_;
|
|
|
|
|
|
|
|
open (f, $quitfile) || return;
|
2001-07-16 16:22:45 -04:00
|
|
|
my $lines = 0; while(<f>) { $lines++; };
|
2000-03-02 13:09:13 -05:00
|
|
|
|
2001-07-16 16:22:45 -04:00
|
|
|
my $line = int(rand($lines))+1;
|
2000-03-02 13:09:13 -05:00
|
|
|
|
2001-07-16 16:22:45 -04:00
|
|
|
my $quitmsg;
|
2000-03-02 13:09:13 -05:00
|
|
|
seek(f, 0, 0); $. = 0;
|
|
|
|
while(<f>) {
|
|
|
|
next if ($. != $line);
|
|
|
|
|
|
|
|
chomp;
|
|
|
|
$quitmsg = $_;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
close(f);
|
|
|
|
|
2001-07-16 16:22:45 -04:00
|
|
|
foreach my $server (Irssi::servers) {
|
2000-12-06 00:42:13 -05:00
|
|
|
$server->command("/disconnect ".$server->{tag}." $quitmsg");
|
2000-03-02 13:09:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-13 13:19:59 -05:00
|
|
|
Irssi::command_bind('quit', 'cmd_quit');
|