
;-------------> ALIAS DDL <---------------;

alias mdx { var %dll $mircdirAddons\dll\mdx\mdx.dll } | return $dll(%dll,$1,$2-) }
alias dialogx { return $mircAddons\dll\mdx\dialog.mdx }
alias mdxbegin { mdx SetMircVersion $version | mdx MarkDialog $dname }

;----> alias <----;

alias antiunban { dialog -m antiunban antiunban }
alias listinit {
  set %n 1
  :init
  did -a antiunban 1 $gettok(%aub.canali,%n,32)
  if (%n = $numtok(%aub.canali,32)) { halt }
  inc %n 1
  goto init
}

alias aub.add { 
  if (!%aub.canali) { /set %aub.canali $did(antiunban,5).text }
  else { /set %aub.canali $addtok(%aub.canali,$did(antiunban,5).text,32) }
  did -b antiunban 2
}
alias aub.rem { /set %chantodel $findtok(%aub.canali,$did(antiunban,1).seltext,1,32) | /set %aub.canali $deltok(%aub.canali,%chantodel,32) }
alias aub.cancella {
  set %n1 $numtok(%aub.canali,32)
  unset %aub.canali
  :cancella
  /did -d antiunban 1 %n1  
  if (%n1 = 1) { halt }
  dec %n1 1
  goto cancella
}


;----> dialog <----;

dialog antiunban {
  title "Anti-Unban"
  size -1 -1 116 130
  option dbu
  List 1 ,40 25 70 70, autohs, autovs, hsbar, vsbar,
  Button "&Aggiungi" , 2,5 30 30 13, default 
  Button "&Rimuovi" , 3,5 50 30 13
  button "Cancella",4, 5 70 30 13
  Edit "" 5 ,40 10 70 9, autohs multi
  text "Channel",6,5 10 20 10
  radio "Attiva",7, 5 90 30 10
  radio "Disattiva",8,74 90 34 10
  button "OK",9, 3 110 30 15, ok
  button "Annulla",10, 83 110 30 15, cancel
  box "",12,2 3 112 100

}

on *:dialog:antiunban:init:0: { 
  ;mdx  
  mdxbegin
  mdx SetFont $dname 2,3,4,6,7,8 14  autohs 
  mdx SetFont $dname 9,10 16  autohs
  mdx SetFont $dname 1,5 12  tahoma 
  ;dialog
  did -b antiunban 2
  did -b antiunban 3
  if (%antiunban == on) { did -c antiunban 7 }
  else { did -c antiunban 8 }
  if (!%aub.canali) { did -b antiunban 4 | halt }
  else { did -e antiunban 4 | listinit }

}

on *:dialog:antiunban:edit:5: { did -e antiunban 2 }

on *:dialog:antiunban:sclick:2: { did -a antiunban 1 $did(antiunban,5).text | aub.add |  did -r antiunban 5 | did -e antiunban 4 }

on *:dialog:antiunban:sclick:1: { did -e antiunban 3 }

on *:dialog:antiunban:sclick:3: { aub.rem | did -d antiunban 1 $did(antiunban,1).sel }

on *:dialog:antiunban:sclick:4: { aub.cancella | unset %aub.canali }

on *:dialog:antiunban:sclick:7: { set %antiunban on  }

on *:dialog:antiunban:sclick:8: { set %antiunban off  }


;----> eventi <----;

on *:unban:#: {
  if (%antiunban == on) && (service.Mindforge.org = $nick) && ($nick != $me) && ($chan isin %aub.canali) {
    if ($me isop #) { /mode $chan +b $banmask }
  }
  else { haltdef }
}
