/var/www/www.irssi.org-old/scripts/html/antiplenk.pl


   1 use Irssi;
   2 use 5.6.0;
   3 use strict;
   4 use 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 
  17 Irssi::settings_add_str($IRSSI{'name'}, "plenk_channels", "#foobar|#barfoo");
  18 Irssi::settings_add_bool($IRSSI{'name'}, "plenk_spam", "1");
  19 Irssi::settings_add_int($IRSSI{'name'}, "plenk_allowed", "10");
  20 Irssi::signal_add_last('message public', 'plenk');
  21 my %times;
  22 
  23 Irssi::print "antiplenk $VERSION loaded";
  24 
  25 sub plenk {
  26 my ($server, $msg, $nick, $address, $channel) = @_;
  27 my $spam = Irssi::settings_get_bool("plenk_spam");
  28 my $allowed = Irssi::settings_get_int("plenk_allowed");
  29 
  30 # channel in list?
  31 if(!($channel =~ Irssi::settings_get_str("plenk_channels"))) { return 0 }
  32 
  33 # check..
  34 while($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 }