summaryrefslogtreecommitdiffstats
path: root/scripts/colorkick.pl
blob: c28e4204bc635fd863424cf326543023c54079b5 (plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/pkg/bin/perl
#
# script what's kicking users for using color or blink
#
# settings:
#  what			type	function
#  colorkick_channels	str	list of channels have to be ``protected''
#  colorkick_color	int	0: don't kick on color
#  colorkick_blink	int	0: don't kick on blink
#

use strict;
use Irssi;
use Irssi::Irc;

use vars qw/%IRSSI $VERSION/;
$VERSION='0.1';
%IRSSI =
(
	authors		=> "Gabor Nyeki",
	contact		=> "bigmac\@vim.hu",
	name		=> "colorkick",
	description	=> "kicking users for using colors or blinks",
	license		=> "public domain",
	written		=> "Thu Dec 26 00:22:54 CET 2002",
	changed		=> "2017-03-07"
);

sub catch_junk
{
	my ($server, $data, $nick, $address) = @_;
	my ($target, $text) = split(/ :/, $data, 2);
	my $valid_channel = 0;

	#if ($target[0] != '#' && $target[0] != '!' && $target[0] != '&')
	#{
	#	return;
	#}

	for my $channel (split(/ /,
		Irssi::settings_get_str('colorkick_channels')))
	{
		if ($target eq $channel)
		{
			$valid_channel = 1;
			last;
		}
	}
	if ($valid_channel == 0)
	{
		return;
	}

	if ($text =~ /\x3/ &&
		Irssi::settings_get_bool('colorkick_color'))
	{
		$server->send_raw("KICK $target $nick :color abuse");
	}
	elsif ($text =~ /\x6/ &&
		Irssi::settings_get_bool('colorkick_blink'))
	{
		$server->send_raw("KICK $target $nick :blink abuse");
	}
}

Irssi::settings_add_str('colorkick', 'colorkick_channels', '');
Irssi::settings_add_bool('colorkick', 'colorkick_color', 1);
Irssi::settings_add_bool('colorkick', 'colorkick_blink', 1);
Irssi::signal_add("event privmsg", "catch_junk");