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