mIRC Home    About    Download    Register    News    Help

Print Thread
#202022 12/07/08 02:10 AM
Joined: Oct 2007
Posts: 102
B
bcancer Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2007
Posts: 102
I would like to kick or ban the exact word.
Exemple: kick sex but not kick sexy ??

Code:
 
on @*:text:*:#:{
if ($nick isop $chan) halt
if ($nick isvoice $chan) halt
  var %a 1
  while (%a <= $ini($scriptdirswearr.txt,channels,0)) {
    if ($chan == $ini($scriptdirswearr.txt,channels,%a)) { .timer- 1 .5 check-words $nick $chan $1- }
    inc %a
  }
}
alias -l check-words {
  var %b 1
  while (%b <= $ini($scriptdirswearr.txt,words,0)) {
    if ($ini($scriptdirswearr.txt,words,%b) isin $strip($3-)) {
      if ($readini($scriptdirswearr.txt,commands,punishment) == Kick/Ban) { ban -u $+ $readini($scriptdirswearr.txt,commands,bantime) $2 $1 3 }
      kick $2 $1 $readini($scriptdirswearr.txt,commands,kickmsg))
      set %a $ini($scriptdirswearr.txt,words,0)
    }
    inc %b
  }
  unset %b
}
alias swearr { if (!dialog(swearr)) { dialog -dmn swearr swearr } | else { dialog -c swearr } }
dialog swearr {
  title "Banned Words"
  size -1 -1 169 155
  option dbu
  box "Bad Words", 1, 3 1 80 73
  button "Add", 3, 7 60 33 11,flat
  button "Delete", 4, 44 60 33 11,flat
  list 2, 6 9 72 50, sort size
  box "Protected Channels", 5, 86 1 80 73
  button "Add", 6, 91 60 33 11,flat
  button "Delete", 7, 128 60 33 11,flat
  list 8, 90 9 72 50, size
  text "Select Punishment", 9, 6 85 44 8
  combo 10, 53 84 60 30, size drop
  button "Save && Exit", 11, 70 140 37 12, ok,flat
  box "Other Options", 13, 3 76 163 55
  text "Ban Time:", 14, 6 97 24 8
  edit "", 15, 32 95 17 10, right
  text "Seconds", 16, 50 97 21 8
  text "Kick Msg:", 17, 6 108 24 8
  edit "", 18, 32 106 130 10
  check "Protect Ops", 12, 19 119 50 10
  check "Protect Voiced Users", 19, 78 119 60 10
}
on *:dialog:swearr:init:*:{
  did -a $dname 10 Kick Only
  did -a $dname 10 Kick/Ban
  var %a 1
  while (%a <= $ini($scriptdirswearr.txt,words,0)) {
    did -a $dname 2 $ini($scriptdirswearr.txt,words,%a)
    inc %a
  }
  var %b 1
  while (%b <= $ini($scriptdirswearr.txt,channels,0)) {
    did -a $dname 8 $ini($scriptdirswearr.txt,channels,%b)
    inc %b
  }
  if ($readini($scriptdirswearr.txt,commands,punishment) === Kick Only) { did -c $dname 10 1 | did -b $dname 14,15,16 }
  if ($readini($scriptdirswearr.txt,commands,punishment) === Kick/Ban) { did -c $dname 10 2 | did -e $dname 14,15,16 }
  did -ra $dname 15 $readini($scriptdirswearr.txt,commands,bantime)
  did -ra $dname 18 $readini($scriptdirswearr.txt,commands,kickmsg)
  if ($readini($scriptdirswearr.txt,protect,ops)) { did -c $dname 12 }
  if ($readini($scriptdirswearr.txt,protect,voice)) { did -c $dname 19 }
}
on *:dialog:swearr:sclick:*:{
  if ($did == 3) { var %word $?="Enter a bad word" | if (%word == $null) { halt } | did -a $dname 2 %word | writeini $scriptdirswearr.txt words %word is }
  if ($did == 4 && $did(2).sel) { var %word $did(2).seltext | did -d $dname 2 $did(2).sel | remini $scriptdirswearr.txt words %word }
  if ($did == 6) { 
    var %chan $?="Enter a channel"
    if (%chan == $null ) { halt }
    if ($left(%chan,1) != $chr(35)) { set %chan $chr(35) $+ %chan | did -a $dname 8 %chan | writeini $scriptdirswearr.txt channels %chan is | unset %chan | halt } 
    else { did -a $dname 8 %chan | writeini $scriptdirswearr.txt channels %chan is | unset %chan } 
  }
  if ($did == 7 && $did(8).sel) { var %chan $did(8).seltext | did -d $dname 8 $did(8).sel | remini $scriptdirswearr.txt channels %chan } 
  if ($did == 10) { if ($did(10).sel == 1) { writeini $scriptdirswearr.txt commands punishment Kick Only | did -b $dname 14,15,16 } | if ($did(10).sel == 2) { writeini $scriptdirswearr.txt commands punishment Kick/Ban | did -e $dname 14,15,16 } }
  if ($did == 11) { 
    if ($did(15) != $null && $readini($scriptdirswearr.txt,commands,punishment) == Kick/Ban) { writeini $scriptdirswearr.txt commands bantime $did(15) }
    if ($did(18) != $null) { writeini $scriptdirswearr.txt commands kickmsg $did(18) }
    dialog -x $dname
  }
  if ($did == 12) { if ($ini($scriptdirswearr.txt,protect,ops)) { remini $scriptdirswearr.txt protect ops | write -l6 $script ;if ( $+ $chr(36) $+ nick isop $chr(36) $+ chan) { halt } | .reload -rs $script } | else { writeini $scriptdirswearr.txt protect ops is | write -l6 $script if ( $+ $chr(36) $+ nick isop $chr(36) $+ chan) halt | .reload -rs $script } }
  if ($did == 19) { if ($ini($scriptdirswearr.txt,protect,voice)) { remini $scriptdirswearr.txt protect voice | write -l7 $script ;if ( $+ $chr(36) $+ nick isvoice $chr(36) $+ chan) { halt } | .reload -rs $script } | else { writeini $scriptdirswearr.txt protect voice is | write -l7 $script if ( $+ $chr(36) $+ nick isvoice $chr(36) $+ chan) halt | .reload -rs $script } }

}



