# scripts/quakequit.pl
# Gets rid of some of the spam that you may see on quakenet if someone joins
# a channel before registering with nickserv.
# eg.
#####
# >>> [email protected] has joined #channel
# +++ Q sets +o Nick #channel
# <<< [email protected] has quit [Registered]
# >>> [email protected] has joined #channel
# +++ *.quakenet.org sets +o Nick #channel
#####
# Five lines for a single join, ridiculous.
# This script would make it so you just saw:
#####
# >>> [email protected] has joined #channel
# +++ Q sets +o Nick #channel
#####
# It does this by remembering people who quit with a message of "Registered"
# for 1 second after they quit. Any joins or modes set within that one
# second are ignored.
#####
# Settings:
# quakequit_networks (default: quakenet)
# - Set the network tags which this script should be looking at.
# quakequit_servermask (default: *.quakenet.org)
# - Sets the quakenet mask so we can ignore the modes it sets.
use strict;
use Irssi;
use vars qw($VERSION %IRSSI);
$VERSION = "1.0";
%IRSSI = (
authors => "David O\'Rourke",
contact => "phyber [at] #irssi",
name => "quakequit",
description => "Hide the stupid quit/join on QuakeNet when a user registers with nickserv.",
licence => "GPLv2",
changed => "02/03/2009",
);
# Output a few extra messages to the status window to help with
# any errors that might happen.
my $debug = 0;
# Debug line output.
sub dprint {
my ($msg) = @_;
if ($debug) {
Irssi::print $msg;
}
}
# Hash to store our temporary ignores in.
my %quits;
# Returns 1 if there are entrys in the quits hash, otherwise 0.
sub has_quitlist {
if (%quits) {
return 1;
}
return 0;
}
# Returns either 1 (from the entry in the hash) or undef.
sub in_quitlist {
my ($tag, $nick) = @_;
return $quits{$tag . ':' . $nick};
}
# Adds an entry to the quitlist.
sub quitlist_add {
my ($tag, $nick) = @_;
dprint("Adding $tag/$nick to the quitlist");
$quits{$tag . ':' . $nick} = 1;
}
# Remove entries from the quits hash, this function takes only a single
# argument since it's called by Irssi::timeout_add_once. The argument is
# the concatinated $tag .':' $nick that the other functions use.
sub quitlist_del {
my ($tagnick) = @_;
dprint("Purging $tagnick from the quits list");
delete $quits{$tagnick};
return 0;
}
# Return 1 if we should process the tag, otherwise 0.
sub process_tag {
my ($tag) = @_;
my $netlist = Irssi::settings_get_str('quakequit_networks');
foreach my $network (split / /, $netlist) {
if (lc $tag eq lc $network) {
return 1;
}
}
return 0;
}
# Process the 'message join' signal. (/JOIN)
sub message_join {
my ($server_rec, $channel, $nick, $addr) = @_;
my $tag = $server_rec->{tag};
# Don't proceed if the hash is empty.
# hash returns