1use Irssi;
2use 5.6.0;
3use strict;
4use vars qw($VERSION %IRSSI);
5
6$VERSION = "0.2.1";
7%IRSSI = (
8    authors => 'Grigori Goronzy',
9    contact => 'greg@chown.ath.cx',
10    name => 'antiplenk',
11    description => 'notices users who "plenk"',
12    license => 'BSD',
13    url => 'http://chown.ath.cx/~greg/antiplenk/',
14    changed => 'Mi 12 Feb 2003 07:00:05 CET',
15);
16
17Irssi::settings_add_str($IRSSI{'name'}, "plenk_channels", "#foobar|#barfoo");
18Irssi::settings_add_bool($IRSSI{'name'}, "plenk_spam", "1");
19Irssi::settings_add_int($IRSSI{'name'}, "plenk_allowed", "10");
20Irssi::signal_add_last('message public', 'plenk');
21my %times;
22
23Irssi::print "antiplenk $VERSION loaded";
24
25sub plenk {
26my ($server, $msg, $nick, $address, $channel) = @_;
27my $spam = Irssi::settings_get_bool("plenk_spam");
28my $allowed = Irssi::settings_get_int("plenk_allowed");
29
30# channel in list?
31if(!($channel =~ Irssi::settings_get_str("plenk_channels"))) { return 0 }
32
33# check..
34while($msg =~ /[[:alnum:]]+ (\.|\,|\?|\!|\: |\; )(\!|\1|\?|\�|\.|\ |$)/g) {
35 # increment
36 $times{$nick}++;
37 # "debug"
38  if($spam) { Irssi::print "antiplenk: $nick plenked on $channel for the $times{$nick}" .
39  ($times{$nick} == 1 ? "st" : $times{$nick} == 2 ? "nd" : $times{$nick} == 3 ? "rd" : "th") .
40  " time" }
41 # too often?
42 if($times{$nick} > $allowed ) {
43  $server->command("msg $nick antiplenk: you 'plenked' more than $allowed times! please stop this at once!");
44  Irssi::print "antiplenk: $nick got a notice";
45  $times{$nick} = 0; }
46 }
47}
48