mIRC Homepage
Posted By: Garou bad word dialog - 06/05/07 03:32 PM
Is it possible for someone to make a bad word trigger script using this dialog with a timer kick message?

Code:
 

alias cspam _dialog -dmn cspam cspam

dialog cspam {
  title "Offensive Words Trigger"
  size -1 -1 400 320
  list 1, 10 45 380 210, sort
  button "Add", 2, 30 290 60 25, default,flat
  button "Update", 7, 100 290 60 25, disable,flat
  button "Remove", 3, 170 290 60 25, disable,flat
  check "Enable Protection", 4, 50 250 120 25
  edit "", 5, 10 20 380 25, autohs
  box "You Can Use Wildmasks Trigger", 6, 5 5 390 275
  check "Use penalty on spammer", 8, 200 250 150 25
  button "Ok", 9, 310 290 60 25, ok,flat
  button "Cancel", 10, 240 290 60 25, cancel,flat
}

Posted By: RusselB Re: bad word dialog - 06/05/07 05:45 PM
A few small problems with your dialog layout, and a recommendation for a change to your layout, along with the balance of the code to the best of my ability based on what you've given.
Code:
alias cspam   dialog $iif(!$dialog(cspam),-mdn,-ev) cspam cspam

dialog cspam {
  title "Offensive Words Trigger"
  size -1 -1 400 320
  option pixels
  combo 1, 10 20 380 235, size
  button "Add", 2, 30 290 60 25, disable default flat
  button "Update", 7, 100 290 60 25, disable flat
  button "Remove", 3, 170 290 60 25, disable flat
  check "Enable Protection", 4, 50 250 120 25
  box "You Can Use Wildmasks Trigger", 6, 5 5 390 275
  check "Use penalty on spammer", 8, 200 250 150 25
  button "Ok", 9, 310 290 60 25, flat ok
  button "Cancel", 10, 240 290 60 25, flat cancel
}
on *:dialog:cspam:init:0:{
  if !$hget(cspam) { .hmake cspam 100 }
  if $exists(cspam.hsh) { .hload cspam cspam.hsh }
  did -r $dname 1
  var %a = 1, %b = $hget(cspam,0).item
  while %a <= %b {
    did -a $dname 1 $hget(cspam,%a).item
    inc %a
  }
}
on *:dialog:cspam:edit:1:{
  did -e $dname 2
}
on *:dialog:cspam:sclick:2:{
  did -a $dname 1 $did(1,0)
  did -d $dname 1 0
}
on *:dialog:cspam:sclick:3:{
  if $did(1,0) {
    did -d $dname 1 $didwm($dname,1,$did(1,0))
  }
  elseif $did(1).seltext {
    did -d $dname 1 $did(1).sel
  }
}
on *:dialog:cspam:dclick:1:{
  did -d $dname 1 $did(1).sel
}
on *:dialog:cspam:sclick:1:{
  did -e $dname 2,7
}
on *:dialog:cspam:sclick:7:{
  did -d $dname 1 $did(1).sel
  did -a $dname 1 $did(1,0)
}
on *:dialog:cspam:sclick:9:{
  .hfree cspam
  var %a = 1, %b = $did(1).lines
  while %a <= %b {
    .hadd -m cspam %a $did(1,%a)
    inc %a
  }
  .hadd -m cspam Enabled $did(4).state
  .hadd -m cspam Penalty $did(8).state
}
on *:dialog:cspam:close:0:{
  if $hget(cspam,0).item {
    .hsave -o cspam cspam.hsh
  }
}
on *:dialog:cspam:sclick:4:{
  .hadd -m cspam Enabled $did(4).state
}
on *:dialog:cspam:sclick:8:{
  .hadd -m cspam Penalty $did(8).state
}
on @*:text:*:#:{
  if $hget(cspam,Enabled) {
    var %a = 1, %b = $0
    while %a <= %b {
      if $hfind(cspam,$gettok($1-,%a,32),1) {
        if !$hget(cspam,Penalty) {
          kick $chan $nick Bad Word detected
          %a = %b
        }
        else {
          .hinc cspam $fulladddress 10
          .ban -ku $+ $hget(cspam,$fulladdress) $chan $nick Bad Words detected.  Ban for $duration($hget(cspam,$fulladdress))
          %a = %b
        }
      }
      inc %a
    }
  }
}
Posted By: sparta Re: bad word dialog - 06/05/07 06:54 PM
If you want, then i can send u my bad word kicker, it works just fine, and you need to configure your dialog so it works with my code, or use the popup menus i made, made a dialog too, but thats something i havent been riping out from my script smile
Posted By: Garou Re: bad word dialog - 06/05/07 11:22 PM
Its not working, when i add a word its adding a numbers and its also adding the word Enabled and Penalty ??
Posted By: RusselB Re: bad word dialog - 07/05/07 01:08 AM
Sorry, change
Code:
did -a $dname 1 $hget(cspam,%a).item
to
Code:
did -a $dname 1 $hget(cspam,%a).data


