#!/usr/bin/perl -w

# AntiASL.pl
# Anti "asl?" script for X-Chat 2.0 and up, because everyone is 16/f/cali
# by Siph0n

# Ignore the person if they asl you? (1 for true, 0 for false)
$ignore_lamers = 0;

Xchat::register ("AntiASL", "1.0", "AntiASL script");
Xchat::print ("\n\0035AntiASL Script Loaded\n\n");
Xchat::hook_print ('Channel Message', 'msg_handler');
Xchat::hook_print ('Channel Msg Hilight', 'msg_handler');
Xchat::hook_print ('Private Message', 'msg_handler');
Xchat::hook_print ('Private Message to Dialog', 'msg_handler');

@stuff_to_say = ('Everytime you asl, Will Smith kills a kitten. Please, think of the kittens.',
				 'Before or after my surgery?', '16/f/cali...not.', 'asl? As in "All the Stupid Lamers"?',
				 'Another one bites the dust.', 'asl kills my sex drive.', 'ASL? Isn\'t that like...an STD?',
				 'Did you hear something?', 'Sorry, you must be 18 or up to party.',
				 'asl is just another way of saying "I can\'t get laid."', 'asl is a crime punishable by death.',
				 'Have you ever tried this in real life? Well it won\'t work here either.', 'One time, at band camp..',
				 'Go look at pr0n.');

$suffix = " --> http://www.stopasl.com";

sub msg_handler
{
	my $their_nick = $_[0][0];
	my $their_msg = $_[0][1];

	# Works for ' asl ', 'asl(1+ !'s, 0+ ?'s)', 'asl(1+ ?'s 0+ !'s)'
	# I did this so stuff like "asleep?" wouldn't register as "asl?"
	unless ($their_msg =~ m/\s+asl!*\?\s+/i || $their_msg =~ m/asl!+\?*/i || $their_msg =~ m/asl\?+!*/i)
	{
		return 0;
	}
	
	# Pick a random message, send it, and if they want to ignore, do so
	Xchat::command("say $their_nick: @stuff_to_say[int(rand(@stuff_to_say))]$suffix");
	if ($ignore_lamers) { Xchat::command("ignore $their_nick!*@* all nosave"); }
	return 0;
}