aIRC — File Browser

aIRCv0.8.69 / aIRCv0.8.69 / script / cprotsetup.mrc

cprotsetup.mrc — 32.3 KB — Download this file

;/**********************************************************************
; *
; * aIRC
; * Channel Protection Setup
; *
; **********************************************************************/

alias _cprot {
  _prot.init
  _dialog -m cprot cprot
  if ($_ischan($1)) { _cprot.refresh $1 1 1 0 }
  elseif ($_ischan($active)) { _cprot.refresh $active 0 1 0 }
  else { _cprot.refresh $null 0 1 0 }
}
dialog cprot {
  size -1 -1 380 197
  option dbu
  title "Channel Protection"

  text "Settings:",1,10 25 30 8
  list 2,10 35 65 135,size
  button "Add",3,10 175 30 15
  button "Remove",4,45 175 30 15

  tab "Text",50,85 2 290 165
  box "User",51,90 20 280 115,tab 50
  box "Botnet",52,90 131 280 35,tab 50

  check "Global",60,95 30 30 8,tab 50
  check "Text Flood",61,125 30 60 8,tab 50
  edit "",62,190 28 17 10,autohs tab 50
  text "lines or",63,210 30 25 10,tab 50
  edit "",64,237 28 17 10,autohs tab 50
  text "bytes in",65,257 30 25 10,tab 50
  edit "",66,285 28 17 10,autohs tab 50
  text "seconds",67,305 30 25 10,tab 50
  button "Actions",68,330 28 35 12,tab 50

  check "Global",70,95 43 30 8,tab 50
  check "Notice Flood",71,125 43 60 8,tab 50
  edit "",72,190 41 17 10,autohs tab 50
  text "lines or",73,210 43 25 10,tab 50
  edit "",74,237 41 17 10,autohs tab 50
  text "bytes in",75,257 43 25 10,tab 50
  edit "",76,285 41 17 10,autohs tab 50
  text "seconds",77,305 43 25 10,tab 50
  button "Actions",78,330 41 35 12,tab 50

  check "Global",80,95 56 30 8,tab 50
  check "Colour Flood",81,125 56 60 8,tab 50
  edit "",82,190 54 17 10,autohs tab 50
  text "c/line or",83,210 56 25 10,tab 50
  edit "",84,237 54 17 10,autohs tab 50
  text "codes in",85,257 56 25 10,tab 50
  edit "",86,285 54 17 10,autohs tab 50
  text "seconds",87,305 56 25 10,tab 50
  button "Actions",88,330 54 35 12,tab 50

  check "Global",90,95 69 30 8,tab 50
  check "Ascii",91,125 69 60 8,tab 50
  edit "",92,190 67 17 10,autohs tab 50
  text "% of",93,210 69 25 10,tab 50
  edit "",94,237 67 17 10,autohs hide
  text "codes in",95,257 69 25 10,hide
  edit "",96,285 67 17 10,autohs tab 50
  text "chars",97,305 69 25 10,tab 50
  button "Actions",98,330 67 35 12,tab 50

  check "Global",100,95 82 30 8,tab 50
  check "Caps",101,125 82 60 8,tab 50
  edit "",102,190 80 17 10,autohs tab 50
  text "% of",103,210 82 25 10,tab 50
  edit "",104,237 80 17 10,autohs hide
  text "codes in",105,257 82 25 10,hide
  edit "",106,285 80 17 10,autohs tab 50
  text "chars",107,305 82 25 10,tab 50
  button "Actions",108,330 80 35 12,tab 50

  check "Global",110,95 95 30 8,tab 50
  check "Repeating",111,125 95 60 8,tab 50
  edit "",112,190 93 17 10,autohs tab 50
  text "repeats in",113,210 95 25 10,tab 50
  edit "",114,237 93 17 10,autohs hide
  text "codes in",115,257 95 25 10,hide
  edit "",116,285 93 17 10,autohs tab 50
  text "seconds",117,305 95 25 10,tab 50
  button "Actions",118,330 93 35 12,tab 50

  check "Global",120,95 108 30 8,tab 50
  check "Advertising",121,125 108 60 8,tab 50
  edit "",122,190 106 17 10,autohs hide
  button "setup",123,210 108 25 10,tab 50
  edit "",124,237 106 17 10,autohs hide
  button "setup",125,257 108 25 10,hide
  edit "",126,285 106 17 10,autohs,hide
  text "seconds",127,305 108 25 10,hide
  button "Actions",128,330 106 35 12,tab 50

  check "Global",130,95 121 30 8,tab 50
  check "Swearing",131,125 121 60 8,tab 50
  edit "",132,190 119 17 10,autohs hide
  button "setup",133,210 121 25 10,tab 50
  edit "",134,237 119 17 10,autohs hide
  button "setup",135,257 121 25 10,hide
  edit "",136,285 119 17 10,autohs,hide
  text "seconds",137,305 121 25 10,hide
  button "Actions",138,330 119 35 12,tab 50

  check "Global",140,95 140 30 8,tab 50
  check "Text Flood",141,125 140 60 8,tab 50
  edit "",142,190 138 17 10,autohs tab 50
  text "lines or",143,210 140 25 10,tab 50
  edit "",144,237 138 17 10,autohs tab 50
  text "bytes in",145,257 140 25 10,tab 50
  edit "",146,285 138 17 10,autohs tab 50
  text "seconds",147,305 140 25 10,tab 50
  button "Actions",148,330 138 35 12,tab 50

  check "Global",150,95 153 30 8,tab 50
  check "Notice Flood",151,125 153 60 8,tab 50
  edit "",152,190 151 17 10,autohs tab 50
  text "lines or",153,210 153 25 10,tab 50
  edit "",154,237 151 17 10,autohs tab 50
  text "bytes in",155,257 153 25 10,tab 50
  edit "",156,285 151 17 10,autohs tab 50
  text "seconds",157,305 153 25 10,tab 50
  button "Actions",158,330 151 35 12,tab 50

  tab "CTCP",200

  box "User",201,90 20 280 53,tab 200

  check "Global",210,95 30 30 8,tab 200
  check "CTCP Flood",211,125 30 60 8,tab 200
  edit "",212,190 28 17 10,autohs tab 200
  text "CTCPs in",213,210 30 25 10,tab 200
  edit "",214,237 28 17 10,autohs hide
  text "bytes in",215,257 30 25 10,hide
  edit "",216,285 28 17 10,autohs tab 200
  text "seconds",217,305 30 25 10,tab 200
  button "Actions",218,330 28 35 12,tab 200

  check "Global",220,95 44 30 8,tab 200
  check "'Non-standard' CTCPs",221,125 44 62 8,tab 200
  button "setup",222,210 44 25 10,tab 200
  button "Actions",223,330 42 35 12,tab 200

  check "Global",225,95 58 30 8,tab 200
  check "DCC's to channel",226,125 58 62 8,tab 200
  button "Actions",227,330 56 35 12,tab 200

  box "Botnet",229,90 80 280 25,tab 200

  check "Global",230,95 90 30 8,tab 200
  check "CTCP Flood",231,125 90 60 8,tab 200
  edit "",232,190 88 17 10,autohs tab 200
  text "CTCPs in",233,210 90 25 10,tab 200
  edit "",234,237 88 17 10,autohs hide
  text "bytes in",235,257 90 25 10,hide
  edit "",236,285 88 17 10,autohs tab 200
  text "seconds",237,305 90 25 10,tab 200
  button "Actions",238,330 88 35 12,tab 200

  box "Don't consider these CTCPs for flood Protection",239,90 110 280 25,tab 200
  check "Global",240,95 120 30 8,tab 200
  check "Enable",241,125 120 50 8,tab 200
  edit "",242,190 119 175 10,tab 200


  tab "Takeover",250

  box "User",251,90 20 280 50,tab 250

  check "Global",260,95 30 30 8,tab 250
  check "Mass Deop",261,125 30 60 8,tab 250
  edit "",262,190 28 17 10,autohs tab 250
  text "deops in",263,210 30 25 10,tab 250
  edit "",264,237 28 17 10,autohs hide
  text "bytes in",265,257 30 25 10,hide
  edit "",266,285 28 17 10,autohs tab 250
  text "seconds",267,305 30 25 10,tab 250
  button "Actions",268,330 28 35 12,tab 250

  check "Global",270,95 43 30 8,tab 250
  check "Mass Kick",271,125 43 60 8,tab 250
  edit "",272,190 41 17 10,autohs tab 250
  text "kicks in",273,210 43 25 10,tab 250
  edit "",274,237 41 17 10,autohs hide
  text "bytes in",275,257 43 25 10,hide
  edit "",276,285 41 17 10,autohs tab 250
  text "seconds",277,305 43 25 10,tab 250
  button "Actions",278,330 41 35 12,tab 250

  check "Global",280,95 56 30 8,tab 250
  check "Mass Ban",281,125 56 60 8,tab 250
  edit "",282,190 54 17 10,autohs tab 250
  text "bans or",283,210 56 25 10,tab 250
  edit "",284,237 54 17 10,autohs tab 250
  text "b/users in",285,257 56 25 10,tab 250
  edit "",286,285 54 17 10,autohs tab 250
  text "seconds",287,305 56 25 10,tab 250
  button "Actions",288,330 54 35 12,tab 250

  box "Dangerous Modes",290,90 75 280 50,tab 250

  check "Global",291,95 85 30 8,tab 250
  check "&Limit [+l] if limit is less or equal than",292,125 85 90 8,tab 250
  edit "",293,220 83 20 10,autohs tab 250
  button "Actions",294,330 83 35 12,tab 250
  check "Global",295,95 98 30 8,tab 250
  check "&Key [+k]",296,125 98 90 8,tab 250
  button "Actions",297,330 96 35 12,tab 250
  check "Global",298,95 111 30 8,tab 250
  check "&Invite only [+i]",299,125 111 90 8,tab 250
  button "Actions",300,330 109 35 12,tab 250

  box "Options",301,90 130 280 37,tab 250

  check "Global",302,95 140 30 8,tab 250
  check "Nethack",303,125 140 90 8,tab 250
  button "Actions",304,330 138 35 12,tab 250
  check "Global",305,95 153 30 8,tab 250
  check "BitchMode (strictops)",306,125 153 90 8,tab 250
  button "Actions",307,330 151 35 12,tab 250

  tab "Misc",320

  box "User",321,90 20 280 90,tab 320

  check "Global",330,95 30 30 8,tab 320
  check "Join/Part Flood",331,125 30 60 8,tab 320
  edit "",332,190 28 17 10,autohs tab 320
  text "joins/parts in",333,210 30 35 10,tab 320
  edit "",334,237 28 17 10,autohs hide
  text "bytes in",335,257 30 25 10,hide
  edit "",336,285 28 17 10,autohs tab 320
  text "seconds",337,305 30 25 10,tab 320
  button "Actions",338,330 28 35 12,tab 320

  check "Global",340,95 43 30 8,tab 320
  check "Nick flood",341,125 43 60 8,tab 320
  edit "",342,190 41 17 10,autohs tab 320
  text "nicks in",343,210 43 35 10,tab 320
  edit "",344,237 41 17 10,autohs hide
  text "bytes in",345,257 43 25 10,hide
  edit "",346,285 41 17 10,autohs tab 320
  text "seconds",347,305 43 25 10,tab 320
  button "Actions",348,330 41 35 12,tab 320

  check "Global",350,95 56 30 8,tab 320
  check "Mode/Topic flood",351,125 56 60 8,tab 320
  edit "",352,190 54 17 10,autohs tab 320
  text "modes/topics in",353,210 56 45 10,tab 320
  edit "",354,237 54 17 10,autohs hide
  text "codes in",355,257 56 25 10,hide
  edit "",356,285 54 17 10,autohs tab 320
  text "seconds",357,305 56 25 10,tab 320
  button "Actions",358,330 54 35 12,tab 320

  check "Global",360,95 69 30 8,tab 320
  check "Clone Protection - Max users per site:",361,125 69 100 8,tab 320
  edit "",362,230 67 20 10,autohs tab 320
  button "Actions",363,330 67 35 12,tab 320
  check "Global",364,95 82 30 8,tab 320
  check "Bad nick",365,125 82 60 8,tab 320
  button "setup",366,190 80 30 10,tab 320
  button "Actions",367,330 80 35 12,tab 320
  check "Global",368,95 95 30 8,tab 320
  check "Bad Identd",369,125 95 60 8,tab 320
  button "setup",370,190 93 30 10,tab 320
  button "Actions",371,330 93 35 12,tab 320

  box "Botnet",375,90 115 280 35,tab 320

  check "Global",380,95 125 30 8,tab 320
  check "Join/Part Flood",381,125 125 60 8,tab 320
  edit "",382,190 123 17 10,autohs tab 320
  text "joins/parts in",383,210 125 35 10,tab 320
  edit "",384,237 123 17 10,autohs hide
  text "bytes in",385,257 125 25 10,hide
  edit "",386,285 123 17 10,autohs tab 320
  text "seconds",387,305 125 25 10,tab 320
  button "Actions",388,330 123 35 12,tab 320

  check "Global",390,95 138 30 8,tab 320
  check "Nick Flood",391,125 138 60 8,tab 320
  edit "",392,190 136 17 10,autohs tab 320
  text "nicks in",393,210 138 35 10,tab 320
  edit "",394,237 136 17 10,autohs hide
  text "bytes in",395,257 138 25 10,hide
  edit "",396,285 136 17 10,autohs tab 320
  text "seconds",397,305 138 25 10,tab 320
  button "Actions",398,330 136 35 12,tab 320

  tab "Options",400

  box "Exempt from Text/CTCP/Misc Protection",401,90 20 280 38,tab 400
  box "Options",402,90 60 280 50,tab 400

  check "Global",403,95 30 30 8,tab 400
  check "&Ops @",404,125 30 100 8,tab 400
  check "Global",405,95 43 30 8,tab 400
  check "&Voiced +",406,125 43 100 8,tab 400

  check "Global",410,95 70 30 8,tab 400
  check "Deop Revenge",411,125 70 50 8,tab 400
  button "Actions",412,330 68 35 12,tab 400
  check "Global",413,95 83 30 8,tab 400
  check "Kick Revenge",414,125 83 50 8,tab 400
  button "Actions",415,330 81 35 12,tab 400
  check "Global",416,95 96 30 8,tab 400
  check "Enforce Bans",417,125 96 50 8,tab 400

  box "Actions (using bots) to take when you are..",419,90 115 280 50,tab 400

  check "Global",420,95 125 30 8,tab 400
  check "Deopped >",421,125 125 35 8,tab 400
  check "deop",422,165 125 25 8,tab 400
  check "kick",423,195 125 25 8,tab 400
  check "ban",424,225 125 25 8,tab 400
  check "reop self",425,255 125 37 8,tab 400
  check "",426,295 138 40 8,hide
  check "Global",430,95 138 30 8,tab 400
  check "Kicked    >",431,125 138 35 8,tab 400
  check "deop",432,165 138 25 8,tab 400
  check "kick",433,195 138 25 8,tab 400
  check "ban",434,225 138 25 8,tab 400
  check "unban self",435,255 138 37 8,tab 400
  check "invite self",436,295 138 42 8,tab 400
  check "Global",440,95 151 30 8,tab 400
  check "Banned   >",441,125 151 37 8,tab 400
  check "deop",442,165 151 25 8,tab 400
  check "kick",443,195 151 25 8,tab 400
  check "ban",444,225 151 25 8,tab 400
  check "unban self",445,255 151 42 8,tab 400
  check "",446,295 138 40 8,hide

  text "Presets:",450,90 183 25 10
  combo 451,115 181 50 100,drop
  button "All ON",452,170 178 25 14
  button "All OFF",453,200 178 25 14
  button "All Global",454,230 178 28 14

  list 461,999 999 999 999,hide
  list 462,999 999 999 999,hide
  list 463,999 999 999 999,hide
  list 464,999 999 999 999,hide
  list 465,999 999 999 999,hide
  list 466,999 999 999 999,hide
  list 467,999 999 999 999,hide
  list 468,999 999 999 999,hide
  list 469,999 999 999 999,hide
  list 470,999 999 999 999,hide
  list 471,999 999 999 999,hide
  list 472,999 999 999 999,hide
  list 473,999 999 999 999,hide

  button "Ok",490,275 178 30 15,ok
  button "Cancel",491,310 178 30 15,cancel
  button "Help",492,345 178 30 15

  box "",499,5 20 75 175
  box "",500,85 171 187 25
}
;;
;
; /_cprot.refresh <#channel|$null> <add channel> <load channels> <using preset?>
;
alias -l _cprot.refresh {
  var %ids,%d = cprot,%h = _aircprot,%cs = $sorttok($hget(%h,channels),32),%c,%i = 1,%n = $numtok(%cs,32),%ppp = 1,%z
  if ($dialog(%d) == $null) { return }
  if ($3) {
    did -r %d 2
    did -ac %d 2 --Global--
    __cprot.refresh.readfile 1
    while (%i <= %n) {
      %c = $gettok(%cs,%i,32)
      did $iif(%c == $1,-ac,-a) %d 2 %c
      __cprot.refresh.readfile $did(%d,2).lines %c
      inc %i
    }
  }
  if ($_ischan($1)) && ($2) {
    var %i = 2,%n = $did(%d,2).lines
    while (%i <= %n) {
      if ($did(%d,2,%i) == $1) {
        %ppp = 0
        break
      }
      inc %i
    }
    if (%ppp) {
      did -ac %d 2 $1
      %z = 461
      while (%z <= 473) {
        did -o %d %z $did(%d,2).sel $replace($right($str(_$null,$numtok($did(%d,%z,1),32)),-1),_,$chr(32))
        inc %z
      }
    }
  }
  .timerCPROTDEVENTENABLE off
  %ids = 60,70,80,90,100,110,120,130,140,150,210,220,225,230,240,260,270,280,291,295,298,302,305,330,340,350,360,364,368,380,390,403,405,410,413,416,420,430,440
  .timerCPROTDEVENTENABLE -mo 1 0 __cprot.refresh.timertemp %ids
  did $iif($did(%d,2).sel == 1,-b,-e) %d 4,454
  var %i = 1,%n = $numtok(%ids,44),%l = $did(%d,2).sel,%ng,%og = 0,%gid,%num
  if ($did(%d,2).sel == $null) { did -c %d 2 1 }
  %l = $did(%d,2).sel
  while (%i <= %n) {
    inc %gid
    %num = $gettok(%ids,%i,44)
    if (%num isnum 60-138) { %ng = 461 }
    elseif (%num isnum 140-158) { %ng = 462 }
    elseif (%num isnum 210-227) { %ng = 463 }
    elseif (%num isnum 230-238) { %ng = 464 }
    elseif (%num isnum 260-288) { %ng = 465 }
    elseif (%num isnum 291-300) { %ng = 466 }
    elseif (%num isnum 302-307) { %ng = 467 }
    elseif (%num isnum 330-371) { %ng = 468 }
    elseif (%num isnum 380-398) { %ng = 469 }
    elseif (%num isnum 403-406) { %ng = 470 }
    elseif (%num isnum 410-417) { %ng = 471 }
    elseif (%num isnum 420-440) { %ng = 472 }
    elseif (%num isnum 240-242) { %ng = 473 }
    if (%ng != %og) {
      %og = %ng
      %gid = 1
    }
    __cprot.refresh %l %num %ng %gid
    inc %i
  }
  if ($_not($4)) { did -u %d 451 }
  did -ev %d 52
}
alias -l __cprot.refresh.timertemp {
  var %d = cprot
  if ($dialog(%d) == $null) { return }
  did $iif($did(%d,2).sel == 1,-b,-e) %d $1-
  did $iif($did(%d,2).sel == 1,-h,-v) %d $1-
}
alias -l __cprot.refresh.readfile {
  var %d = cprot,%h = _aircprot
  if ($2 == $null) { var %rc = $hget(%h,chan_global),%rb = $hget(%h,botnet_global),%cunoconsctcp = $hget(%h,cunoconsctcp_global) }
  else { var %rc = $hget(%h,chan_ [ $+ [ $2 ] ] ),%rb = $hget(%h,botnet_ [ $+ [ $2 ] ] ),%cunoconsctcp = $hget(%h,cunoconsctcp_ [ $+ [ $2 ] ] ) }
  did -o %d 461 $1 $gettok(%rc,1-8,32)
  did -o %d 462 $1 $gettok(%rb,1-2,32)
  did -o %d 463 $1 $gettok(%rc,9-11,32)
  did -o %d 464 $1 $gettok(%rb,3,32)
  did -o %d 465 $1 $gettok(%rc,12-14,32)
  did -o %d 466 $1 $gettok(%rc,15-17,32)
  did -o %d 467 $1 $gettok(%rc,18-19,32)
  did -o %d 468 $1 $gettok(%rc,20-25,32)
  did -o %d 469 $1 $gettok(%rb,4-5,32)
  did -o %d 470 $1 $gettok(%rc,26-27,32)
  did -o %d 471 $1 $gettok(%rc,28-30,32)
  did -o %d 472 $1 $gettok(%rc,31-33,32)
  did -o %d 473 $1 $gettok(%rc,34,32) $+ . $+ $replace(%cunoconsctcp,$chr(32),$chr(1))
}
alias -l __cprot.refresh {
  ; $1 - línea del canal (1 = global)
  ; $2 - id base (del global ? )
  ; $3 - grupo 46?
  ; $4 - token del grupo
  var %d = cprot,%t,%y = $_cprot.ids($2),%i = 1,%n = $numtok(%y,32),%did,%type,%tmp,%enabledisable = e
  if ($gettok($did(%d,$3,$1),$4,32) != $null) {
    did -u %d $2
    %t = $ifmatch
  }
  else {
    %t = $gettok($did(%d,$3,1),$4,32)
    if ($1 != 1) {
      did -c %d $2
      %enabledisable = b
    }
  }
  if ($gettok(%t,1,46) == -) { %t = $puttok(%t,$did(%d,$calc($2 + $gettok($gettok(%y,1,32),1,46))).state,1,46) }
  while (%i <= %n) {
    var %tmp = $gettok(%t,%i,46),%did = $calc($2 + $gettok($gettok(%y,%i,32),1,46)),%type = $gettok($gettok(%y,%i,32),2,46)
    if (%i == 2) && (%enabledisable == e) {
      if ($_not($gettok(%t,1,46))) { %enabledisable = b }
    }
    if (%type == text) {
      %tmp = $round(%tmp,0)
      if (%tmp isnum) && (%tmp >= 0) { did -o $+ %enabledisable %d %did 1 %tmp }
      else { did -o $+ %enabledisable %d %did 1 0 }
    }
    elseif (%type == state) { did $iif(%tmp,-c,-u) $+ %enabledisable %d %did }
    elseif (%type == string) {
      var %zzz = $calc(%i + 1) $+ -
      did -o $+ %enabledisable %d %did 1 $replace(%tmp,$chr(1),$chr(32))
    }
    inc %i
  }
}
alias -l _cprot.savebuf {
  var %d = cprot,%l,%i,%t,%r
  if ($dialog(%d) == $null) { return }
  %l = $did(%d,2).sel
  if (%l == $null) { return }
  if ($1 == *) || ($1 isnum 60-138) { did -o %d 461 %l $__cprot.savebuf(60,70,80,90,100,110,120,130) }
  if ($1 == *) || ($1 isnum 140-158) { did -o %d 462 %l $__cprot.savebuf(140,150) }
  if ($1 == *) || ($1 isnum 210-227) { did -o %d 463 %l $__cprot.savebuf(210,220,225) }
  if ($1 == *) || ($1 isnum 230-238) { did -o %d 464 %l $__cprot.savebuf(230) }
  if ($1 == *) || ($1 isnum 260-288) { did -o %d 465 %l $__cprot.savebuf(260,270,280) }
  if ($1 == *) || ($1 isnum 291-300) { did -o %d 466 %l $__cprot.savebuf(291,295,298) }
  if ($1 == *) || ($1 isnum 302-307) { did -o %d 467 %l $__cprot.savebuf(302,305) }
  if ($1 == *) || ($1 isnum 330-371) { did -o %d 468 %l $__cprot.savebuf(330,340,350,360,364,368) }
  if ($1 == *) || ($1 isnum 380-398) { did -o %d 469 %l $__cprot.savebuf(380,390) }
  if ($1 == *) || ($1 isnum 403-409) { did -o %d 470 %l $__cprot.savebuf(403,405) }
  if ($1 == *) || ($1 isnum 410-417) { did -o %d 471 %l $__cprot.savebuf(410,413,416) }
  if ($1 == *) || ($1 isnum 420-446) { did -o %d 472 %l $__cprot.savebuf(420,430,440) }
  if ($1 == *) || ($1 isnum 240-242) { did -o %d 473 %l $__cprot.savebuf(240) }
}
alias -l _cprot.ids {
  if ($istok(60 70 80 140 150 280,$1,32)) { return 1.state 2.text 4.text 6.text }
  if ($istok(90 100 110 210 230 260 270 330 340 350 380 390,$1,32)) { return 1.state 2.text 4.text 6.text }
  if ($istok(120 130 220 225 295 298 302 305 364 368 403 405 410 413 416,$1,32)) { return 1.state }
  if ($istok(291 360,$1,32)) { return 1.state 2.text }
  if ($istok(420 430 440,$1,32)) { return 1.state 2.state 3.state 4.state 5.state 6.state }
  if ($istok(240,$1,32)) { return 1.state 2.string }
}
alias -l __cprot.savebuf {
  tokenize 32 $replace($1-,$chr(44),$chr(32))
  var %i = 1,%n = $0,%t,%r = :
  while (%i <= %n) {
    %t = $__cprot.savebuf.section($gettok($1-,%i,32))
    %r = %r $iif(%t != $null,%t,$null)
    inc %i
  }
  %r = $gettok(%r,2-,32)
  return %r
}
alias -l __cprot.savebuf.section {
  var %d = cprot,%i = 1,%ids = $_cprot.ids($1),%n = $numtok(%ids,32),%did,%type,%r,%t,%enabledisable = -e
  if ($dialog(%d) == $null) { return }
  if ($did(%d,$1).state) && ($did(%d,2).sel > 1) { %enabledisable = -b }
  while (%i <= %n) {
    var %did = $calc($1 + $gettok($gettok(%ids,%i,32),1,46)),%type = $gettok($gettok(%ids,%i,32),2,46)
    if (%type == text) {
      %t = $round($did(%d,%did).text,0)
      if (%t isnum) && (%t >= 0) { %r = %r $+ . $+ %t }
      else { %r = %r $+ . $+ 0 }
    }
    elseif (%type == state) { %r = %r $+ . $+ $did(%d,%did).state }
    elseif (%type = string) { %r = %r $+ . $+ $replace($did(%d,%did).text,$chr(32),$chr(1)) }
    if (%did == $calc($1 + 2)) {
      %enabledisable = -e
      if ($did(%d,$1).state) && ($did(%d,2).sel > 1) { %enabledisable = -b }
      elseif ($_not($did(%d,$calc($1 + 1)).state)) { %enabledisable = -b }
    }
    did %enabledisable %d %did
    inc %i
  }
  if ($did(%d,$1).state) && ($did(%d,2).sel != 1) { return $null }
  if (.* iswm %r) { %r = $right(%r,-1) }
  return %r
}
alias -l _cprot.devent.ok {
  _prot.init
  _prot.init _aircprotbak
  var %d = cprot,%h = _aircprot,%hbak = _aircprotbak,%wcn,%wbn,%ppprot = $hget(%h,personal),%pbprot = $hget(%h,personalbotnet),%i = 1,%n = $did(%d,2).lines,%cs,%c,%result,%w,%t1,%t2
  _hmake %h 50
  while (%i <= %n) {
    if (%i > 1) { var %c = $did(%d,2,%i),%w = _wchini %c,%cs = $addtok(%cs,%c,32) }
    else { var %c = global,%w = _wchini default }
    _hadd %h chan_ $+ %c $did(%d,461,%i) $did(%d,463,%i) $did(%d,465,%i) $did(%d,466,%i) $did(%d,467,%i) $did(%d,468,%i) $did(%d,470,%i) $did(%d,471,%i) $did(%d,472,%i) $gettok($did(%d,473,%i),1,46)
    _hadd %h botnet_ $+ %c $did(%d,462,%i) $did(%d,464,%i) $did(%d,469,%i)
    _hadd %h cuadvert_ $+ %c $hget(%hbak,cuadvert_ [ $+ [ %c ] ] )
    _hadd %h cubadnick_ $+ %c $hget(%hbak,cubadnick_ [ $+ [ %c ] ] )
    _hadd %h cubadident_ $+ %c $hget(%hbak,cubadident_ [ $+ [ %c ] ] )
    _hadd %h cunsctcp_ $+ %c $hget(%hbak,cunsctcp_ [ $+ [ %c ] ] )
    _hadd %h cuswear_ $+ %c $hget(%hbak,cuswear_ [ $+ [ %c ] ] )
    _hadd %h cunoconsctcp_ $+ %c $replace($gettok($did(%d,473,%i),2-,46),$chr(1),$chr(32))
    %result = $hget(%h,chan_ [ $+ [ %c ] ] )
    %w enforcebans $gettok($gettok(%result,30,32),1,46)
    %w bitch $gettok($gettok(%result,19,32),1,46)
    %w stopnethack $gettok($gettok(%result,18,32),1,46)
    %t1 = $gettok($gettok(%result,28,32),1,46)
    %t2 = $gettok($gettok(%result,29,32),1,46)
    if (%t1 == $null) && (%t2 == $null) { %w revengebot }
    elseif (%t1) || (%t2) { %w revengebot 1 }
    else { %w revengebot 0 }
    inc %i
  }
  hfree %hbak
  _hadd %h channels %cs
  _hadd %h personal %ppprot
  _hadd %h personalbotnet %pbprot
  _prot.save
}
alias -l _cprot.devent.addchan {
  var %d = cprot,%cs = $_mychans,%i = $numtok(%cs,32),%win = @__cprotdeventaddchan,%c,%csr
  if ($dialog(%d) == $null) { return }
  _openwins %win
  _dialog2win %d 2 %win *
  while (%i) {
    %c = $gettok(%cs,%i,32)
    if ($fline(%win,%c,0) == 0) { %csr = $addtok(%csr,%c,32) }
    dec %i
  }
  close -@ %win
  tokenize 32 $_selectedit($null,1,Channel Protection [/cprot],ischan,$gettok(%csr,1,32),32,%csr,Channel:)
  if ($dialog(%d) == $null) { return }
  _cprot.refresh $1 1 0 0
}
alias -l _cprot.devent.preset {
  var %d = cprot,%l,%rc,%rb
  if ($dialog(%d) == $null) { return }
  %l = $did(%d,2).sel
  did -u %d %n1 60,70,80,90,100,110,120,130,140,150,210,220,225,230,260,270,280,291,295,298,302,305,330,340,350,360,364,368,380,390,403,405,410,413,416,420,430,440
  _cprot.savebuf *
  if ($1 == 1) {
    %rc = -.12.1200.8 -.6.600.15 -.60.180.8 -.80.0.40 -.100.0.20 -.6.0.60 - - -.4.0.8 - - -.5.0.8 -.5.0.8 -.5.10.8 -.1 - - - - -.6.0.8 -.5.0.8 -.6.0.8 -.3 - - - - - - - -.$null
    %rb = -.36.3600.8 -.18.1800.15 -.8.0.8 -.18.0.8 -.15.0.8
  }
  if ($1 == 2) {
    %rc = -.10.1000.10 -.5.500.20 -.40.120.10 -.60.0.30 -.80.0.15 -.4.0.120 - - -.3.0.10 - - -.4.0.10 -.4.0.10 -.4.8.10 -.1 - - - - -.5.0.10 -.4.0.10 -.5.0.10 -.3 - - - - - - - -.$null
    %rb = -.30.3000.10 -.15.1500.20 -.6.0.10 -.15.0.10 -.12.0.10
  }
  if ($1 == 3) {
    %rc = -.8.800.12 -.4.400.25 -.20.60.12 -.40.0.20 -.60.0.10 -.2.0.180 - - -.2.0.12 - - -.3.0.12 -.3.0.12 -.3.6.12 -.1 - - - - -.4.0.12 -.3.0.12 -.4.0.12 -.3 - - - - - - - -.$null
    %rb = -.24.2400.12 -.12.1200.25 -.4.0.12 -.12.0.12 -.9.0.12
  }
  did -o %d 461 %l $gettok(%rc,1-8,32)
  did -o %d 462 %l $gettok(%rb,1-2,32)
  did -o %d 463 %l $gettok(%rc,9-11,32)
  did -o %d 464 %l $gettok(%rb,3,32)
  did -o %d 465 %l $gettok(%rc,12-14,32)
  did -o %d 466 %l $gettok(%rc,15-17,32)
  did -o %d 467 %l $gettok(%rc,18-19,32)
  did -o %d 468 %l $gettok(%rc,20-25,32)
  did -o %d 469 %l $gettok(%rb,4-5,32)
  did -o %d 470 %l $gettok(%rc,26-27,32)
  did -o %d 471 %l $gettok(%rc,28-30,32)
  ;  did -o %d 472 %l $gettok(%rc,31-33,32)
  _cprot.refresh $null 0 0 1
  _cprot.savebuf *
}
ON *:DIALOG:cprot:*:*:{
  if ($devent == init) {
    _mdx.init $_icofile(cprot.ico)
    did -r $dname 451
    did -a $dname 451 Permissive
    did -a $dname 451 Normal
    did -a $dname 451 Strict
    _dummy $_lang.loaddialog($dname,_cprot,00086969,main.lang,$scriptdir)
  }
  if ($devent == sclick) {
    var %channel
    if ($did(2).sel > 1) { %channel = $did(2,$ifmatch) }
    if ($did == 2) { _cprot.refresh $null 0 0 0 }
    elseif ($did == 3) { _cprot.devent.addchan }
    elseif ($did == 4) {
      if ($did(2).sel > 1) {
        var %l = $ifmatch
        did -d $dname 2,461,462,463,464,465,466,467,468,469,470,471,472,473 $ifmatch
        did -c $dname 2 $iif(%l <= $did(2).lines,%l,$calc(%l - 1))
        _cprot.refresh $null 0 0 0
      }
    }
    elseif ($istok(50 200 250 320 400,$did,32)) { _cprot.refresh $null 0 0 0 }
    elseif ($did == 451) { _cprot.devent.preset $did(451).sel }
    elseif ($did isnum 452-454) {
      var %n1,%n2
      %n1 = 60,70,80,90,100,110,120,130,140,150,210,220,225,230,260,270,280,291,295,298,302,305,330,340,350,360,364,368,380,390,403,405,410,413,416,420,430,440
      if ($did == 454) { did -c $dname %n1 }
      else {
        did -u $dname %n1
        if ($did == 452) { did -c $dname 61,71,81,91,101,111,121,131,141,151,211,221,226,231,261,271,281,331,341,351,361,365,369,381,391,411,414,417 }
        elseif ($did == 453) { did -u $dname 61,71,81,91,101,111,121,131,141,151,211,221,226,231,261,271,281,292,296,299,303,306,331,341,351,361,365,369,381,391,411,414,417,421,431,441 }
      }
      _cprot.savebuf *
      _cprot.refresh $null 0 0 0
    }
    elseif ($did == 490) {
      _cprot.devent.ok
      _unloadcprotsetupmrc
    }
    elseif ($did == 491) { _unloadcprotsetupmrc }

    elseif ($did == 123) { _protlist.load cuadvert %channel }
    elseif ($did == 133) { _protlist.load cuswear %channel }
    elseif ($did == 222) { _protlist.load cunsctcp %channel }
    elseif ($did == 366) { _protlist.load cubadnick %channel }
    elseif ($did == 370) { _protlist.load cubadident %channel }

    elseif ($did == 68) { _protaction 1 0 0 cutext %channel }
    elseif ($did == 78) { _protaction 1 0 0 cunotice %channel }
    elseif ($did == 88) { _protaction 1 0 0 cucolour %channel }
    elseif ($did == 98) { _protaction 1 0 0 cuascii %channel }
    elseif ($did == 108) { _protaction 1 0 0 cucaps %channel }
    elseif ($did == 118) { _protaction 1 0 0 curepeat %channel }
    elseif ($did == 128) { _protaction 1 0 0 cuadvert %channel }
    elseif ($did == 138) { _protaction 1 0 0 cuswear %channel }
    elseif ($did == 148) { _protaction 1 0 1 cbtext %channel }
    elseif ($did == 158) { _protaction 1 0 1 cbnotice %channel }
    elseif ($did == 218) { _protaction 1 0 0 cuctcp %channel }
    elseif ($did == 223) { _protaction 1 0 0 cunsctcp %channel }
    elseif ($did == 227) { _protaction 1 0 0 cudccctcp %channel }
    elseif ($did == 238) { _protaction 1 0 1 cbctcp %channel }
    elseif ($did == 268) { _protaction 1 0 0 cumdeop %channel }
    elseif ($did == 278) { _protaction 1 0 0 cumkick %channel }
    elseif ($did == 288) { _protaction 1 0 0 cumban %channel }
    elseif ($did == 294) { _protaction 1 0 0 cudmodel %channel }
    elseif ($did == 297) { _protaction 1 0 0 cudmodek %channel }
    elseif ($did == 300) { _protaction 1 0 0 cudmodei %channel }
    elseif ($did == 304) { _protaction 1 0 0 cunethack %channel }
    elseif ($did == 307) { _protaction 1 0 0 cubitchmode %channel }
    elseif ($did == 338) { _protaction 1 0 0 cujoinpart %channel }
    elseif ($did == 348) { _protaction 1 0 0 cunick %channel }
    elseif ($did == 358) { _protaction 1 0 0 cumodetopic %channel }
    elseif ($did == 363) { _protaction 1 0 0 cuclones %channel }
    elseif ($did == 367) { _protaction 1 0 0 cubadnick %channel }
    elseif ($did == 371) { _protaction 1 0 0 cubadident %channel }
    elseif ($did == 388) { _protaction 1 0 1 cbjoinpart %channel }
    elseif ($did == 398) { _protaction 1 0 1 cbnick %channel }
    elseif ($did == 412) { _protaction 1 0 0 cudeoprevenge %channel }
    elseif ($did == 415) { _protaction 1 0 0 cukickrevenge %channel }

  }
  _cprot.savebuf $did
}
;
;;
;
; $_protlist(setting,token,dialog title,add/edit text,parm type,[channel])
;
alias -l _protlist {
  var %c,%h = _aircprot,%tmp = $1 $+ _global,%g = $hget(%h,%tmp),%d = _protlist,%i,%z = $6
  _dialog -am %d _simplelist
  dialog -t %d $3 $iif(%z,$^sbp(%z))
  did -h %d 1
  did -o %d 250 1 $1
  did -o %d 250 2 $2
  did -o %d 250 3 $3
  did -o %d 250 4 $4
  did -o %d 250 5 $5
  did -o %d 250 6 $6
  did -r %d 2,4
  did -u %d 220
  did -o %d 220 1 Use global settings
  did -o %d 102 1 &Edit
  did -ov %d 103 1 &Delete
  if ($6) {
    %tmp = $1 $+ _ $+ $6
    %c = $hget(%h,%tmp)
    did -ev %d 220
  }
  else { did -bh %d 220 }
  did $iif(%c,-h,-v) %d 2
  did $iif(%c,-v,-h) %d 4
  did $iif(%c,-u,-c) %d 220
  %i = $numtok(%g,$2)
  while (%i) {
    did -a %d 2 $gettok(%g,%i,$2)
    dec %i
  }
  if (%c != $null) {
    %i = $numtok(%c,$2)
    while (%i) {
      did -a %d 4 $gettok(%c,%i,$2)
      dec %i
    }
  }
  _protlist.refresh
}
;
;;
;
; /_protlist.load <cuadvert|cuswear|cunsctcp|cubadnick|cubadident> [channel]
;
alias -l _protlist.load {
  var %g = $1
  goto %g
  :cuadvert | return $_protlist(cuadvert,254,Advertising Protection,add/edit text,normal,$2)
  :cuswear | return $_protlist(cuswear,254,Swearing Protection,add/edit text,normal,$2)
  :cunsctcp | return $_protlist(cunsctcp,44,Non Standard CTCPs Protection,add/edit text,1,$2)
  :cubadnick | return $_protlist(cubadnick,44,Bad Nick Protection,add/edit text,1,$2)
  :cubadident | return $_protlist(cubadident,44,Bad Nick Identd Protection,add/edit text,1,$2)
  :%g
}
ON *:DIALOG:_protlist:init:0:{ _mdx.init $_icofile(pprot.ico) }
ON *:DIALOG:_protlist:sclick:101:{ _protlist.add }
ON *:DIALOG:_protlist:sclick:102:{ _protlist.edit }
ON *:DIALOG:_protlist:dclick:2:{ _protlist.edit }
ON *:DIALOG:_protlist:dclick:4:{ _protlist.edit }
ON *:DIALOG:_protlist:sclick:103:{ _dialog.delsel $dname $iif($did(2).visible,2,4) }
ON *:DIALOG:_protlist:sclick:220:{ _protlist.refresh }
ON *:DIALOG:_protlist:sclick:201:{
  _prot.init
  var %t = $did(250,1),%c = $did(250,6),%h = _aircprot
  if (%c == $null) { _hadd %h %t $+ _global $left($didtok($dname,2,$did(250,2)),930) }
  elseif ($did(2).visible) { _hadd %h %t $+ _ $+ %c }
  elseif ($didtok($dname,4,$did(250,2)) != $null) { _hadd %h %t $+ _ $+ %c $left($ifmatch,930) }
  else { _hadd %h %t $+ _ $+ %c $chr($did(250,2)) }
  _prot.save
  _unloadcprotsetupmrc
}
ON *:DIALOG:_protlist:sclick:202:{ _unloadcprotsetupmrc }
alias -l _protlist.add {
  var %d = _protlist,%setting,%token,%text,%parm,%did
  if ($dialog(%d) == $null) { return }
  var %setting = $did(%d,250,1),%token = $did(%d,250,2),%text = $did(%d,250,4),%did = $iif($did(%d,2).visible,2,4)
  %parm = $remove($_parameter($null,1,$dialog(%d).title,$did(%d,250,5),$null,%text),$chr($did(%d,250,2)))
  if (%parm != $null) { _dialog.add %d %did %parm }
}
alias -l _protlist.edit {
  var %d = _protlist,%setting,%token,%text,%parm,%did,%sel
  if ($dialog(%d) == $null) { return }
  var %setting = $did(%d,250,1),%token = $did(%d,250,2),%text = $did(%d,250,4),%did = $iif($did(%d,2).visible,2,4),%sel
  if ($did(%d,%did).sel == $null) { return }
  %sel = $did(%d,%did,$did(%d,%did).sel)
  %parm = $remove($_parameter($null,1,$dialog(%d).title,$did(%d,250,5),%sel,%text),$chr($did(%d,250,2)))
  if (%parm != $null) && (%parm != %sel) {
    did -d %d %did $did(%d,%did).sel
    _dialog.add %d %did %parm
  }
}
alias -l _protlist.refresh {
  var %d = _protlist
  if ($did(%d,250,6)) {
    did $iif($did(%d,220).state,-b,-e) %d 2,4,101,102,103
    did $iif($did(%d,220).state,-v,-h) %d 2
    did $iif($did(%d,220).state,-h,-v) %d 4
  }
  else {
    did -e %d 2,4,101,102,103
    did -v %d 2
    did -h %d 4
  }
}


;;;;;;
;;;;;

alias -l _unloadcprotsetupmrc { _quickunload cprot,_protlist $script }