mIRC Home    About    Download    Register    News    Help

Print Thread
#236243 14/02/12 05:36 PM
Joined: Jun 2009
Posts: 96
V
Babel fish
OP Offline
Babel fish
V
Joined: Jun 2009
Posts: 96
this is small but relevant part of my anti spam script
basically bad words are written in txt file and it reads from them

but problem lies with wildcard match
for example, it only reacts on exact given word
if banned word is "www" or "http", it will react only on them
but if user types www.whatever or http://whatever

it doesn't react
how to fix this ?

Code:
on @*:text:*:#:{
      if ($read($mircdirsystem\spam_triggers.txt, w,$+(*,$1,*)) iswm $1) {
         if (%spam.kickban == on) { .ban -k $chan $nick %spam.ban.type spam in $chan is not allowed ! }
      }
}

Last edited by vinifera; 14/02/12 05:38 PM.
vinifera #236244 14/02/12 07:45 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
The way you have it isn't going to work. For example, let's say www is in your text file. $1 is www. test. com (without spaces... the forum's converting the link on me). You are doing a search for *www.test.com*, which will of course not be found in your text file. You're basically doing it backwards. You want to see if the words from your spam file are in what is said instead of seeing if what's said is in your spam file.

Spam management can be tricky because you have to check a lot of words and variations and trying to do it from a basic text file may not be the best solution. In many cases, a regex solution will work far better for this sort of thing.

Last edited by Riamus2; 14/02/12 07:48 PM.

Invision Support
#Invision on irc.irchighway.net
Riamus2 #236246 14/02/12 07:57 PM
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
If you're looking to filter out generic forms of text, a regex is probably better suited. For a large list of specific text, the following may suit your needs. In either case a hash table should probably be used.

You can loop through every bad word, and compare to input line. This will allow you to match partial words.
Code:
alias partialwords {
  if (!$hget(badwords)) {
    hmake badwords
    hload -n badwords badwords.txt
  }
  var %i = $hget(badwords,0).item
  while (%i) {
    if ($hget(badwords,%i) isin $1-) return 1
    dec %i
  }
}

Loki12583 #236266 15/02/12 11:31 AM
Joined: Jun 2009
Posts: 96
V
Babel fish
OP Offline
Babel fish
V
Joined: Jun 2009
Posts: 96
looks complicated :P

vinifera #236304 17/02/12 01:47 AM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
...but is more effective for most cases smile
If you don't want to go for the usually fastest but more demanding method (that is: regular expressions and a $hfind(,R) lookup) but also don't want to use a while-loop that checks all words separately, this "mixed" approach might be of use.


Link Copied to Clipboard