2001-10-19 13:28:34 -04:00
|
|
|
# If quit message isn't given, quit with a random message
|
|
|
|
# read from ~/.irssi/irssi.quit
|
2000-03-02 13:09:13 -05:00
|
|
|
|
|
|
|
use Irssi;
|
2000-10-18 16:50:12 -04:00
|
|
|
use Irssi::Irc;
|
2001-07-16 16:22:45 -04:00
|
|
|
use strict;
|
2002-03-10 16:28:38 -05:00
|
|
|
use vars qw($VERSION %IRSSI);
|
|
|
|
|
|
|
|
$VERSION = "1.00";
|
|
|
|
%IRSSI = (
|
|
|
|
authors => 'Timo Sirainen',
|
|
|
|
name => 'quitmsg',
|
|
|
|
description => 'Random quit messages',
|
|
|
|
license => 'Public Domain',
|
|
|
|
changed => 'Sun Mar 10 23:18 EET 2002'
|
|
|
|
);
|
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) = @_;
|
2001-10-20 17:38:40 -04:00
|
|
|
return if ($data ne "");
|
2000-03-02 13:09:13 -05:00
|
|
|
|
2015-06-12 13:40:15 -04:00
|
|
|
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) {
|
2015-06-12 13:40:15 -04: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');
|