aIRC — File Browser

aIRCv0.8.69 / aIRCv0.8.69 / script / op.mrc

op.mrc — 22.17 KB — Download this file

;/**********************************************************************
; *
; * aIRC
; * Op Commands
; *
; **********************************************************************/

alias v { voice $1- }
alias dv { devoice $1- }
alias dop { deop $1- }
alias md { mdeop $1- }
;
alias opme {
  if ($iif($_ischan($1),$1,$chan)) { _bot opme $ifmatch }
}
alias opmeall { _usebotallchans opme <CHAN> }
alias voicemeall { _usebotallchans voiceme <CHAN> }
alias unbanme {
  if ($iif($_ischan($1),$1,$chan)) { _bot unbanme $ifmatch $iif($_ischan($1),$2,$1) }
}
alias inviteme {
  if ($iif($_ischan($1),$1,$chan)) { _bot inviteme $ifmatch }
}


; /_autokickloser <handle> <nick> <#chan>
alias _autokickloser {
  var %msg
  if ($_getuserfield($1,comment) != $null) { %msg = $ifmatch }
  else { %msg = $_evaltext($replace($_defmsg(kick+k),<HANDLE>,$1,<NICK>,$2,<CHAN>,$3)) }
  kb $3 $2 %msg
}

;;
;
; /ban [-ruN] [#channel] [nick|address],[nick|address]... [type]
;
alias ban {
  if ($_disconnected) {
    unset %c.ban.nodeop
    return
  }
  var %ban,%i = 1,%n,%time,%remove = 0,%tban,%command = _raw.ban,%deop = $iif($_getsetup(script,_deopdevoiceonban),1,0)
  if (%c.ban.nodeop) { %deop = 0 }
  unset %c.ban.nodeop
  if (-u* iswm $1) || ($1 == -r) {
    if ($remove($1,-u) isnum) && ($remove($1,-u) > 0) { %time = $remove($1,-u) }
    elseif ($1 == -r) {
      %remove = 1
      %command = _raw.unban
    }
    tokenize 32 $2-
  }
  if ($_not($_ischan($1))) { tokenize 32 $null $1- }
  tokenize 32 $_parmchans(Ban users [/ban],Channel:,ischan,Nick or Masks to ban,replace 32 44,1,$1,$2,$3)
  if ($_iamnotop4com($1,ban)) { return }
  if ($3 == $null) { tokenize 32 $1 $2 %_masknorm }
  while ($gettok($2,%i,44)) {
    var %n = $ifmatch,%tban
    if (. isin %n) || (* isin %n) {
      if (%remove == 0) && (%deop) && ($ialchan(%n,$1,0)) { deov $1 %n }
      %tban = %n
    }
    elseif ($_address(%n,$3)) {
      %tban = $_address(%n,$3)
      if (%remove == 0) && (%deop) && ($ialchan(%tban,$1,0)) { deov $1 %tban }
    }
    else { %tban = %n }
    %tban = $_fixmask(%tban)
    if (%tban != $null) {
      %command $1 %tban
      if (%time) { .timer_UNBAN $+ $1 $+ , $+ %tban 1 %time _raw.unban $1 %tban }
    }
    inc %i
  }
}
;
;;
;
; /kick -i [#channel] [nick|address],[nick|address]... [reason]
;
;

alias kick {
  if ($_disconnected) { return }
  var %nk,%kipn,%i = 1,%ip,%flags
  if (-* iswm $1) && ($removecs($1,-,i) == $null) {
    %flags = $1
    tokenize 32 $2-
  }
  if ($_not($_ischan($1))) { tokenize 32 $null $1- }
  tokenize 32 $_parmchans(Kick Users [/kick],Channel:,ischan,Nick or Masks to kick<CRLF>,replace 32 44,1,$1,$2,$3-)
  if ($_iamnotop4com($1,kick)) { return }
  while ($gettok($2,%i,44)) {
    %nk = $ifmatch
    if ($_ismask(%nk)) {
      var %ip = 1,%nk = $_fixmask(%nk)
      while ($ialchan(%nk,#$1,%ip).nick != $null) {
        if ($ifmatch != $me) { _kickqueue #$1 $ifmatch $3- }
        inc %ip
      }
    }
    elseif (%nk ison #$1) { _kickqueue #$1 %nk $3- }
    ;    else { _kickqueue #$1 %nk $3- }
    inc %i
  }
  if ($3- != $null) { _recent.add kickreason 20 $replace($3-,#$1,<CHAN>) }
}
;
;;
;
; /op [#channel] [nick|address],[nick|address]...
;
alias op {
  if ($_disconnected) { return }
  var %m,%i = 1,%n
  if ($_not($_ischan($1))) { tokenize 32 $null $1- }
  tokenize 32 $_parmchans(Give ops [/op],Channel:,ischan,Nicks or Masks to give ops:,replace 32 44,0,$1,$2-,$null)
  if ($_iamnotop4com($1,op)) { return }
  while ($gettok($2-,%i,44) != $null) {
    var %m = $ifmatch,%n = 1
    if ($_ismask(%m)) {
      while ($ialchan(%m,#$1,%n).nick != $null) {
        if ($ifmatch !isop #$1) { _raw.op #$1 $ifmatch }
        inc %n
      }
    }
    elseif (%m ison #$1) && (%m !isop #$1) { _raw.op #$1 $ifmatch }
    inc %i
  }
}
;
;;
;
; /deop [#channel] [nick|address],[nick|address]...
;
alias deop {
  if ($_disconnected) { return }
  var %m,%i = 1,%n,%k,%owner = 0
  if ($_not($_ischan($1))) { tokenize 32 $null $1- }
  tokenize 32 $_parmchans(Take Ops [/deop],Channel:,ischan,Nicks or Masks to take Ops:,replace 32 44,0,$1,$2-,$null)
  if ($_iamnotop4com($1,deop)) { return }
  if ($me isowner #$1) { %owner = 1 }
  while ($gettok($2-,%i,44) != $null) {
    var %m = $ifmatch,%n = 1
    if ($_ismask(%m)) {
      while ($ialchan(%m,#$1,%n).nick != $null) {
        if ($ifmatch != $me) {
          %k = $ifmatch
          if (%k isop #$1) { _raw.deop #$1 $ifmatch }
          if (%owner) && (%k isowner #$1) { _raw.deowner #$1 $ifmatch }
        }
        inc %n
      }
    }
    elseif (%m ison #$1) {
      if (%m isop #$1) { _raw.deop #$1 $ifmatch }
      if (%owner) && (%m isowner #$1) { _raw.deowner #$1 $ifmatch }
    }
    inc %i
  }
}
;
;;
;
; /voice [#channel] [nick|address],[nick|address]...
;
alias voice {
  if ($_disconnected) { return }
  var %m,%i = 1,%n
  if ($_not($_ischan($1))) { tokenize 32 $null $1- }
  tokenize 32 $_parmchans(Give Voice [/voice],Channel:,ischan,Nicks or Masks to give voice:,replace 32 44,0,$1,$2-,$null)
  if ($_iamnotop4com($1,voice)) { return }
  while ($gettok($2-,%i,44) != $null) {
    var %m = $ifmatch,%n = 1
    if ($_ismask(%m)) {
      while ($ialchan(%m,#$1,%n).nick != $null) {
        if ($ifmatch isreg #$1) { _raw.voice #$1 $ifmatch }
        inc %n
      }
    }
    elseif (%m ison #$1) && (%m isreg #$1) { _raw.voice #$1 $ifmatch }
    inc %i
  }
}
;
;;
;
; /devoice [#channel] [nick|address],[nick|address]...
;
alias devoice {
  if ($_disconnected) { return }
  var %m,%i = 1,%n
  if ($_not($_ischan($1))) { tokenize 32 $null $1- }
  tokenize 32 $_parmchans(Take Voice [/devoice],Channel:,ischan,Nick or Masks to take voice:,replace 32 44,0,$1,$2-,$null)
  if ($_iamnotop4com($1,devoice)) { return }
  while ($gettok($2-,%i,44) != $null) {
    var %m = $ifmatch,%n = 1
    if ($_ismask(%m)) {
      while ($ialchan(%m,#$1,%n).nick != $null) {
        if ($ifmatch != $me) {
          if ($ifmatch isvo #$1) { _raw.devoice #$1 $ifmatch }
        }
        inc %n
      }
    }
    elseif (%m ison #$1) && (%m isvo #$1) { _raw.devoice #$1 $ifmatch }
    inc %i
  }
}
;
;;
;
; /deov [#channel] [nick|address],[nick|address]...
;
alias deov {
  if ($_disconnected) { return }
  var %m,%i = 1,%n,%k,%owner = 0
  if ($_not($_ischan($1))) { tokenize 32 $null $1- }
  tokenize 32 $_parmchans(Take OPs and voice [/deov],Channel:,ischan,Nick or Masks to take ops and voice:,replace 32 44,0,$1,$2-,$null)
  if ($_iamnotop4com($1,deov)) { return }
  if ($me isowner #$1) { %owner = 1 }
  while ($gettok($2-,%i,44) != $null) {
    var %m = $ifmatch,%n = 1
    if ($_ismask(%m)) {
      while ($ialchan(%m,#$1,%n).nick != $null) {
        if ($ifmatch != $me) {
          %k = $ifmatch
          if (%owner) && (%k isowner #$1) { _raw.deowner #$1 $ifmatch }
          if (%k isop #$1) { _raw.deop #$1 $ifmatch }
          if (%k isvo #$1) { _raw.devoice #$1 $ifmatch }
        }
        inc %n
      }
    }
    elseif (%m ison #$1) {
      if (%owner) && (%m isowner #$1) { _raw.deowner #$1 $ifmatch }
      if (%m isop #$1) { _raw.deop #$1 $ifmatch }
      if (%m isvo #$1) { _raw.devoice #$1 $ifmatch }
    }
    inc %i
  }
}
;
;;
;
; /cop [nick|address],[nick|address]...
;
alias cop {
  if ($_disconnected) { return }
  var %mask = $_parameter($1,1,Op in all your channels [/cop],replace 32 44,$_activequery,Op in all channels where you have ops:),%i = $chan(0),%chan,%r = 0
  while (%i) {
    %chan = $chan(%i)
    if ($me isop %chan) {
      op %chan $1-
      inc %r
    }
    dec %i
  }
  if (%r == 0) { error.a /cop: You are not a channel operator in any channel }
}
;;
;
; /cvoice [nick|address],[nick|address]...
;
alias cvoice {
  if ($_disconnected) { return }
  var %mask = $_parameter($1,1,Voice in all your channels [/cvoice],replace 32 44,$_activequery,Voice in all channels where you have ops:),%i = $chan(0),%chan,%r = 0
  while (%i) {
    %chan = $chan(%i)
    if ($me isop %chan) {
      voice %chan $1-
      inc %r
    }
    dec %i
  }
  if (%r == 0) { error.a /cvoice: You are not a channel operator in any channel }
}
;;
;
; /cdeop [nick|address],[nick|address]...
;
alias cdeop {
  if ($_disconnected) { return }
  var %mask = $_parameter($1,1,Deop in all your channels [/cdeop],replace 32 44,$_activequery,Deop in all channels where you have ops:),%i = $chan(0),%chan,%r = 0
  while (%i) {
    %chan = $chan(%i)
    if ($me isop %chan) {
      deop %chan $1-
      inc %r
    }
    dec %i
  }
  if (%r == 0) { error.a /cdeop: You are not a channel operator in any channel }
}
;;
;
; /cdevoice [nick|address],[nick|address]...
;
alias cdevoice {
  if ($_disconnected) { return }
  var %mask = $_parameter($1,1,Devoice in all your channels [/cdevoice],replace 32 44,$_activequery,Devoice in all channels where you have ops:),%i = $chan(0),%chan,%r = 0
  while (%i) {
    %chan = $chan(%i)
    if ($me isop %chan) {
      devoice %chan $1-
      inc %r
    }
    dec %i
  }
  if (%r == 0) { error.a /cdevoice: You are not a channel operator in any channel }
}
;
;;
;
; /cdeov [nick|address],[nick|address]...
;
alias cdeov {
  if ($_disconnected) { return }
  var %mask = $_parameter($1,1,Deop and Devoice in all your channels [/cdeov],replace 32 44,$_activequery,Deop and Devoice in all channels where you have ops:),%i = $chan(0),%chan,%r = 0
  while (%i) {
    %chan = $chan(%i)
    if ($me isop %chan) {
      deov %chan $1-
      inc %r
    }
    dec %i
  }
  if (%r == 0) { error.a /cdeov: You are not a channel operator in any channel }
}
;
;;
;-
; /cban [-ruN] [nick|address],[nick|address]... [type]
;
alias cban {
  var %int,%t,%cs,%n,%pre,%nodeop = $iif(%c.ban.nodeop,1,0)
  unset %c.ban.nodeop
  if ($_disconnected) { return }
  if (-u* iswm $1) {
    %int = $_parameter($2,1,Ban from all your channels [/cban],replace 32 44,$_activequery,Ban in all channels where you have ops:)
    %t = $3
    %pre = $1
  }
  else {
    %int = $_parameter($1,1,Ban from all your channels [/cban],replace 32 44,$_activequery,Ban in all channels where you have ops:)
    %t = $2
  }
  if (%t == $null) { %t = %_masknorm }
  var %i = $chan(0),%chan,%r = 0
  while (%i) {
    %chan = $chan(%i)
    if ($me isop %chan) {
      %c.ban.nodeop = %nodeop
      ban %pre %chan %int %t
      inc %r
    }
    dec %i
  }
  if (%r == 0) { error.a /cban: You are not a channel operator in any channel }
}
;
;;
;
; /ckick [nick|address],[nick|address]... [reason]
;
alias ckick {
  if ($_disconnected) { return }
  var %flags
  if (-* iswm $1) && ($removecs($1,-,i) == $null) {
    %flags = $1
    tokenize 32 $2-
  }
  var %mask = $_parameter($1,1,Kick from all your channels [/ckick],replace 32 44,$_activequery,Kick in all channels where you have ops:),%msg = $2-,%i = $chan(0),%chan,%r = 0,%k
  while (%i) {
    %chan = $chan(%i)
    if ($me isop %chan) {
      var %k = 1,%nk
      while ($gettok(%mask,%k,44) != $null) {
        %nk = $ifmatch
        if ($ialchan(%nk,%chan,0) > 0) || (%nk ison %chan) { kick %flags %chan %nk %msg }
        inc %k
      }
      inc %r
    }
    dec %i
  }
  if (%r == 0) { error.a /cban: You are not a channel operator in any channel }
}
;;
;
; /ckb [-ruN] [nick|address],[nick|address]... [reason]
;
alias ckb {
  var %flags
  if (-* iswm $1) {
    %flags = $1
    tokenize 32 $2-
  }
  var %mask = $_parameter($1,1,Kick/ban from all your channels [/ckb],replace 32 44,$_activequery,Kick/ban in all channels where you have ops:),%msg = $2-
  ckick %mask %msg
  %c.ban.nodeop = 1
  cban %flags %mask
}
;;
;
; /cbk [-ruN] [nick|address],[nick|address]... [reason]
;
alias cbk {
  var %flags
  if (-* iswm $1) {
    %flags = $1
    tokenize 32 $2-
  }
  var %mask = $_parameter($1,1,Ban/kick from all your channels [/cbk],replace 32 44,$_activequery,Ban/kick in all channels where you have ops:),%msg = $2-
  cban %flags %mask
  .timer -m 1 100 ckick %mask %msg
}
;
;;
;
; /kb [-ruN] [#channel] [nick|address],[nick|address]... [reason]
;
alias kb {
  var %flags
  if (-* iswm $1) {
    %flags = $1
    tokenize 32 $2-
  }
  if ($_not($_ischan($1))) { tokenize 32 $null $1- }
  tokenize 32 $_parmchans(Kick and Ban [/kb],Channel:,ischan,Nicks or Masks to kick and ban:,replace 32 44,1,$1,$2,$3-)
  if ($_iamnotop4com($1,kb)) { return }
  kick #$1 $2 $3-
  %c.ban.nodeop = 1
  ban %flags #$1 $2
}
;
;;
;
; /bk [-ruN] [#channel] [nick|address],[nick|address]... [reason]
;
alias bk {
  var %flags
  if (-* iswm $1) {
    %flags = $1
    tokenize 32 $2-
  }
  if ($_not($_ischan($1))) { tokenize 32 $null $1- }
  tokenize 32 $_parmchans(Ban and Kick [/bk],Channel:,ischan,Nicks or Masks to ban and kick:,replace 32 44,1,$1,$2,$3-)
  if ($_iamnotop4com($1,bk)) { return }
  ban %flags #$1 $2
  .timer -m 1 100 kick #$1 $2 $3-
}
;
;;
;
; -( Mass )-
;
;;
;
;;
;
; /kbguest [#channel]
;
alias kbguest {
  if ($_disconnected) { return }
  tokenize 32 $_parameter($iif($1,$1,#),1,Kick and Ban Guests [/kbguest],ischan,$null,Channel:)
  if ($_iamnotop4com($1,kbguest)) { return }
  mode #$1 +b guest*
  kick #$1 guest* change your nick
}
;
;;
;
; /mop [#channel]
;
alias mop {
  if ($_disconnected) { return }
  var %c = $_parameter($iif($1,$1,#),1,MassOP [/mop],ischan,$null,Channel:)
  if ($_iamnotop4com(%c,mop)) { return }
  _nickscom  %c a o s _raw.op %c <NICK>
  if ($result == 0) { error.a No users in %c to massop }
}
;
;;
;
;  /mdeop [#channel]
;
alias mdeop {
  if ($_disconnected) { return }
  var %c = $_parameter($iif($1,$1,#),1,MassDeOP [/mdeop],ischan,$null,Channel:)
  if ($_iamnotop4com(%c,mdeop)) { return }
  _nickscom %c o $null op _raw.deop %c <NICK>
  if ($result == 0) { error.a No users in %c to massdeop }
}
;
;;
;
; /mvoice [#channel]
;
alias mvoice {
  if ($_disconnected) { return }
  var %c = $_parameter($iif($1,$1,#),1,Mass Voice [/mvoice],ischan,$null,Channel:)
  if ($_iamnotop4com(%c,mvoice)) { return }
  _nickscom %c a ov voice _raw.voice %c <NICK>
  if ($result == 0) { error.a No users in %c to massvoice }
}
;
;;
;
; /mdevoice [#channel]
;
alias mdevoice {
  if ($_disconnected) { return }
  var %c = $_parameter($iif($1,$1,#),1,Mass Devoice [/mdevoice],ischan,$null,Channel:)
  if ($_iamnotop4com(%c,mdevoice)) { return }
  _nickscom %c v o op _raw.devoice %c <NICK>
  if ($result == 0) { error.a No users in %c to massdevoice }
}
;
;;
;
; /mdeov
;
alias mdeov {
  if ($_disconnected) { return }
  var %i = 0,%c = $_parameter($iif($1,$1,#),1,Mass DeOP/DeVoice [/mdeov],ischan,$null,Channel:)
  if ($_iamnotop4com(%c,mdeov)) { return }
  _nickscom %c o $null op _raw.deop %c <NICK>
  inc %i $result
  _nickscom %c v $null op _raw.devoice %c <NICK>
  inc %i $result
  if (%i == 0) { error.a No users in %c to mass deop/devoice }
}
;
;;
;
; /mb [#channel] [op|nop]
;
alias mb {
  if ($_disconnected) { return }
  var %show,%mt,%ops,%i = 0
  if ($3 == $null) { %show = 1 }
  if ($_not($_ischan($1))) { tokenize 32 $null $1- }
  tokenize 32 $_parmchans(Mass Ban [/mb],Channel:,ischan,$null,$null,1,$1,$null,$2)
  if ($_iamnotop4com(#$1,mb)) { return }
  if ($2 == $null) { _nickscom $1 a $null op ban $1 <NICK> }
  elseif ($2 == op) { _nickscom $1 o $null op ban $1 <NICK> }
  elseif ($2 == nop) { _nickscom $1 a o op ban $1 <NICK> }
  else {
    if (%show) { error.a Usage: /mb [#channel] [op|nop] }
    return
  }
  if ($result = 0) && (%show) { error.a No users in #$1 to massban }
}
;
;;
;
; /mk [#channel] [op|nop]
;
alias mk {
  if ($_disconnected) { return }
  var %show
  if ($3 == $null) { %show = 1 }
  if ($_not($_ischan($1))) { tokenize 32 $null $1- }
  tokenize 32 $_parmchans(Mass Kick [/mk],Channel:,ischan,$null,$null,1,$1,$null,$2)
  if ($_iamnotop4com(#$1,mk)) { return }
  if ($2 == $null) { _nickscom $1 a $null op kick $1 <NICK> Masskick }
  elseif ($2 == op) { _nickscom $1 o $null op kick $1 <NICK> Masskick }
  elseif ($2 == nop) { _nickscom $1 a o op kick $1 <NICK> Masskick }
  else {
    if (%show) { error.a Usage: /mk [op|nop] }
    return
  }
  if ($result == 0) { error.a No users in #$1 to masskick }
}
;
;;
;
; /mbk [#channel] [op|nop]
;
alias mbk {
  if ($_disconnected) { return }
  var %show = 0
  if ($3 == $null) { %show = 1 }
  if ($_not($_ischan($1))) { tokenize 32 $null $1- }
  tokenize 32 $_parmchans(Mass Ban/Kick [/mbk],Channel:,ischan,$null,$null,1,$1,$null,$2)
  if ($_iamnotop4com(#$1,mbk)) { return }
  if ($2 == $null) { _nickscom $1 a $null op bk $1 <NICK> MassKickBan }
  elseif ($2 == op) { _nickscom $1 o $null op bk $1 <NICK> MassKickBan }
  elseif ($2 == nop) { _nickscom $1 a o op bk $1 <NICK> MassKickBan }
  else {
    if (%show) { error.a Usage: /mbk [op|nop] }
  }
  if ($result == 0) { error.a No users in #$1 to mass ban/kick }
}
;
;;
;
; /mkb [#channel] [op|nop]
;
alias mkb {
  if ($_disconnected) { return }
  var %show = 0
  if ($3 == $null) { %show = 1 }
  if ($_not($_ischan($1))) { tokenize 32 $null $1- }
  tokenize 32 $_parmchans(Mass Kick/Ban [/mkb],Channel:,ischan,$null,$null,1,$1,$null,$2)
  if ($_iamnotop4com(#$1,mkb)) { return }
  if ($2 == $null) { _nickscom $1 a $null op kb $1 <NICK> MassBanKick }
  elseif ($2 == op) { _nickscom $1 o $null op kb $1 <NICK> MassBanKick }
  elseif ($2 == nop) { _nickscom $1 a o op kb $1 <NICK> MassBanKick }
  else {
    if (%show) { error.a Usage: /mkb [op|nop] }
  }
  if ($result == 0) { error.a No users in #$1 to mass kick/ban }
}
;
;;
;
; _nickscom <#channel> <include|$null> <exclude|$null> <exclude2|$null> command ...
;
;   include/exclude can contain one or more of:
;     a = all nicks, o = ops, h = helpers, v = voiced, r = regular
;   exclude2 can contain:
;     p = protecteds, o = protecteds by op
;     if you use "o" you must also use "p"
;   include/exclude can be $null
;
;  in the command, use <NICK> <CHAN> and <ADDRESS>
;
alias _nickscom {
  var %chan = $1,%i = $nick(%chan,0,$2,$3),%nick,%addy,%total = 0,%checkprot = 0,%protop = $iif(o isin $4,1,0)
  if (p isin $4) { %checkprot = 1 }
  while (%i) {
    var %nick = $nick(%chan,%i,$2,$3),%addy = $_address(%nick,5)
    if (%checkprot) && ($_isprot(%addy,%chan,%protop)) { }
    else {
      $replace($5-,<CHAN>,%chan,<NICK>,%nick,<ADDRESS>,%addy)
      inc %total
    }
    dec %i
  }
  return %total
}

; /kbd [-uN] [#chan1|#chan1*],[#chan2|#chan2*] [nick|address] [reason]
alias kbd {
  var %d,%chans,%who,%reason
  if (-* iswm $1-) {
    if (-u* iswm $1) && ($_isint($remove($1,-u))) { %d = $ifmatch }
    tokenize 32 $2-
  }
  if ($_ischan($replace($1,$chr(44),_))) {
    %chans = $_fixchans($1)
    tokenize 32 $2-
  }
  %who = $1
  %reason = $2-
  _dialog -m _kbd _kbd
  if (%chans != $null) { did -ac _kbd 1003 %chans }
  if (%who != $null) { did -ac _kbd 1005 %who }
  if (%reason != $null) { did -o _kbd 1202,1204 1 %reason }
  _kbd.refresh
  did -f _kbd 1202
}
dialog _kbd {
  size -1 -1 135 115
  option dbu
  title "Kick/Ban Dialog"

  box "",1101,5 1 125 90
  box "",1102,5 1 125 50

  text "Channel[s]:",1002,10 12 34 10,right
  combo 1003,45 10 80 100,drop sort edit
  text "User[s]:",1004,10 24 34 10,right
  combo 1005,45 22 80 100,drop sort edit

  check "/kick",1011,10 37 25 10
  check "/ban",1012,50 37 25 10
  check "/+ban",1013,90 37 25 10

  text "kick Reason:",1201,10 55 34 10,right
  edit "",1202,45 53 80 10,autohs
  text "+ban Reason:",1203,10 67 34 10,right
  edit "",1204,45 65 80 10,autohs

  check "temp ban",1205,10 79 35 10
  edit "",1206,47 79 15 10,autohs
  text "seconds",1207,64 81 28 8

  text "",2001,5 95 50 20
  button "&Do it!",2002,60 95 33 15,ok
  button "&Cancel",2003,97 95 33 15,cancel
}
ON *:DIALOG:_kbd:*:*:{
  if ($devent == init) {
    _mdx.init $_icofile(kickban.ico)
    var %i = $chan(0)
    while (%i) {
      did -a $dname 1003 $chan(%i)
      dec %i
    }
    did -c $dname 1011,1012
    did -o $dname 1206 1 60
    _dummy $_lang.loaddialog($dname,$dname,00086969,main.lang,$scriptdir)
  }
  elseif ($devent == sclick) && ($did == 2002) { _kbd.doit }
  _kbd.refresh
}
alias -l _kbd.refresh {
  var %d = _kbd
  did $iif($did(%d,1011).state,-e,-b) %d 1201,1202
  if ($did(%d,1012).state) {
    did $iif($did(%d,1013).state,-e,-b) %d 1203,1204
    did -e %d 1013,1205,1206,1207
  }
  else { did -b %d 1013,1203,1204,1205,1206,1207 }
}
alias -l _kbd.doit {
  var %d = _kbd,%chan,%whokick,%whoban,%kr,%br,%t = 0,%i,%j,%mychans = $replace($_mychans,$chr(44),$chr(32)),%pchan
  %chan = $_fixchans($did(%d,1003))
  %whokick = $_fixmask($gettok($gettok($did(%d,1005),1,44),1,32))
  %whoban = %whokick
  if ($gettok(%whokick,2,33) == *@*) && (* !isin $gettok(%whokick,1,33)) && (? !isin $gettok(%whokick,1,33)) {
    %whokick = $gettok(%whokick,1,33)
    if ($_address(%whokick,%_masknorm) != null) { %whoban = $ifmatch }
  }
  %kr = $did(%d,1202)
  %br = $did(%d,1204)
  if ($did(%d,1205).state) {
    if ($_isint($did(%d,1206))) { %t = $ifmatch }
  }
  if ($_not($_connected)) {
    did -o %d 2001 1 ERROR: You are not connected
    halt
  }
  if ($_not($did(%d,1011).state)) && ($_not($did(%d,1012).state)) {
    did -o %d 2001 1 ERROR: No actions to take
    halt
  }
  if (%whokick == $null) {
    did -o %d 2001 1 ERROR: Invalid user
    halt
  }
  if (%whoban == $null) {
    did -o %d 2001 1 ERROR: Invalid user
    halt
  }
  if (%chan == $null) {
    did -o %d 2001 1 ERROR: Invalid channel
    halt
  }
  %i = $numtok(%chan,44)
  while (%i) {
    if ($wildtok(%mychans,$gettok(%chan,%i,44),0,32)) {
      %j = $ifmatch
      while (%j) {
        %pchan = $addtok(%pchan,$wildtok(%mychans,$gettok(%chan,%i,44),%j,32),44)
        dec %j
      }
    }
    dec %i
  }
  %i = $numtok(%pchan,44)
  while (%i) {
    %chan = $gettok(%pchan,%i,44)
    if ($me isop %chan) {
      if ($did(%d,1011).state) { kick %chan %whokick %kr }
      if ($did(%d,1012).state) {
        if ($did(%d,1013).state) {
          if (%t) { +ban %whoban %chan % $+ bantime $+ %t %br }
          else { +ban %whoban %chan %br }
        }
        else {
          if (%t) { ban -u $+ %t %chan %whoban }
          else { ban %chan %whoban }
        }
      }
    }
    else { error.a You're not a channel operator in %chan }
    dec %i
  }
}