
use strict;
use warnings;
use Xchat qw(:all);

my @spam_patterns = (
	qr/^\QHello. Do you love tasty treats that can be enjoyed at any time?/,
	qr/\QIt is basically sk8boarding(or snoboardin) on water usin a boat/,
	qr/^\QDo u get hard when you see a tornado?/,
	qr/^\QMany people think bras are only meant for women./,
	qr/^\QHello, do u think you have the skills 2 b IRC's ultimate IRC User?/,
	qr/^\QDo u consider urself a man?/,
	qr/^\QAll men should wear bras every day/,
	qr/^ hey lookin 4 a quick way 2 make sum cash,/,
	qr/\Qhi. i just found you a nice person then i decided to call you to at irc,freenode,org channel #calculus/,
	qr/^\Q[**\E.+UNABLE TO CONNECT.+UNLESS.+USING SASL/,
);
register( "Damn Spam -_-", "1.0" );

for my $event ( "Private Message", "Private Message to Dialog" ) {
	hook_print( $event, \&spam_check, { priority => PRI_HIGHEST } );
}

sub spam_check {
	my ($nick, $message) = @{$_[0]};
	$message = strip_code( $message );

	if( grep { $message =~ $_ } @spam_patterns ) {
		if( context_info()->{type} == 3 ) { # dialog
			command( "CLOSE" );
		}

		return EAT_ALL
	}
	return EAT_NONE;
}
