html/nickban.pl


   1 $VERSION = "1.1";
   2 %IRSSI = (
   3     authors     =>  "Roeland 'Trancer' Nieuwenhuis",
   4     contact     =>  "irssi\@trancer.nl",
   5     name        =>  "nickban",
   6     description =>  "A simple nick banner. If it encounters a nick it bans its host",
   7     license     =>  "Public Domain"
   8 );
   9 
  10 use strict;
  11 use Irssi;
  12 
  13 # The channels the nicks are banned on (on which this script is active)
  14 my @channels = qw(#worldchat #chat-world #php);
  15 
  16 # The banned nicks
  17 my @nicks = qw(evildude evilgirl);
  18 
  19 # Your kickreason
  20 my $kickreason = "Not welcome here.";
  21 
  22 sub nick_banner {
  23 
  24     my($server, $channel, $nick, $address) = @_;
  25 
  26     # Are we opped?
  27     return unless $server->channel_find($channel)->{chanop};
  28     
  29     # If the nick is a server, stop it.
  30     return if $nick eq $server->{nick};
  31     
  32     # Is the user a banned nick?
  33     my $nono = 0;
  34     foreach (@nicks) { $nono = 1 if lc($nick) eq lc($_) }
  35     return unless $nono;
  36        
  37     # Is the user on one of the banned channels?
  38     my $react = 0;
  39     foreach (@channels) { $react = 1 if lc($channel) eq lc($_) }
  40     return unless $react;
  41     
  42     # User voiced or op'd?
  43     # Pretty useless, but ok
  44     return if $server->channel_find($channel)->nick_find($nick)->{op} || $server->channel_find($channel)->nick_find($nick)->{voice};
  45 
  46     $server->command("kickban $channel $nick $kickreason");
  47     Irssi::print("Nick banning $nick on $channel. Banned.");
  48 }
  49 
  50 Irssi::signal_add_last('message join', 'nick_banner');