User Control Panel
Advertisements

HELP US, HELP YOU!

Insult

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl
View unanswered posts
Author Message
MxT
Young One
Young One


Joined: 26 Nov 2005
Posts: 65

Reputation: 6.7Reputation: 6.7Reputation: 6.7Reputation: 6.7Reputation: 6.7Reputation: 6.7

PostPosted: Fri Jan 20, 2006 12:54 am    Post subject: Insult Reply with quote

Hi, i want to make a insult detector for my chat. but i dont know how to do something like if the message is equal to example any word in a array like
Code:

@insult = ("asshole", "stupid", "fool");
if($message =~ /@insulte/si)
{
  $self->sendMessage("Dont swear please !");
}


Plz it will improve it.
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Fri Jan 20, 2006 1:06 am    Post subject: Reply with quote

You could join the array into something regexp-friendly.

Code:
my $regexp = join ('|', @insult);
if ($message =~ /$regexp/si) {
   $self->sendMessage ("Dont swear please !");
}

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
MxT
Young One
Young One


Joined: 26 Nov 2005
Posts: 65

Reputation: 6.7Reputation: 6.7Reputation: 6.7Reputation: 6.7Reputation: 6.7Reputation: 6.7

PostPosted: Fri Jan 20, 2006 2:33 am    Post subject: Thank cer Reply with quote

Thank cer, its work Very Happy Very Happy
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group