diff options
Diffstat (limited to 'scripts/quitmsg.pl')
-rw-r--r-- | scripts/quitmsg.pl | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/quitmsg.pl b/scripts/quitmsg.pl new file mode 100644 index 00000000..6e296755 --- /dev/null +++ b/scripts/quitmsg.pl @@ -0,0 +1,31 @@ +# 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) { + $server->command("/disconnect ".$server->values()->{'tag'}." $quitmsg"); + } +} + +Irssi::command_bind('quit', '', 'cmd_quit'); |