I used the search button on this forum and I understood that I need to use regular expressions for the following code:
on @*:TEXT:*:#chanName:{
IF ($nick isop #) { RETURN }
VAR %s = $strip($1-)
IF ((*BadWord1* iswm %s) || (*BadWord2* iswm %s) || (*BadWord3* iswm %s) || (*BadWord4* iswm %s)) {
SET -u3600 %rl. [ $+ [ $address($nick,2) ] ] $calc( %rl. [ $+ [ $address($nick,2) ] ] + 1)
The problem is that the script does not read only the bad word in a sentence, but also other words that contain the bad word...
example: XYZbadWord1 - should not trigger the script
Also is it possible the read the bad words from a .txt ?
I would apreciate the help. Thanks.
on *:TEXT:*:#chanName:{
var %s = $strip($1-) , %clk = 1
while (%clk <= $lines(badwords.txt)) {
if ($wildtok(%s,$read(badwords.txt,n, $+ %clk $+ ),1,32) == $read(badwords.txt,n, $+ %clk $+ )) { echo -a OMG $nick Said a bad word!!!! }
inc %clk
}
}
Basically the echo command can be changed to whatever to perform the command this will simply check your text file for matching words in your txt file (I would suggest a hash file but im a little rusty) a $wildtok event matches specifications if not wildcarded example
$wildtok(My puppy is awesome,*up*,1,32) returns puppy
Noticed how up is wildcarded$wildtok(My puppy is awesome,up,1,32) returns $False
$wildtok(My puppy is awesome,puppy,1,32) returns puppy
you can also set nth to 0 so it returns numbers over word
so in the script I did a simple while loop to check txt file for each word 1 by 1 in your $1- command to see if theres a bad word