Hey guys. I've been messing around with a bad word filter. It's pretty straightforward, you can add/delete words & toggle it on/off if you have a certain access level, and the words get written to a simple txt file.
Code:
on +99:text:!filter*:#: {

  if ($2 == on) { 
    if (%filter) { msg # Filter staat al aan } 
    else { 
      msg # Filter geactiveerd
      set %filter On
      return
    }
  }
  if ($2 == off) {
    if (%filter) {
      msg # filter uitgeschakeld
      unset %filter on
      return
    }
    else { 
      msg # Filter is al uitgeschakeld
      return
    }
  }
  if ($2 == add) {
    if ($read(filter.txt,tnw,$3) != $null) {
      msg # ' $+ $3 $+ ' staat al op de lijst
      return
    }
    else {
      write filter.txt $3
      msg # ' $+ $3 $+ ' toegevoegd aan lijst met geblokkeerde woorden
      return
    }
  } 
  if ($2 == rem) {    
    if ($read(filter.txt,tnw,$3) != $null) {
      write -dl $+ $readn filter.txt
      msg # ' $+ $3 $+ ' verwijderd uit lijst met geblokkeerde woorden
      return
    }
    else {
      msg # ' $+ $3 $+ ' staat niet in de lijst
      return
    }
  }
  else { msg # ' $+ $2 $+ ' is geen geldige opdracht. Gebruik '!filter on' om de link protection te activeren en '!filter off om het weer uit te schakelen. }
}


on *:text:*:#: {
  if ($read(moderators.txt,tnw,$nick) != $null) { return }
  if (%filter) {
    if ($read(filter.txt,tnw,$1-)) { 
      /timer 1 1 msg $chan /timeout $nick 10
      return
    }
  }
}


When i got to the actual matching part i noticed that the way i was doing it had some obvious issues. Its matching the entire comments as a whole, instead of words individually.
Click to reveal..
For instance:
user: <banned word> -- word matches, user gets timed out
user: bla bla i went to paris <banned word> -- no match found


So my question is, could i do this with a text file at all?
Is there a way i can make it scan the comments for words that match a word on the text file?

Thanks for your time smile

Last edited by Sjoepele; 17/01/15 02:13 AM.