mIRC Home    About    Download    Register    News    Help

Print Thread
#250478 17/01/15 02:11 AM
Joined: Mar 2014
Posts: 42
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Mar 2014
Posts: 42
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.
Joined: Mar 2014
Posts: 215
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Mar 2014
Posts: 215
probably something as simple as this could work as an if statement, but new words have to be manually added
Code:
if (badword1 isin $1-) { foobar }


#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball
Joined: Mar 2014
Posts: 42
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Mar 2014
Posts: 42
Yeah thats what i've been using so far. Im changing it up because i want people to be able to add/remove words when i'm not there (script is running on someone elses channel)

But yeah that definitely does work

Joined: Jun 2014
Posts: 248
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
I'm concerned that checking everything said in a channel verse every word in a textfile will run quite poorly. I'm also concerned that isin will match false positives for certain words. You might want to make sure that you pick words that won't accidentally show up as part of another words or use a different method.

Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Code:
on *:text:*:#: {
if ($ulevel >= 99) {
if ($strip($1) == !filter) {
if ($strip($2) == on) {
if (%filter == on) { msg $chan Filter Is Already On }
elseif (%filter == off) { set %filter on | msg $chan Filter Is Now %filter }
elseif (!%filter) { set %filter on | msg $chan FIlter is Now %filter }
}
elseif ($strip($2) == off) {
if (%filter == off) { msg $chan Filter Is Already Off }
elseif (%filter == on) { set %filter off | msg $chan Filter Is Now %filter }
elseif (!%filter) { set %filter off | msg $chan Filter Is Now %filter }
}
}
if ($strip($1) == !filteradd) {
var %p = 1
while (%p <= $lines(badwords.txt)) {
if ($gettok($read(badwords.txt, %p),1,126) == $gettok($strip($2-),1,126)) {
set %rmatch 1
msg $chan $gettok($strip($2-),1,126) Is Already In Filter List
}
if (%p == $lines(badwords.txt)) {
if (!%rmatch) { write badwords.txt $strip($2-) }
}
inc %p
}
}
if ($strip($1) == !filterrem) { 
var %o = 1
while (%o <= $lines(badwords.txt)) {
if ($gettok($read(badwords.txt, %o),1,126) == $strip($2-)) {
write $+(-dl,%o) badwords.txt
}
inc %o
}
}
}
if (%filter) {
    var %x = 1
    while (%x <= $numtok($strip($1-),32)) {
      var %b = 1
      var %y = $gettok($strip($1-),%x,32)
      while (%b <= $lines(badwords.txt)) {
        var %c = $gettok($read(badwords.txt, %b),1,126)
        if (%y == %c) || ($gettok($strip($1-),$+(%x,-,$numtok($gettok($read(badwords.txt, %b),1,126),32)),32) == $gettok($read(badwords.txt, %b),1,126)) {
;;;;THIS PART;;;;;
          mode $chan +b $address($nick,2) | kick $chan $nick BadWord Detected: $gettok($read(badwords.txt, %b),2,126) 
        }
        inc %b
      }
      inc %x
    }
  }
}


Hi There smile I Have A Very Simular Script In My Bot So I Added Your Version Of On/Off Toggle And Add and remove commands.
I Didn't Understand If You Wanted The Script To KickBan The User So You Can Change The KickBan Part. I Have Marked The Part With ;;;THIS PART;;; In Case You Couldn't Find It In The Code.
This Script Saves The Bad Words Or Expressions You Want And If It Finds A Match It KickBans The User. As I Said You Can Change That Part
So To Add A Word Or Expression You Have To Have user level 99 on users list of mIRC and you have to type !filteradd word~kickreason (e.g !filteradd you are a banana~im not a banana Mr. ) (or e.g !filteradd banana~no bananas allowed)
And To Delete A Word Or Expression You Should Just Type !filterrem word/expressionm (e.g !filterrem banana) (or e.g !filterrem you are a banana)
P.S-1 I Haven't tested it but i copied most of the code from my bot so it works 100% :P
P.S-2 (by expression i mean the sctipt can see for example this: you are a banana . and ban it. Not only one word.)
I Hope You Like It! If You Want Me To Change Anything Tell Me!

-OrFeAsGr-

Last edited by OrFeAsGr; 02/02/15 12:25 AM.

Link Copied to Clipboard