html/colorkick.pl


   1 #!/usr/pkg/bin/perl
   2 #
   3 # script what's kicking users for using color or blink
   4 #
   5 # settings:
   6 #  what			type	function
   7 #  colorkick_channels	str	list of channels have to be ``protected''
   8 #  colorkick_color	int	0: don't kick on color
   9 #  colorkick_blink	int	0: don't kick on blink
  10 #
  11 
  12 
  13 use Irssi;
  14 use Irssi::Irc;
  15 
  16 use vars %IRSSI;
  17 %IRSSI =
  18 (
  19 	authors		=> "Gabor Nyeki",
  20 	contact		=> "bigmac\@vim.hu",
  21 	name		=> "colorkick",
  22 	description	=> "kicking users for using colors or blinks",
  23 	license		=> "public domain",
  24 	written		=> "Thu Dec 26 00:22:54 CET 2002",
  25 	changed		=> "Fri Jan  2 03:43:10 CET 2004"
  26 );
  27 
  28 sub catch_junk
  29 {
  30 	my ($server, $data, $nick, $address) = @_;
  31 	my ($target, $text) = split(/ :/, $data, 2);
  32 	my $valid_channel = 0;
  33 
  34 	if ($target[0] != '#' && $target[0] != '!' && $target[0] != '&')
  35 	{
  36 		return;
  37 	}
  38 
  39 	for my $channel (split(/ /,
  40 		Irssi::settings_get_str('colorkick_channels')))
  41 	{
  42 		if ($target == $channel)
  43 		{
  44 			$valid_channel = 1;
  45 			last;
  46 		}
  47 	}
  48 	if ($valid_channel == 0)
  49 	{
  50 		return;
  51 	}
  52 
  53 	if ($text =~ /\x3/ &&
  54 		Irssi::settings_get_bool('colorkick_color'))
  55 	{
  56 		$server->send_raw("KICK $target $nick :color abuse");
  57 	}
  58 	elsif ($text =~ /\x6/ &&
  59 		Irssi::settings_get_bool('colorkick_blink'))
  60 	{
  61 		$server->send_raw("KICK $target $nick :blink abuse");
  62 	}
  63 }
  64 
  65 Irssi::settings_add_str('colorkick', 'colorkick_channels', '');
  66 Irssi::settings_add_bool('colorkick', 'colorkick_color', 1);
  67 Irssi::settings_add_bool('colorkick', 'colorkick_blink', 1);
  68 Irssi::signal_add("event privmsg", "catch_junk");