; Ban Manager v1.00
; -----------------
;
; Gestionnaire des BAN's sur les canaux où vous êtes OP.
; Gestion par interface graphique.
; Ajout et retrait de Bans
; 
; Scripteur: Steve "(the) GuaRDiaN" De Jongh 
;
; Si vous souhaitez utilisez ou modifier ce fichier, veuillez ne pas modifier mes données.
; D'avance merci.
	

on me:*:join:#:mode $chan b

alias banmanager { if $dialog(banmanager) == $null dialog -md banmanager banmanager }

dialog banmanager {
  title "Ban Manager v1.00"
  size -1 -1 100 200
  option dbu
  text "Liste des adresses bannies:",1, 5 5 90 8
  list 2, 5 15 90 50,sort vsbar
  button "Supprimer",3, 5 60 40 10
  button "Rafraîchir",4, 55 60 40 10
  text "Nouvelle adresse:",5, 5 72 60 8
  edit "",6, 5 80 90 12
  text "Sur le canal:",7, 5 95 60 8
  combo 8, 5 105 90 36, drop vsbar
  button "Ajouter",9, 5 120 90 10
  button "Fermer",99, 10 185 80 10,cancel
}

on *:dialog:banmanager:init:0: {
  refresh_banlist
  refresh_chan
}

alias add_banned {
  var %nb_ban_active = $banlist( %chan_managed , 0)
  var %z = 1
  while ( %z <= %nb_ban_active ) {
    did -a banmanager 2 %chan_managed $+ § $+ $banlist( %chan_managed , %z )
    inc %z
  }
}

on *:dialog:banmanager:sclick:3: {
  if ($did(2).sel != $null) {
    if ($me isop $gettok($did(2,$did(banmanager,2).sel),1,167) ) mode $gettok( $did(2, $did(banmanager,2).sel ) ,1,167) -b $gettok( $did(2, $did(banmanager,2).sel ) ,2,167)
    did -d banmanager 2 $did(banmanager,2).sel
  }
}

on *:dialog:banmanager:sclick:4: {
  refresh_banlist
  refresh_chan
}

alias refresh_banlist {
  did -r banmanager 2 
  var %nb_chan_managed = $chan($me)
  var %i = 1
  while ( %i <= %nb_chan_managed ) {
    set %chan_managed $chan( %i )
    if ( $me isop %chan_managed ) add_banned
    inc %i
  }

}

on *:dialog:banmanager:sclick:99: {
  unset %chan_managed
}

alias refresh_chan {
  did -r banmanager 8
  var %chan_iam_on_nb = $chan($me)
  var %m = 1
  while ( %m <= %chan_iam_on_nb ) {
    if ($me isop $chan(%m)) did -a banmanager 8 $chan( %m )
    inc %m
  }
}

on *:dialog:banmanager:sclick:9: {
  if ( $did(banmanager,6) != $null ) && ( $did(banmanager,8).sel != $null ) {
    mode $did(8,$did(banmanager,8).sel) +b $did(banmanager,6)
    did -a banmanager 2 $did(8,$did(banmanager,8).sel) $+ § $+ $did(banmanager,6)
    did -r banmanager 6
    refresh_chan
  }
}