mIRC Home    About    Download    Register    News    Help

Print Thread
#115166 23/03/05 12:35 AM
Joined: Nov 2004
Posts: 21
D
di_mis Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Nov 2004
Posts: 21
Is there any friend who knows how do i make this code to catch also word with wildcards?? (ex. iswm)
Like *bad* or *dam* etc ..and not only the all word ???
this is the code :
on @*:TEXT:*:#: {
if ($nick !isop #) {
var %i = 0
while (%i < $numtok($read(swear.txt,1),32)) {
inc %i
var %current.word = $gettok($read(swear.txt,1),%i,32) {
if ($istok($strip($1-),%current.word,32) == $true) {
..and follows the kicks

thank you

Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
Code:
on @*:TEXT:*:#: {
  if ($nick !isop #) {
    var %i = 1
    while $gettok($read(swear.txt,1),%i,32) {
      if ($+(*,$v1,*) iswm $strip($1-)) { 
        ban -ku180 $chan $nick 2 Swearing is not allowed!
        halt
      }
      inc %i
    }
  }
}  


This will kick & ban for 3 mins the person who swears.


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
Currently the while condition reads the same line from the file each iteration. It would make more sense to read only once

Code:
on @*:text:*:#:{
  if ($nick !isop #) {
    tokenize 32 $read(swear.txt,1)
    set -ln %text $1-
    scon -r if ( $* isin % $+ text) $({,) ban -ku180 # $nick No swearing $(| halt },)
  }
}


Since each word in the file is re-evaluated with /scon, this assumes there is nothing in there that will be treated as code

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Using your code I added ISWM and fixed your mistake a typo I assume, you set %text after tokenizing it to the swear words frown
Code:
on *:text:*:#:{
  if ($nick !isop #) {
    set -ln %text $strip($1-)
    tokenize 32 $read(swear.txt,1)
    scon -r if ($+(*, $* ,*) iswm % $+ text) $({,) ban -ku180 # $nick No swearing $(| halt },)
  }
}

Joined: Nov 2004
Posts: 21
D
di_mis Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Nov 2004
Posts: 21
No guys ..i try to connect your codes with mine who has
warning first and then kick-ban but its not worked ..its crash my mirc
This is the original code
if someone can make it to work also with wildcards - iswm i thing(ex. *dam* or *shi*)...i will obliged

on @*:TEXT:*:#: {
if ($nick !isop #) {
var %i = 0
while (%i < $numtok($read(swear.txt,1),32)) {
inc %i
var %current.word = $gettok($read(swear.txt,1),%i,32) {
if ($istok($strip($1-),%current.word,32) == $true) {
set -u3600 %rl. [ $+ [ $address($nick,2) ] ] $calc( %rl. [ $+ [ $address($nick,2) ] ] + 1)
if (%rl. [ $+ [ $address($nick,2) ] ] == 1) {
notice $nick Please don't! - this is your first warning! next time is ban.
}
if (%rl. [ $+ [ $address($nick,2) ] ] >= 2) {
ban -k $chan $nick 2 Banned for $duration($duration(24 hrs)) --> $ifmatch <--
}
}
}
}
}
}

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Ok just to get this right, swear.txt is formated as so, on the first line there is a bunch of words seperated by spaces each is a swear word it might look like this (ps below you see some real nasty things to call people!!!!)
tinkywinky poe sclub7 hi5

OK the problem i think is in you trying to explain what you want to do, do you want it to kick/ban with this
(1) I love hi5's sound becuase its got hi5 in the sentence
and/or
(2) I love tin*ywinky becuase its got the word tinkywinky with a letter replaced with a *
and/or
(3) I love tinkyw$i%y becuase its got the word tinkywinky with a letters replaced with a other characters

Joined: Nov 2004
Posts: 21
D
di_mis Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Nov 2004
Posts: 21
First of all thank you Davec for your helping me
now...
as assume a badword is mayonnaise ..i want in swear.txt
to have the word *mayo* or (sorry about this) the bad word
is fuckers or fuckoff i want in swear.txt to have *f*ck*
I make it some try to set a code and is working - i don't now that is OK or not but it's work -
look and tell me ..this is the code:
on @*:TEXT:*:#: {
if ($nick !isop #) {
var %i = 1
while $gettok($read(swear.txt,1),%i,32) {
if ($+(*,$v1,*) iswm $strip($1-)) {
set -u1800 %rl. [ $+ [ $address($nick,2) ] ] $calc( %rl. [ $+ [ $address($nick,2) ] ] + 1)
if (%rl. [ $+ [ $address($nick,2) ] ] == 1) {
msg $chan $nick badword detected - Next time is ban -
}
if (%rl. [ $+ [ $address($nick,2) ] ] >= 2) {
ban -ku3600 $chan $nick 2 Banned-Badword!
}
}
inc %i
}
}
}

if this code is OK the only thing that i want (i try it but i cant make it) is how can i make the code to see what word the banned person say it and was banned:
ban -ku3600 $chan $nick 2 Banned-Badword! (word: ???)
*(word:??) = how can i make it this?

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
assuming that code works as you want, the word is $gettok($read(swear.txt,1),%i,32)

* Add a /RETURN after the /msg and the /ban as you want the event to exit after either of these commands.

I do not beleive you well get the desired effect by using wildcard words, since F*CK well match "the first lock is in the second door" ie First loCK. irst lo is the *

Joined: Nov 2004
Posts: 21
D
di_mis Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Nov 2004
Posts: 21
Yes i understand what u mean
ill try to fixed.
anyway i want to thank you for you help
thanks a lot also for the "word"
smile

Joined: Nov 2004
Posts: 21
D
di_mis Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Nov 2004
Posts: 21
ok DaveC i think now i have the problem
look what is happen
i have a swear.txt file with lots of words ..other with wildcard
other not !
example : *ash* *dam* mayo ...as assume the word mayo is a badword ....now if someone say in channel the word mayonnaise the code kicked heme ..how its happen this i dont know !
i understand this if the word mayo was with wildcard but it doesnt!
any idea?

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I would like you to try this instead, please read the comments in it as you must select 1 or 4 methods of pharsing/comparing the line (directly below Phase1 header)
The swear.txt should be formated with complete swear words sepearated by a spaces, you do not need wildcards for this one.

Code:
on @*:TEXT:*:#: {      
  if ($nick !isop #) {     
    tokenize 32 $strip($1-)
    ;
    ; ******************************************************************************
    ; *** Phase 1 : check if any of the swear words appear in the text as words. ***
    ; ******************************************************************************
    ;
    var %nicktext = $1-                                                                          | ; *** see below for explanation (1)
    var %nicktext = $remove($1-,$chr(32))                                                        | ; *** see below for explanation (2)
    var %nicktext | !.echo -q $regsub($1-,/[^A-Z a-z]+/g,,%nicktext) | var %nicktext = %nicktext | ; *** see below for explanation (3)
    var %nicktext | !.echo -q $regsub($1-,/[^A-Za-z]+/g,,%nicktext)  | var %nicktext = %nicktext | ; *** see below for explanation (4)
    ;
    ; * Please select only one of the above four lines remark out with a ; the other three you do not want. See below for explanation.
    ;
    var %swearwords = $$read(swear.txt,nt,1)
    var %i = $numtok(%swearwords,32)
    while (%i) {
      var %badword = $gettok(%swearwords,%i,32)
      if ($+(*,%badword,*) iswm %nicktext) {
        inc -u1800 %rl. [ $+ [ $address($nick,2) ] ]
        if (%rl. [ $+ [ $address($nick,2) ] ] == 1) { msg $chan $nick badword detected - Next time is ban - %badword }
        if (%rl. [ $+ [ $address($nick,2) ] ] &gt;= 2) { ban -ku3600 $chan $nick 2 Banned-Badword! - %badword }
        return
      }
      dec %i
    }
    ;
    ; ********************************************************************************************************************
    ; *** Phase 2 : Assume any non alpha is a character holder and search for matching words. ie "shìt typed as "sh!t" ***
    ; ********************************************************************************************************************
    ;
    var %swearwords = . $$read(swear.txt,nt,1) .
    var %nicktext | !.echo -q $regsub($1-,/[^A-Z a-z]+/g,*,%nicktext) | var %nicktext = %nicktext 
    var %i = $numtok(%nicktext,32)
    while (%i) {
      var %nickword = $gettok(%nicktext,%i,32)
      if (%nickword != *) {
        if ($(* %nickword *) iswm %swearwords) {
          inc -u1800 %rl. [ $+ [ $address($nick,2) ] ]
          if (%rl. [ $+ [ $address($nick,2) ] ] == 1) { msg $chan $nick badword detected - Next time is ban - $ [ $+ [ %i ] ] }
          if (%rl. [ $+ [ $address($nick,2) ] ] &gt;= 2) { ban -ku3600 $chan $nick 2 Banned-Badword! - $ [ $+ [ %i ] ] }
          return
        }
        dec %i
      }
    }
  }
}
;
;
;Phase 1 %nicktext is the source text the nick says, how you wish to pharse it is your choice, see below for whats likely to occur.
;Assume "shìt" is a bad word                                ::: text  "u shìt"  "u s h i t"  "u s-h-i-t"  "thrash it"  "thrash! It"
;Option(1) : plain text                                     ::: Catch    Y           N            N/y*         N            N
;Option(2) : accumulated plain text (spaces removed)        ::: Catch    Y           Y            N/y*         Y            N
;Option(3) : alpha text (remove non alphas except space)    ::: Catch    Y           N            Y            N            N
;Option(4) : accumulated alpha text (remove all but A-Za-z) ::: Catch    Y           Y            Y            Y            Y
;
; Note on Items marked with a /y* above, While these are not acctually caught here they are caught by phase two, so may be deemed as Y
;
;
;Phase 2 removes any one or more continuous non alpha except space replacing them with one * (which represents 0 or more characters in ISWM)
;"u shìt"     -&gt; "u shìt"
;"u s h i t"  -&gt; "u s h i t"
;"u s-h-i-t"  -&gt; "u s*h*i*t"
;"thrash it"  -&gt; "thrash it"
;"thrash! It" -&gt; "thrash* it"
;"you s%%t!"  -&gt; "you s*t*"
;Each word is then checked for a word boundry wildmatch into the list of swearwords, with "s*h*i*t" and "s*t*" being matched
;
;


