Do you want to do
if (<any line in file> iswm $1-)
or
if (<any line in file> isin $1-)
There's a difference between those two. For example, if your file is:
and $1- is "I'm the one",
(one iswm $1-) , as well as (two iswm $1-), (three iswm $1-) are FALSE, but
(one isin $1-) is TRUE. For iswm to work, your items should be enclosed in *'s, ie the file should look like:
*one*
*two*
*three*
*four*
If the file has the 2nd format (ie the items are surrounded by *'s), there is a quick way to check $1- against the entire file at once (without a loop) by using hash tables and taking advantage of $hfind's W switch:
alias something {
if !$hget(wordslist) {
if !$isfile(wordslist.txt) { return }
hmake wordslist
hload -n wordslist wordslist.txt
}
if $hfind(wordslist,$strip($1),1,W).data { return $true }
return $false
}
An example usage would be:
on *:text:*:?: if $something($1-) { msg $nick You just said something that matches the file! }
You can find a detailed explanation about $hfind 'reverse wildcard' feature
here ($hfind used to be $hmatch back when that article was written).
If you want to do an "isin" check, I'm afraid you can't do it in one go, so you'd have to loop through the lines in the file one by one. Luckily, with the new /f* commands, this can be quite fast without having to do any tricks:
alias something {
.fopen a wordslist.txt
if $ferr { return }
var %a = $strip($1)
while !$feof {
if $fread(a) isin %a {
.fclose a
return $true
}
}
.fclose a
return $false
}