1
0
mirror of https://github.com/irssi/irssi.git synced 2024-10-27 05:20:20 -04:00
irssi/scripts/quitmsg.pl

37 lines
805 B
Perl
Raw Normal View History

# 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);
2021-09-21 16:40:14 -04:00
$VERSION = "1.01";
%IRSSI = (
authors => 'Timo Sirainen',
name => 'quitmsg',
description => 'Random quit messages',
license => 'Public Domain',
2021-09-21 16:40:14 -04:00
changed => 'Mon Jul 22 20:00 EET 2020'
);
2021-09-21 16:40:14 -04:00
my $quitfile = Irssi::get_irssi_dir() . "/irssi.quit";
sub cmd_quit {
my ($data, $server, $channel) = @_;
return if ($data ne "");
2021-09-21 16:40:14 -04:00
open (my $fh, "<", $quitfile) || return;
my @lines = <$fh>;
2021-09-21 16:40:14 -04:00
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');