diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
commit | 03929dac2a29664878d2c971648a4fe1fb698462 (patch) | |
tree | 02c5e2b3e006234aa29545f7a93a1ce01b291a8b /scripts/quitrand.pl | |
parent | Initial commit. (diff) | |
download | irssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.tar.xz irssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.zip |
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/quitrand.pl')
-rw-r--r-- | scripts/quitrand.pl | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/quitrand.pl b/scripts/quitrand.pl new file mode 100644 index 0000000..cfa1b38 --- /dev/null +++ b/scripts/quitrand.pl @@ -0,0 +1,52 @@ +# 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.00"; +%IRSSI = ( + authors => 'Fernando J. Pereda', + contact => 'ferdy@ferdyx.org', + name => 'quitrand', + description => 'Random quit messages - based on quitmsg (Timo Sirainen)', + license => 'GPLv2', +); + +my $quitfile = glob "~/.irssi/irssi.quit"; + +sub cmd_quit { + my ($data, $server, $channel) = @_; + + open(f,"<",$quitfile); + my @contenido = <f>; + close(f); + + my $numlines = 0; + + foreach my $nada (@contenido) { + $numlines++; + } + + my $line = int(rand($numlines))+1; + + my $quitmsg = "[IRSSI] ".$contenido[$line]; + + chop($quitmsg); + + print($quitmsg); + + foreach my $sv (Irssi::servers()) { + foreach my $item ($sv->channels()) { + $item->command("PART ".$item->{name}." $quitmsg"); + } + } + + foreach my $svr (Irssi::servers()) { + $svr->command("DISCONNECT ".$svr->{tag}." $quitmsg"); + } +} + +Irssi::command_bind('quit', 'cmd_quit'); |