In a different thread we worked out this simply blacklist that uses tokens.
on *:TEXT:!blacklist add*:#: {
if ($nick isop #) {
set %blacklist. $+ $chan $addtok($($+(%,blacklist.,$chan),2), $3, 44)
msg # $3 Has been added to my blacklist, anyone using $3 will be timed out for 10 minutes.
}
else {
msg # Sorry $nick $+ , you do not have permission to add words to the blacklist
}
}
on *:TEXT:!blacklist del*:#: {
if ($nick isop #) {
set %blacklist. $+ $chan $remtok($($+(%,blacklist.,$chan),2), $3, 44)
msg # $3 Has been removed from the blacklist
}
else {
msg # Sorry $nick $+ , you do not have permission to add words to the blacklist
}
}
on *:TEXT:*:#: {
if ($nick isop #) { return }
var %i = 1
while (%i <= $0) {
if ($istok($($+(%,blacklist.,$chan),2), $gettok($1-,%i,32), 44) == $true) {
msg # $nick -> Do not use Blacklisted Words. (Timeout)
msg # .timeout $nick 600
break
}
inc %i
}
}
If thats interesting at all to you...there ya go! if not
on *:text:!blacklist del *:#: {
if ($nick !isop $chan) { return }
if ($read(skyasiblacklist.txt), ns, $3)) {
write -dl $readn skyasiblacklist.txt
msg $chan $2 has been removed from the blacklist.
}
Also..It kinda looks like it only times out for blacklisted words if it is the 3rd word in a sentence...is that what you intended?
In this example
$1 = !blacklist $2= del and $3= the first word in * $3- is word number three and every word after...the rest of the line.
In this line of your code
if ($read(skyasiblacklist.txt,nw,$3))
You are checking the 3rd($3) word in the line of text to see if its in the text file.
If you notice in the example we've used
var %i = 1
while (%i <= $0)
$0 returns the total number of words in a line. So this is saying
Set a temporary variable(%i) and give it the value of 1. If that varible is LESS than the total number of words in the line repeat this 'WHILE' code. At the end of that code we inc %i which increases %i by 1. So the second time around %i is 2..then 3 4 5. Until %i is = $0 (total words in the line)
We tokenize the line of text $gettok($1-,%i,32)..$1- being the first word in the text, and every word after it. We request the %i token. So First we get token 1 then 2 and 3..ect as the while statement loops and %i increases. The 32 is the character that is between each token(word). Character 32 is space.
Anywho I hope this was useful.