* you might notice im using ì instead of i at some points.
This is only in the documentation, because the the forum keeps changing shìt spelt with a i into [censored] <<< see smile

Joined: Nov 2004
Posts: 21
D
di_mis Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Nov 2004
Posts: 21
wowwww
this is a great DaveC thanks thanks a lot
BUT he has a small problem
look what i mean:
if a badword is a idiot (and i wrote this in txt file)
THEN if someone say in channel damidiot or aridiotma or deidiot ..it catch it also this words!! (and we dont want that--we want to catch it only the "idiot" word)
and this is a serious problem for me frown
(i dont know maybe some isin needed ..i don't know)
buy the way i really really i apprisied to spend your time for this code
really thanks a lot!

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
on @*:TEXT:*:#: {      
  if ($nick !isop #) {     
    tokenize 32 $strip($1-)
    ;
    ; ******************************************************************************
    ; *** Phase 1 : check if any of the swear words appear in the text as words. ***
    ; ******************************************************************************
    ;
    var %nicktext                                                                                | ; *** see below for phase 1 option (0)
    ;var %nicktext = $1-                                                                          | ; *** see below for phase 1 option (1)
    ;var %nicktext = $remove($1-,$chr(32))                                                        | ; *** see below for phase 1 option (2)
    ;var %nicktext | !.echo -q $regsub($1-,/[^A-Z a-z]+/g,,%nicktext) | var %nicktext = %nicktext | ; *** see below for phase 1 option (3)
    ;var %nicktext | !.echo -q $regsub($1-,/[^A-Za-z]+/g,,%nicktext)  | var %nicktext = %nicktext | ; *** see below for phase 1 option (4)
    ;
    ; * Please select only one of the above four lines remark out with a ; the other three you do not want. See below for explanation.
    ;
    if ($len(%nicktext)) {
      var %swearwords = $$read(swear.txt,nt,1)
      var %i = $numtok(%swearwords,32)
      while (%i) {
        var %badword = $gettok(%swearwords,%i,32)
        if ($+(*,%badword,*) iswm %nicktext) {
          inc -u1800 %rl. [ $+ [ $address($nick,2) ] ]
          if (%rl. [ $+ [ $address($nick,2) ] ] == 1) { msg $chan $nick badword detected - Next time is ban - %badword }
          if (%rl. [ $+ [ $address($nick,2) ] ] &gt;= 2) { ban -ku3600 $chan $nick 2 Banned-Badword! - %badword }
          return
        }
        dec %i
      }
    }
    ;
    ; ********************************************************************************************************************
    ; *** Phase 2 : Assume any non alpha is a character holder and search for matching words. ie "shìt typed as "sh!t" ***
    ; ********************************************************************************************************************
    ;
    var %swearwords = . $$read(swear.txt,nt,1) .
    var %nicktext | !.echo -q $regsub($1-,/[^A-Z a-z]+/g,*,%nicktext) | var %nicktext = %nicktext 
    var %i = $numtok(%nicktext,32)
    while (%i) {
      var %nickword = $gettok(%nicktext,%i,32)
      if (%nickword != *) {
        if ($(* %nickword *) iswm %swearwords) {
          inc -u1800 %rl. [ $+ [ $address($nick,2) ] ]
          if (%rl. [ $+ [ $address($nick,2) ] ] == 1) { msg $chan $nick badword detected - Next time is ban - $ [ $+ [ %i ] ] }
          if (%rl. [ $+ [ $address($nick,2) ] ] &gt;= 2) { ban -ku3600 $chan $nick 2 Banned-Badword! - $ [ $+ [ %i ] ] }
          return
        }
        dec %i
      }
    }
  }
}
;
;
;Phase 1 %nicktext is the source text the nick says, how you wish to pharse it is your choice, see below for whats likely to occur.
;Assume "shìt" is a bad word                                ::: text  "u shìts"  "u s h i t s"  "u s-h-i-t-s"  "thrash its"  "thrash! Its"
;Option(0) : Phase 1 disabled                               ::: Catch     N              N             N             N             N (default)
;Option(1) : plain text                                     ::: Catch     Y              N             N/y*          N             N
;Option(2) : accumulated plain text (spaces removed)        ::: Catch     Y              Y             N/y*          Y             N
;Option(3) : alpha text (remove non alphas except space)    ::: Catch     Y              N             Y             N             N
;Option(4) : accumulated alpha text (remove all but A-Za-z) ::: Catch     Y              Y             Y             Y             Y
;
; Note on Items marked with a /y* above, While these are not acctually caught here they are caught by phase two, so may be deemed as Y
;
;
;Phase 2 removes any one or more continuous non alpha except space replacing them with one * (which represents 0 or more characters in ISWM)
;"u shìt"     -&gt; "u shìt"
;"u s h i t"  -&gt; "u s h i t"
;"u s-h-i-t"  -&gt; "u s*h*i*t"
;"thrash it"  -&gt; "thrash it"
;"thrash! It" -&gt; "thrash* it"
;"you s%%t!"  -&gt; "you s*t*"
;Each word is then checked for a word boundry wildmatch into the list of swearwords, with "s*h*i*t" and "s*t*" being matched
;
;

