mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
ea4dea38c0
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1211 dbcabf3a-b0e7-0310-adc4-f8d773084564
33 lines
575 B
Perl
33 lines
575 B
Perl
# Quit with a random quit message read from ~/.irssi/irssi.quit
|
|
|
|
use Irssi;
|
|
use Irssi::Irc;
|
|
|
|
$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) {
|
|
$server->command("/disconnect ".$server->{tag}." $quitmsg");
|
|
}
|
|
}
|
|
|
|
Irssi::command_bind('quit', 'cmd_quit');
|