diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:18:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:18:39 +0000 |
commit | fff5217f02d91268ce90c8c05665602c059faaef (patch) | |
tree | 2ba24d32dc96eafe7ed0a85269548e76796d849d /scripts/quitmsg.pl | |
parent | Initial commit. (diff) | |
download | irssi-fff5217f02d91268ce90c8c05665602c059faaef.tar.xz irssi-fff5217f02d91268ce90c8c05665602c059faaef.zip |
Adding upstream version 1.4.5.upstream/1.4.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/quitmsg.pl')
-rw-r--r-- | scripts/quitmsg.pl | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/quitmsg.pl b/scripts/quitmsg.pl new file mode 100644 index 0000000..102d9aa --- /dev/null +++ b/scripts/quitmsg.pl @@ -0,0 +1,36 @@ +# If quit message isn't given, quit with a random message +# read from ~/.irssi/irssi.quit + +use Irssi; +use Irssi::Irc; +use strict; +use vars qw($VERSION %IRSSI); + +$VERSION = "1.01"; +%IRSSI = ( + authors => 'Timo Sirainen', + name => 'quitmsg', + description => 'Random quit messages', + license => 'Public Domain', + changed => 'Mon Jul 22 20:00 EET 2020' +); + +my $quitfile = Irssi::get_irssi_dir() . "/irssi.quit"; + +sub cmd_quit { + my ($data, $server, $channel) = @_; + return if ($data ne ""); + + open (my $fh, "<", $quitfile) || return; + my @lines = <$fh>; + + my $quitmsg = $lines[int(rand(@lines))]; + chomp($quitmsg); + close($fh); + + foreach my $server (Irssi::servers) { + $server->command("/disconnect ".$server->{tag}." $quitmsg"); + } +} + +Irssi::command_bind('quit', 'cmd_quit'); |