That should be the only change you need.
Posted By: Garou Re: bad word dialog - 07/05/07 01:25 AM
Ok thx and also when I check the enable and penalty box all it does is add number 1 and the box wont stay checked.
Posted By: RusselB Re: bad word dialog - 07/05/07 02:43 AM
Re-write
Code:
alias cspam   dialog $iif(!$dialog(cspam),-mdn,-ev) cspam cspam

dialog cspam {
  title "Offensive Words Trigger"
  size -1 -1 400 320
  option pixels
  combo 1, 10 20 380 235, size
  button "Add", 2, 30 290 60 25, disable default flat
  button "Update", 7, 100 290 60 25, disable flat
  button "Remove", 3, 170 290 60 25, disable flat
  check "Enable Protection", 4, 50 250 120 25
  box "You Can Use Wildmasks Trigger", 6, 5 5 390 275
  check "Use penalty on spammer", 8, 200 250 150 25
  button "Ok", 9, 310 290 60 25, flat ok
  button "Cancel", 10, 240 290 60 25, flat cancel
}
on *:dialog:cspam:*:*:{
  if $devent == init {
    if !$hget(cspam) { .hmake cspam 100 }
    if $exists(cspam.hsh) { .hload cspam cspam.hsh }
    did -r $dname 1
    did $iif($hget(cspam,Enabled),-c,-u) $dname 4
    did $iif($hget(cspam,Penalty),-c,-u) $dname 8
    var %a = 1, %b = $hget(cspam,0).item
    while %a <= %b {
      if !$istok(Enabled Protect,$hget(cspam,%a).item,32) {        did -a $dname 1 $hget(cspam,%a).data      }
      inc %a
    }
  }
  elseif $devent == dclick && $did == 1 {    did -d $dname 1 $did(1).sel  }
  elseif $devent == edit && $did == 1 {    did -e $dname 2  }
  elseif $devent == sclick {
    if $did == 2 {
      did -a $dname 1 $did(1,0)
      did -d $dname 1 0
    }
    elseif $did == 3 {      did -d $dname 1 $iif($did(1).sel,$v1,$didwm($dname,1,$did(1,0)))    }
    elseif $did == 1 {      did -e $dname 2,7    }
    elseif $did == 7 {
      did -d $dname 1 $did(1).sel
      did -a $dname 1 $did(1,0)
    }
    elseif $did == 9 {
      .hfree cspam
      var %a = 1, %b = $did(1).lines
      while %a <= %b {
        .hadd -m cspam %a $did(1,%a)
        inc %a
      }
      .hadd -m cspam Enabled $did(4).state
      .hadd -m cspam Penalty $did(8).state
    }
    elseif $did == 4 || $did == 8 {
      .hadd -m cspam $iif($did == 4,Enabled,Penalty) $did($did).state
    }
  }
  elseif $devent == close {
    if $hget(cspam,0).item {
      .hsave -o cspam cspam.hsh
    }
  }
}
on @*:text:*:#:{
  if $hget(cspam,Enabled) {
    var %a = 1, %b = $0
    while %a <= %b {
      if $hfind(cspam,$gettok($1-,%a,32),1).data {
        if !$hget(cspam,Penalty) {
          kick $chan $nick Bad Word detected
          %a = %b
        }
        else {
          .hinc cspam $fulladddress 10
          .ban -ku $+ $hget(cspam,$fulladdress) $chan $nick Bad Words detected.  Ban for $duration($hget(cspam,$fulladdress))
          %a = %b
        }
      }
      inc %a
    }
  }
}
Posted By: Garou Re: bad word dialog - 07/05/07 02:56 AM
Ok i still cant see the checks in the check box and it wont kick or ban :P
Posted By: RusselB Re: bad word dialog - 07/05/07 03:00 AM
damn typos..code edited
Posted By: Garou Re: bad word dialog - 07/05/07 03:12 AM
All working but it wont kick or ban :P
Posted By: RusselB Re: bad word dialog - 07/05/07 04:01 AM
Does the bot/client that the code is on have full ops in the channel?
If not, make it so.
If so, what, if any, error messages are being generated?
Posted By: Garou Re: bad word dialog - 07/05/07 04:05 AM
Yes its full sop and no I dont get any error.
Posted By: RusselB Re: bad word dialog - 07/05/07 04:42 AM
missed a parameter in the $hfind line, so it was looking in the item, not the data for the match. Sorry. Code edited.
Posted By: Garou Re: bad word dialog - 07/05/07 04:51 AM
Cool its working fine now :P Last questions please, Why all these numbers adding in the box and in cspam.hash when i add a bad word?

3
0
4
0
5
1
6
1
7
1
8
1
9
1
Enabled
1
Penalty
1
12
1
10
gay
11
1
1
1
2
fag
Posted By: RusselB Re: bad word dialog - 07/05/07 05:24 AM
Only thing I can think of, is that it's an accumulation of past runs of the code that didn't work properly. If you don't have many words added yet, before you run the code next time, issue the following commands:
/remove cspam.hsh
/hfree cspam
Posted By: Garou Re: bad word dialog - 07/05/07 05:42 AM
ok thx very much for all your help.
© mIRC Discussion Forums