use strict;
use vars qw($VERSION %IRSSI);

use Irssi;
$VERSION = '1.00';
%IRSSI = (
    authors     => 'Jani Hartikainen',
    contact     => 'eeye02@hotmail.com',
    name        => 'Mystats',
    description => 'This script shows your stats like' .
                   'how many channels you are on,' .
                   ' how many people you can kick etc',
    license     => 'Public Domain',
);

my $banchannel = "#ban";
my $bancount = 1074;
my @safenicks = (
	'zomg',
	'gmoz',
	'Remco',
	'Ramunas',
	'Ramunas_',
	'KeN',
	'playitpurple',
	'flow'
	);

sub event_join {
	my ($server,$chan,$nick,$host) = @_;
	#my $w = Irssi::active_win();
	#print "$chan $nick";
	
	if($chan eq $banchannel)
	{
		my $found = 0;
		for(my $i = 0; $i < @safenicks; $i++)
		{
			if($safenicks[$i] eq $nick)
			{
				$found = 1;
			}
		}
		
		if($found eq 0)
		{
			#print "hello";
			$bancount++;
			my $c = $server->channel_find($chan);
			#$c->command("say asd");
			$c->command("knockout 129600 $nick You are ban #$bancount");
			#$server->command("kb $chan $nick You are ban #$bancount");
		}

	}
}

Irssi::signal_add("message join","event_join");
