All pastes #756919 Raw Edit

auto limiter

public text v1 · immutable
#756919 ·published 2007-10-31 20:45 UTC
rendered paste body
alias autolimit {
  var %x 1,%y
  while ($gettok(%limitchannels,%x,32)) {
    %y = $ifmatch
    if ($calc($chan(%y).limit - $nick(%y,0)) < %limitno) && ($chan(%y).limit != $calc($nick(%y,0) + %limitno)) && ($me isop %y) {
      mode %y +l $calc($nick(%y,0) + %limitno) 
    }
    if ($chan(%y).limit == $null) && ($me isop %y) {
      mode %y +l $calc($nick(%y,0) + %limitno) 
    }
    inc %x
  }
}

dialog autolimit {
  title "auto limiter"
  size -1 -1 180 100
  option dbu
  button "ok",1, 190 80 15 10
  box ,2,2 2 176 96
  list 3, 10 16 50 70
  text "channels",4, 21 7 25 7
  button "del",5, 23 80 20 10
  edit ,6, 80 20 15 10
  text "users in",7, 100 20 40 10
  edit ,8, 122 20 18 10
  text "secs",9, 145 20 15 10
  button "start limiter!",10, 87 40 50 10
  button "stop limiter!",11, 87 60 50 10
  text "allow",12, 100 9 25 10
}

on *:dialog:autolimit:*:*: {
  if ($did == 5) && ($devent == sclick) {
    did -d $dname 3 $did($dname,3).sel
  }
  if ($did == 6) && ($devent == edit) {
    set %limitno $did($dname,6).text
  }
  if ($did == 8) && ($devent == edit) {
    set %limittime $did($dname,8).text
  }
  if ($did == 10) && ($devent == sclick) {
    set %limitchannels $didtok($dname,3,32)
    var %x 1
    while ($gettok(%limitchannels,%x,32)) {
      mode $ifmatch +l $calc($nick($ifmatch,0) + %limitno) 
      inc %x
    }
    .timerlimit 0 %limittime autolimit
  }
  if ($did == 11) && ($devent == sclick) {
    .timerlimit off
  }
  if ($did == 0) && ($devent == init) {
    did -h $dname 1
    did -a $dname 6 %limitno
    did -a $dname 8 %limittime
    var %x 1
    while ($chan(%x)) {
      did -a $dname 3 $chan(%x)
      inc %x
    }
  }
}

on *:exit: { unset %limitno,%limittime,%limitchannels }