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!