;=================== dialog protection ==================
alias protection {
  dialog -m protection protection
  if ($dialog(protection) != $null) {
    set %stemp 2
    :start
    inc %stemp 2
    dialog -s protection $dialog(protection).x $dialog(protection).y %stemp 260
    if (%stemp >= 274) { goto done }
    goto start 
    :done
  }
}
dialog protection {
  title "MetalX Portection"
  size 240 140 138 130
  option dbu
  tab "ป้องกันห้อง", 99, 1 1 135 117
  box , 30, 3 14 131 103, tab 99
  check "โฆษณาห้อง", 31, 9 22 40 10, tab 99
  check พิมพ์ ข้อความ, 32, 9 35 41 10, tab 99
  check "พิมพ์ notice", 35, 9 48 40 10, tab 99
  check "พิมพ์ action", 36, 9 61 40 10, tab 99
  check คำหยาบ, 33, 9 87 40 10, tab 99
  check โคลน, 37, 9 100 27 10, tab 99
  check "พิมพ์ ข้อความ ซ้ำ", 38, 71 22 50 10, tab 99
  check "พิมพ์ notice ซ้ำ", 39, 71 35 50 10, tab 99
  check "พิมพ์ action ซ้ำ", 40, 71 48 50 10, tab 99
  check "เตะ ข้อความสี", 41, 71 61 50 10, tab 99
  check เตะ invite, 42, 71 74 50 10, tab 99
  check โฆษณา Web, 70, 71 87 50 10, tab 99
  check Sound, 47, 71 100 38 10, tab 99
  check พิมพ์ longtext, 53, 9 74 41 10, tab 99
  tab "ป้องกันตัวเอง", 50
  check ข้อความ, 3, 9 25 28 10, tab 50
  edit "", 4, 44 25 20 10, tab 50
  text บันทัด, 5, 68 25 15 10, tab 50
  edit , 6, 87 25 20 10, tab 50
  text "วินาที", 7, 109 25 15 10, tab 50
  check notice, 8, 9 40 28 10, tab 50
  edit "", 9, 44 40 20 10, tab 50
  text บันทัด, 10, 68 40 15 10, tab 50
  edit , 11, 87 40 20 10, tab 50
  text "วินาที", 12, 109 40 15 10, tab 50
  check action, 13, 9 55 28 10, tab 50
  edit , 14, 44 55 20 10, tab 50
  text "บันทัด", 15, 68 55 15 10, tab 50
  edit , 16, 87 55 20 10, tab 50
  text วินาที, 17, 109 55 15 10, tab 50
  check ซิบฟลัด, 18, 9 70 27 10, tab 50
  edit , 19, 44 70 20 10, tab 50
  text "เวลา", 20, 68 70 15 10, tab 50
  edit "", 21, 87 70 20 10, tab 50
  text "วินาที", 22, 109 70 15 10, tab 50
  check "ซิบโฆษณา", 23, 9 98 36 10, tab 50
  check "ป้องกันแบน", 34, 87 98 40 9, tab 50
  box , 51, 3 13 131 75, tab 50
  box , 52, 3 86 131 31, tab 50
  check "Version", 44, 50 98 34 9, tab 50
  tab "ส่วนเพิ่มเติม", 90
  box , 25, 3 14 131 44, tab 90
  box , 98, 3 56 131 61, tab 90
  text "รูปแบบการแบน", 26, 10 24 40 9, tab 90
  combo 24, 53 22 79 97, tab 90 edit drop
  text "ระยะเวลาที่แบน", 27, 10 42 40 10, tab 90
  edit , 28, 53 41 24 10, tab 90
  text วินาที, 29, 79 42 17 8, tab 90
  check เตะ แบน, 43, 10 91 38 10, tab 90
  check ส่งคิล bugpirch, 45, 10 105 45 10, tab 90
  button "menu text", 140, 96 68 35 10, tab 90 flat
  button badident, 49, 96 92 35 10, tab 90 flat
  button badword, 77, 96 80 35 10, tab 90 flat
  button "blacklist", 48, 96 104 35 10, tab 90 flat
  check "เตะคนมี +", 46, 10 77 38 10, tab 90
  check "kick bug", 2, 10 64 38 10, tab 90
  button DONE!!, 1, 1 120 136 10, flat ok
}
on *:dialog:protection:*:*:{
  if ($devent == init) {
    .did -ra protection 4 %metextline
    .did -ra protection 6 %metexttime
    .did -ra protection 9 %menotline
    .did -ra protection 11 %menottime
    .did -ra protection 14 %meactline
    .did -ra protection 16 %meacttime
    .did -ra protection 19 %mezipline
    .did -ra protection 21 %meziptime
    .did -ra protection 28 %bantimeadd
    if (%banlevel = 0 ) { .did -ac protection 24 *!user@host.domain }
    else .did -a protection 24 *!user@host.domain
    if (%banlevel = 1 ) { .did -ac protection 24 *!*user@host.domain }
    else  .did -a protection 24 *!*user@host.domain
    if (%banlevel = 2 ) { .did -ac protection 24 *!*@host.domain }
    else .did -a protection 24 *!*@host.domain
    if (%banlevel = 3 ) { .did -ac protection 24 *!*user@*.domain }
    else .did -a protection 24 *!*user@*.domain
    if (%banlevel = 4 ) { .did -ac protection 24 *!*@*.domain }
    else .did -a protection 24 *!*@*.domain
    if (%banlevel = 5 ) { .did -ac protection 24 nick!user@host.domain }
    else .did -a protection 24 nick!user@host.domain
    if (%banlevel = 6 ) { .did -ac protection 24 nick!*user@host.domain }
    else .did -a protection 24 nick!*user@host.domain
    if (%banlevel = 7 ) { .did -ac protection 24 nick!*@host.domain }
    else .did -a protection 24 nick!*@host.domain
    if (%banlevel = 8 ) { .did -ac protection 24 nick!*user@*.domain }
    else .did -a protection 24 nick!*user@*.domain
    if (%banlevel = 9 ) { .did -ac protection 24 nick!*@*.domain }
    else .did -a protection 24 nick!*@*.domain
    if (%kickban == เปิด) { did -c protection 43 }
    if (%kickvop == เปิด) { did -c protection 46 }
    if (%pingme == เปิด) { did -c protection 44 }
    if (%kickctcp == เปิด) { did -c protection 47 }
    if (%ป้องกันโฆณา == เปิด) { did -c protection 23 }
    if (%ซิบฟลัด == เปิด) { did -c protection 18 }
    if ($group(#bug).status == on) { did -c protection 2 }
    if ($group(#metext).status == on) { did -c protection 3 }
    if ($group(#menotice).status == on) { did -c protection 8 }
    if ($group(#meaction).status == on) { did -c protection 13 }
    if ($group(#advchan).status == on) { did -c protection 31 }
    if ($group(#banword).status == on) { did -c protection 33 }
    if ($group(#textflood).status == on) { did -c protection 32  }
    if ($group(#promeban).status == on) { did -c protection 34 }
    if ($group(#noticeflood).status == on) { did -c protection 35 }
    if ($group(#actionflood).status == on) { did -c protection 36 }
    if ($group(#clone).status == on) { did -c protection 37 }
    if ($group(#textrep).status == on) { did -c protection 38 }
    if ($group(#noticerep).status == on) { did -c protection 39 }
    if ($group(#actionrep).status == on) { did -c protection 40 }
    if ($group(#colortext).status == on) { did -c protection 41 }
    if ($group(#invite).status == on) { did -c protection 42 }
    if ($group(#bugPirch).status == on) { did -c protection 45 }
    if ($group(#xlongtext).status == on) { did -c protection 53 }
    if ($group(#advertis).status == on) { did -c protection 70 }
  }
  if ($devent == sclick) {
    if ($did(2).state == 1) { .enable #bug }
    if ($did(2).state == 0) { .disable #bug }
    if ($did(3).state == 1) { .enable #metext }
    if ($did(3).state == 0) { .disable #metext }
    if ($did(8).state == 1) { .enable #menotice }
    if ($did(8).state == 0) { .disable #menotice }
    if ($did(13).state == 1) { .enable #meaction }
    if ($did(13).state == 0) { .disable #meaction }
    if ($did(18).state == 0) { set %ซิบฟลัด ปิด }
    if ($did(18).state == 1) { set %ซิบฟลัด เปิด }  
    if ($did(23).state == 1) { set %ป้องกันโฆณา เปิด }
    if ($did(23).state == 0) { set %ป้องกันโฆณา ปิด }
    if ($did(31).state == 0) { .disable #advchan }
    if ($did(31).state == 1) { .enable #advchan }
    if ($did(32).state == 1) { .enable #textflood }
    if ($did(32).state == 0) { .disable #textflood }
    if ($did(33).state == 0) { .disable #banword }
    if ($did(33).state == 1) { .enable #banword }
    if ($did(34).state == 1) { .enable #promeban }
    if ($did(34).state == 0) { .disable #promeban }
    if ($did(35).state == 1) { .enable #noticeflood  }
    if ($did(35).state == 0) { .disable #noticeflood }
    if ($did(36).state == 1) { .enable #actionflood }
    if ($did(36).state == 0) { .disable #actionflood }
    if ($did(37).state == 1) { .enable #clone }
    if ($did(37).state == 0) { .disable #clone }
    if ($did(38).state == 1) { .enable #textrep }
    if ($did(38).state == 0) { .disable #textrep }
    if ($did(39).state == 1) { .enable #noticerep }
    if ($did(39).state == 0) { .disable #noticerep }
    if ($did(40).state == 1) { .enable #actionrep }
    if ($did(40).state == 0) { .disable #actionrep }
    if ($did(41).state == 1) { .enable #colortext }
    if ($did(41).state == 0) { .disable #colortext }
    if ($did(42).state == 1) { .enable #invite }
    if ($did(42).state == 0) { .disable #invite }
    if ($did(43).state == 1) { set %kickban เปิด }
    if ($did(43).state == 0) { set %kickban ปิด }
    if ($did(44).state == 1) { set %pingme เปิด }
    if ($did(44).state == 0) { set %pingme ปิด }
    if ($did(46).state == 1) { set %kickvop เปิด }
    if ($did(46).state == 0) { set %kickvop ปิด }
    if ($did(47).state == 1) { set %kickctcp เปิด }
    if ($did(47).state == 0) { set %kickctcp ปิด }
    if ($did(45).state == 1) { .enable #bugPirch }
    if ($did(45).state == 0) { .disable #bugPirch }
    if ($did(53).state == 1) { .enable #xlongtext }
    if ($did(53).state == 0) { .disable #xlongtext }
    if ($did(70).state == 1) { .enable #advertis }
    if ($did(70).state == 0) { .disable #advertis }
    if ($did == 78) { text }
    if ($did == 48) { _luser }
    if ($did == 49) { _lbiduser }
    if ($did == 77) { swear }
    if ($did == 140) { menutext } 
    if ($did == 1) { .timer -mo 1 1 fade_out $dname | halt }
    %metextline = $did(4)
    %metexttime = $did(6) 
    %menotline = $did(9)
    %menottime = $did(11)
    %meactline = $did(14)
    %meacttime = $did(16)
    %mezipline = $did(19)
    %meziptime = $did(21)
    %bantimeadd = $did(28)
    set %bantime -u $+ %bantimeadd 
  }
  if ($did(24) == *!user@host.domain) { %banlevel = 0 }
  if ($did(24) == *!*user@host.domain) { %banlevel = 1 }
  if ($did(24) == *!*@host.domain) { %banlevel = 2 }
  if ($did(24) == *!*user@*.domain) { %banlevel = 3 }
  if ($did(24) == *!*@*.domain) { %banlevel = 4 }
  if ($did(24) == nick!user@host.domain) { %banlevel = 5 }
  if ($did(24) == nick!*user@host.domain) { %banlevel = 6 }
  if ($did(24) == nick!*@host.domain) { %banlevel = 7 }
  if ($did(24) == nick!*user@*.domain) { %banlevel = 8 }
  if ($did(24) == nick!*@*.domain) { %banlevel = 9 }
}
;=================== menutext ==================
alias menutext { 
  dialog -m menutext menutext
  if ($dialog(menutext) != $null) {
    set %stemp 2
    :start
    inc %stemp 1
    dialog -s menutext $dialog(menutext).x $dialog(menutext).y %stemp 148
    if (%stemp >= 180) { goto done }
    goto start 
    :done
  }
}
dialog menutext {
  title "Mode Text And Clone"
  size -1 -1 180 148
  option pixels
  text Repeat, 2, 8 10 41 15
  text "secs", 3, 143 8 27 16
  text "Flood", 4, 8 30 41 16
  edit , 5, 53 25 39 20
  text "secs", 6, 143 26 27 16
  button "DONE!!", 8, 0 130 180 18, flat ok
  edit , 9, 53 7 39 20
  text Longtext, 1, 8 48 41 14
  edit "", 10, 53 44 88 20
  text char, 11, 143 46 26 16
  edit "", 7, 53 68 39 20
  text "Join ip in:", 12, 8 87 45 16
  text "clone", 13, 144 89 28 16
  box , 14, 0 -4 181 134
  edit , 15, 53 86 88 20
  box , 16, 2 60 177 68
  box "", 17, 2 -2 177 69
  text "+imrb in:", 18, 9 107 43 16
  text "secs", 19, 144 108 28 16
  edit "", 20, 53 104 88 20
  text kick in:, 21, 7 70 46 16
  text secs, 22, 144 69 26 16
  edit , 23, 108 7 33 20
  text in, 24, 93 8 13 17
  edit , 25, 108 25 33 20
  text in, 26, 93 26 13 17
  edit , 27, 108 68 33 20
  text "in", 28, 93 70 13 14
}
on *:dialog:menutext:*:*:{
  if ($devent == init) {
    .did -ra menutext 9 %repeat
    .did -ra menutext 5 %flood
    .did -ra menutext 23 %retime
    .did -ra menutext 25 %floodtime 
    .did -ra menutext 10 %longtext
    .did -ra menutext 7 %kmaxclone 
    .did -ra menutext 15 %maxclone 
    .did -ra menutext 20 %mode.m 
    .did -ra menutext 27 %clotime 
  }
  if ($devent == sclick) {
    %repeat = $did(9)
    %flood = $did(5)
    %retime = $did(23)
    %floodtime = $did(25)
    %longtext = $did(10)
    %kmaxclone = $did(7)
    %maxclone = $did(15)
    %mode.m = $did(20)
    %clotime = $did(27)
    if ($did == 8) { .timer -mo 1 1 fade_out $dname | halt }
  }
}
;=================== dialog blacklist ==================
alias _buser { .guser blacklist $1 3 }
alias _rbuser { .ruser blacklist $1 3 }
alias _luser { _blacklist }
alias _blist {
  did -r _blacklist 11
  var %_btotal = $ulist(*,blacklist,0) , %_b = 0
  while (%_b < %_btotal) {
    inc %_b
    did -a _blacklist 11 $ulist(*,blacklist,%_b)
  }
}
alias _blacklist {
  dialog -m _blacklist _blacklist
  if ($dialog(_blacklist) != $null) {
    set %stemp 2
    :start
    inc %stemp 2
    dialog -s _blacklist $dialog(_blacklist).x $dialog(_blacklist).y %stemp 186
    if (%stemp >= 198) { goto done }
    goto start 
    :done
  }
}
dialog _blacklist {
  title "MetalX Black List"
  size -1 -1 99 93
  option dbu
  text ใส่ nick หรือ ip ใน Blacklist:, 10, 13 3 67 7
  combo 11, 1 12 65 72, sort
  edit , 12, 1 80 66 11, read autohs
  button add, 20, 67 13 30 10, default flat
  button "dilete", 30, 67 24 30 10, default flat
  button DONE, 40, 67 35 30 10, flat ok
  box "", 1, 0 -3 99 96
  box "", 2, 1 -2 97 14
}
on *:dialog:_blacklist:init:*: {
  _blist
}
on *:dialog:_blacklist:sclick:*: {
  if ($did == 20) {
    if ($did(11).text != $null && $level($did(11).text) != blacklist) {
      var %_badd = $did(11).text
      .auser blacklist %_badd
      _blist
      did -o $dname 12 1 Added %_badd to blacklist... | echo -a 5,4/4,5/4,1 (5(150,1 Add 7 %_badd 0 in blacklist now 5)7) 4,5\5,4\
    }
    elseif ($level($did(11).text) == blacklist) { did -o $dname 12 1 Address already exists... }
  }
  if ($did == 30) {
    if ($did(11).text != $null && $level($did(11).text) == blacklist) {
      var %_brem = $did(11).text
      .ruser blacklist %_brem
      _blist
      did -o $dname 12 1 Removed %_brem from blacklist... | echo -a   5,4/4,5/4,1 (5(150,1 delete 7 %_brem 0 from blacklist now 5)7) 4,5\5,4\ 
    }    
    elseif ($level($did(11).text) != blacklist) { did -o $dname 12 1 Address doesn't exist... }
  }
  if ($devent == sclick) {
    if ($did == 40)  { .timer -mo 1 1 fade_out $dname | halt }
  }
}
;=================== dialog badiden ==================
alias _biduser { .guser badident $1 3 }
alias _rbiduser { .ruser badident $1 3 }
alias _lbiduser {  _badident }
alias _bidlist {
  did -r _badident 11
  var %_bidtotal = $ulist(*,badident,0) , %_bid = 0
  while (%_bid < %_bidtotal) {
    inc %_bid
    did -a _badident 11 $ulist(*,badident,%_bid)
  }
}
alias _badident {
  dialog -m _badident _badident
  if ($dialog(_badident) != $null) {
    set %stemp 2
    :start
    inc %stemp 2
    dialog -s _badident $dialog(_badident).x $dialog(_badident).y %stemp 186
    if (%stemp >= 198) { goto done }
    goto start 
    :done
  }
}
dialog _badident {
  title "Badident"
  size -1 -1 99 93
  option dbu
  text ใส่ iden หรือ ip ใน Badiden, 10, 13 3 67 7
  combo 11, 1 12 65 72, sort
  edit , 12, 1 80 66 11, read autohs
  button add, 20, 67 13 30 10, default flat
  button "dilete", 30, 67 24 30 10, default flat
  button DONE, 40, 67 35 30 10, flat ok
  box "", 1, 0 -3 99 96
  box "", 2, 1 -2 97 14
}
on *:dialog:_badident:init:*: {
  _bidlist
}
on *:dialog:_badident:sclick:*: {
  if ($did == 20) {
    if ($did(11).text != $null && $level($did(11).text) != badident) {
      var %_badid = $did(11).text
      .auser badident %_badid
      _bidlist
    did -o $dname 12 1 Added %_badid to badident... | echo -a  0,7:15,4:4,5:14,1: 4(5(150,1 add 7 %_badid 0 in badiden now 5)7) 14:14,5:15,4:0,7:     }
    elseif ($level($did(11).text) == badident) { did -o $dname 12 1 Address already exists... }
  }
  if ($did == 30) {
    if ($did(11).text != $null && $level($did(11).text) == badident) {
      var %_bidrem = $did(11).text
      .ruser badident %_bidrem
      _bidlist
      did -o $dname 12 1 Removed %_bidrem from badident... | echo -a  0,7:15,4:4,5:14,1: 4(5(150,1 delete 7 %_bidrem 0 from badiden now 5)7) 14:14,5:15,4:0,7: 
    }    
    elseif ($level($did(11).text) != badident) { did -o $dname 12 1 Address doesn't exist... }
  }
  if ($devent == sclick) {
    if ($did == 40)  { .timer -mo 1 1 fade_out $dname | halt }
  }
}
;=================== end ==================
