I was looking for badwords engine but couldnt find just engine snippet of badwords! So i made it for you! :) This is very very simple badwords detection engine! Engine uses text file to compare users entered text! If badword matches then... well your choice :) This is just a core! You can improve it! :) All you have to do is to create a text file called badwords.txt. In every line add a single badword! That
s it!
;On text entry variable saves entered text and
;passes it to alias engine to check if it is bad word!
on *:TEXT:*:#: {
set %text $1-
set %s 1
badword
}
;Checks if it is bad word using while loop as
;many times as lines containing badwords in your text file
alias badword {
;Looks how many lines is in your text file
set %lines $lines(badwords.txt)
while ( %s <= %lines ) {
if ($read(badwords.txt, %s ) isin %text ) {
; You command here :) For example: msg # Jesus don`t like your language $nick ! :)
unset %s
halt
}
else inc %s
}
}
A couple of things, the major being removing all these global variables.
You can do that with something like:
on *:TEXT:*:#: {
badword $1-
}
And later use it as such in the alias like:
alias badword {
;Looks how many lines is in your text file
var %lines $lines(badwords.txt)
var %s 1
while ( %s <= %lines ) {
if ($read(badwords.txt, %s ) isin $1-) {
;....continue code
What I'm really trying to suggest is your usage of global versus local variables (/set versus /var).
Hope that helps!
There may be one that also has a message tag before the ban, for example to read the line. Txt and that if a usuer types a lienea him a warning and if you type another line badword.txt him one last warning before the bankick.
Thank you in advance and happy new year
P.D: Written from the google translator.