Joined: Nov 2004
Posts: 21
D
di_mis Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Nov 2004
Posts: 21
THANKS VERY MUTCH DaveC
YOU ARE VERY GENTLE
smile

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Sorry for the repeat posts, just been reported a critical error in it so found and fixed it. I put a extra if condition inisde a while loop and encased the dec %i of the while counter inside the condition, oooops!

Code:
on @*:TEXT:*:#: {      
  if ($nick !isop #) {     
    tokenize 32 $strip($1-)
    ;
    ; ******************************************************************************
    ; *** Phase 1 : check if any of the swear words appear in the text as words. ***
    ; ******************************************************************************
    ;
    var %nicktext                                                                                | ; *** see below for phase 1 option (0)
    ;var %nicktext = $1-                                                                          | ; *** see below for phase 1 option (1)
    ;var %nicktext = $remove($1-,$chr(32))                                                        | ; *** see below for phase 1 option (2)
    ;var %nicktext | !.echo -q $regsub($1-,/[^A-Z a-z]+/g,,%nicktext) | var %nicktext = %nicktext | ; *** see below for phase 1 option (3)
    ;var %nicktext | !.echo -q $regsub($1-,/[^A-Za-z]+/g,,%nicktext)  | var %nicktext = %nicktext | ; *** see below for phase 1 option (4)
    ;
    ; * Please select only one of the above four lines remark out with a ; the other three you do not want. See below for explanation.
    ;
    if ($len(%nicktext)) {
      var %swearwords = $$read(swear.txt,nt,1)
      var %i = $numtok(%swearwords,32)
      while (%i) {
        var %badword = $gettok(%swearwords,%i,32)
        if ($+(*,%badword,*) iswm %nicktext) {
          inc -u1800 %rl. [ $+ [ $address($nick,2) ] ]
          if (%rl. [ $+ [ $address($nick,2) ] ] == 1) { msg $chan $nick badword detected - Next time is ban - %badword }
          if (%rl. [ $+ [ $address($nick,2) ] ] &gt;= 2) { ban -ku3600 $chan $nick 2 Banned-Badword! - %badword }
          return
        }
        dec %i
      }
    }
    ;
    ; ********************************************************************************************************************
    ; *** Phase 2 : Assume any non alpha is a character holder and search for matching words. ie "shìt typed as "sh!t" ***
    ; ********************************************************************************************************************
    ;
    var %swearwords = . $$read(swear.txt,nt,1) .
    var %nicktext | !.echo -q $regsub($1-,/[^A-Z a-z]+/g,*,%nicktext) | var %nicktext = %nicktext 
    var %i = $numtok(%nicktext,32)
    while (%i) {
      var %nickword = $gettok(%nicktext,%i,32)
      if (%nickword != *) {
        if ($(* %nickword *) iswm %swearwords) {
          inc -u1800 %rl. [ $+ [ $address($nick,2) ] ]
          if (%rl. [ $+ [ $address($nick,2) ] ] == 1) { msg $chan $nick badword detected - Next time is ban - $ [ $+ [ %i ] ] }
          if (%rl. [ $+ [ $address($nick,2) ] ] &gt;= 2) { ban -ku3600 $chan $nick 2 Banned-Badword! - $ [ $+ [ %i ] ] }
          return
        }
      }
      dec %i
    }
  }
}
;
;
;Phase 1 %nicktext is the source text the nick says, how you wish to pharse it is your choice, see below for whats likely to occur.
;Assume "shìt" is a bad word                                ::: text  "u shìts"  "u s h i t s"  "u s-h-i-t-s"  "thrash its"  "thrash! Its"
;Option(0) : Phase 1 disabled                               ::: Catch     N              N             N             N             N (default)
;Option(1) : plain text                                     ::: Catch     Y              N             N/y*          N             N
;Option(2) : accumulated plain text (spaces removed)        ::: Catch     Y              Y             N/y*          Y             N
;Option(3) : alpha text (remove non alphas except space)    ::: Catch     Y              N             Y             N             N
;Option(4) : accumulated alpha text (remove all but A-Za-z) ::: Catch     Y              Y             Y             Y             Y
;
; Note on Items marked with a /y* above, While these are not acctually caught here they are caught by phase two, so may be deemed as Y
;
;
;Phase 2 removes any one or more continuous non alpha except space replacing them with one * (which represents 0 or more characters in ISWM)
;"u shìt"     -&gt; "u shìt"
;"u s h i t"  -&gt; "u s h i t"
;"u s-h-i-t"  -&gt; "u s*h*i*t"
;"thrash it"  -&gt; "thrash it"
;"thrash! It" -&gt; "thrash* it"
;"you s%%t!"  -&gt; "you s*t*"
;Each word is then checked for a word boundry wildmatch into the list of swearwords, with "s*h*i*t" and "s*t*" being matched
;
;

Joined: Nov 2004
Posts: 21
D
di_mis Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Nov 2004
Posts: 21
thanks davec ! i had this problem too

Joined: May 2005
Posts: 1
L
Mostly harmless
Offline
Mostly harmless
L
Joined: May 2005
Posts: 1
DaveC i love the code yet i have a question for you.

I have this code in use now, yet when testing it, i am just wondering if there is any way to reset the user. For example ... if someone swears twice (unknown to them) and then the ban expires (or is removed) how can that user have their name removed the the ban/swear list. If that makes sense at all (in essence what happened is they were posting what popped up for them when they were kicked and BANG got banned again and no warning. I am wondering how the code can be altered to fix this).

I mean it is great code but i need to get it altered and wasn't sure how to fix it to suite my needs atm. I wasnt sure if there was a way to have the nicknames that offended written to a file and then have that file called upon as a reference to the swear filter.

Thanks


Link Copied to Clipboard