Last edited by bcancer; 12/07/08 02:22 AM.
bcancer #202023 12/07/08 03:28 AM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Instead of doing

if (word isin word_list)

do:

if ($istok(word_list,word,32))

If you need case-sensitive, use $istokcs instead of $istok

Note that 32 is the ASCII value of the separator between your words in the list, use 9 if tab-delimited, 44 if comma-delimited, etc.

maroon #202024 12/07/08 03:42 AM
Joined: Oct 2007
Posts: 102
B
bcancer Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2007
Posts: 102
Sorry i dont get it or dunno what to add or change ??

bcancer #202025 12/07/08 04:22 AM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I assumed that if you had written the above code you would know what I'm talking about. Don't use ISIN

if ($ini($scriptdirswearr.txt,words,%b) isin $strip($3-))

should be changed to

if ($istok($strip($3-),$ini($scriptdirswearr.txt,words,%b),32))

This will only find exact words, so if someone has a period or a comma or other punctuation attached to the bad word, this won't find it.

Assuming your bad-words don't have punctuation in them, you can strip them from your "sentence" before searching, ie

var %sentence = $3-

becomes

var %sentence = $replace($strip($3-),!,$chr(32),.,$chr(32),$chr(44),$chr(32),$chr(63),$chr(32))

by changing punctuation characters into spaces, you avoid them causing "blah blah sex." from seeing it as a bad word.

maroon #202030 12/07/08 08:50 AM
Joined: Oct 2007
Posts: 102
B
bcancer Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Oct 2007
Posts: 102
Thx very much maroon its working fine now smile


Link Copied to Clipboard