mirror of
https://github.com/irssi/irssi.git
synced 2024-09-08 04:26:01 -04:00
given..) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1867 dbcabf3a-b0e7-0310-adc4-f8d773084564
36 lines
639 B
Perl
36 lines
639 B
Perl
# If quit message isn't given, quit with a random message
|
|
# read from ~/.irssi/irssi.quit
|
|
|
|
use Irssi;
|
|
use Irssi::Irc;
|
|
use strict;
|
|
|
|
my $quitfile = glob "~/.irssi/irssi.quit";
|
|
|
|
sub cmd_quit {
|
|
my ($data, $server, $channel) = @_;
|
|
return if ($data ne "");
|
|
|
|
open (f, $quitfile) || return;
|
|
my $lines = 0; while(<f>) { $lines++; };
|
|
|
|
my $line = int(rand($lines))+1;
|
|
|
|
my $quitmsg;
|
|
seek(f, 0, 0); $. = 0;
|
|
while(<f>) {
|
|
next if ($. != $line);
|
|
|
|
chomp;
|
|
$quitmsg = $_;
|
|
last;
|
|
}
|
|
close(f);
|
|
|
|
foreach my $server (Irssi::servers) {
|
|
$server->command("/disconnect ".$server->{tag}." $quitmsg");
|
|
}
|
|
}
|
|
|
|
Irssi::command_bind('quit', 'cmd_quit');
|