summaryrefslogtreecommitdiffstats
path: root/scripts/quitrand.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/quitrand.pl')
-rw-r--r--scripts/quitrand.pl52
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');