
alias ban1 {
  if (MindForge.org isincs $address($nick,1)) { /except | /mode # -ee $nick $mask($ial($nick,1),3),2) | /mode # -aohv $nick $nick $nick $nick | /mode # +bb $nick $address($nick,3) }
  else { /except | /mode # -ee $nick $mask($ial($nick,1),3),2) | /mode # -aohv $nick $nick $nick $nick | /mode # +bb $nick $address($nick,2) }
}

;-------------> 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 }

;---------> DIALOG <---------------;

dialog proper {
  Title "Ptotezioni    4 Angel Red Script"
  size -1 -1 138 120 
  option dbu
  tab "Deop" 1, 2 3 134 90
  tab "Kick" 2, 2 3 134 90 
  tab "Ban" 3, 2 3 134 90
  box "Seleziona le azioni da compiere on Deop" 4, 5 20 128 55, tab 1
  box "Seleziona le azioni da compiere on Kick" 5, 5 20 128 55, tab 2
  box "Seleziona le azioni da compiere on Ban" 6, 5 20 128 55, tab 3
  button "OK" 7, 4 99 40 17, ok
  button "Annulla" 8, 95 99 40 17, cancel

  ;---> dialog deop, tab 1
  check "Deop" 9, 10 30 23 10, tab 1
  check "Kick" 10, 50 30 20 10, tab 1
  check "Ban" 11, 93 30 20 10, tab 1
  text "Setta Messaggio al kick" 12, 10 47 100 10, tab 1
  edit "", 13, 10 58 118 10, tab 1 autohs
  radio "Attiva" 14, 18 80 30 10, tab 1
  radio "Disattiva" 15, 90 80 33 10, tab 1
  ;---> dialog kick, tab 2
  check "Deop" 16, 10 30 23 10, tab 2
  check "Kick" 17, 50 30 20 10, tab 2
  check "Ban" 18, 93 30 20 10, tab 2
  text "Setta Messaggio al kick" 19, 10 47 100 10, tab 2
  edit "", 20, 10 58 118 10, tab 2 autohs
  radio "Attiva" 21, 18 80 30 10, tab 2
  radio "Disattiva" 22, 90 80 33 10, tab 2
  ;---> dialog ban, tab 2
  check "Deop" 23, 10 30 23 10, tab 3
  check "Kick" 24, 50 30 20 10, tab 3
  check "Ban" 25, 93 30 20 10, tab 3
  check "Unban me" 26, 93 43 37 10, tab 3
  text "Setta Messaggio al kick" 27, 10 47 73 10, tab 3
  edit "", 28, 10 58 118 10, tab 3 autohs
  radio "Attiva" 29, 18 80 30 10, tab 3
  radio "Disattiva" 30, 90 80 33 10, tab 3
} 
;<------------------------>;
on *:dialog:proper:init:0: {
  ;mdx  
  mdxbegin
  mdx SetFont $dname 12,19,27 14  autohs 
  mdx SetFont $dname 7,8,9,10,11,14,15,16,17,18,21,22,23,24,25,26,29,30 16  autohs
  mdx SetFont $dname 4,5,6 14  autohs

  ;deop
  if (%Deop_stato == on) { did -c proper 14 }
  if (%Deop_stato == off) { did -c proper 15 | did -b proper 9 | did -b proper 10 | did -b proper 11 | did -b proper 13 }
  if (%Deop_deop == off) { did -u proper 9 }
  if (%Deop_deop == on) { did -c proper 9 }
  if (%Deop_kick == off) { did -u proper 10 | did -b proper 13 } 
  if (%Deop_kick == on) { did -c proper 10 } 
  if (%Deop_ban == off) { did -u proper 11 }
  if (%Deop_Ban == on) { did -c proper 11 }
  { did -a proper 13 %Deop_mess_kick }
  ;kick
  if (%Kick_stato == on) { did -c proper 21 }
  if (%Kick_stato == off) { did -c proper 22 | did -b proper 16 | did -b proper 17 | did -b proper 18 | did -b proper 20 }
  if (%Kick_deop == off) { did -u proper 16 }
  if (%Kick_deop == on) { did -c proper 16 }
  if (%Kick_kick == off) { did -u proper 17 | did -b proper 20 } 
  if (%Kick_kick == on) { did -c proper 17 } 
  if (%Kick_ban == off) { did -u proper 18 }
  if (%Kick_ban == on) { did -c proper 18 }
  { did -a proper 20 %Kick_mess_kick }
  ;ban
  if (%Ban_stato == on) { did -c proper 29 }
  if (%Ban_stato == off) { did -c proper 30 | did -b proper 23 | did -b proper 24 | did -b proper 25 | did -b proper 26 | did -b proper 28 }
  if (%Ban_deop == off) { did -u proper 23 }
  if (%Ban_deop == on) { did -c proper 23 }
  if (%Ban_kick == off) { did -u proper 24 | did -b proper 28 } 
  if (%Ban_kick == on) { did -c proper 24 } 
  if (%Ban_ban == off) { did -u proper 25 }
  if (%Ban_ban == on) { did -c proper 25 }
  if (%Ban_ban == off) { did -u proper 25 }
  if (%Ban_ban == on) { did -c proper 25 }
  if (%Unban_me == on) { did -c proper 26 }
  if (%Unban_me == off) { did -u proper 26 }
  { did -a proper 28 %Ban_mess_kick }
}

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

on *:dialog:proper:sclick:9: { 
  if ($did(9).state == 1) { set %Deop_deop on }
  else { set %Deop_deop off }
}
on *:dialog:proper:sclick:10: { 
  if ($did(10).state == 1) { set %Deop_kick on | did -e proper 13 }
  else { set %Deop_kick off | did -b proper 13 }
}
on *:dialog:proper:sclick:11: { 
  if ($did(11).state == 1) { set %Deop_ban on }
  else { set %Deop_ban off }
}
on *:dialog:proper:edit:13: { set %Deop_mess_kick $did(proper,13) }
on *:dialog:proper:sclick:14: { set %Deop_stato on | did -e proper 9 | did -e proper 10 | did -e proper 11 | if ($did(10).state = 1) did -e proper 13 | echo -a 7[3Deop-Protection7]3 Attivato }
on *:dialog:proper:sclick:15: { set %Deop_stato off | did -b proper 9 | did -b proper 10 | did -b proper 11 | did -b proper 13 | echo -a 7[3Deop-Protection7]3 Disattivato }
;<------------------------>;
on *:dialog:proper:sclick:16: { 
  if ($did(16).state = 1) { set %Kick_deop on }
  else { set %Kick_deop off }
}
on *:dialog:proper:sclick:17: { 
  if ($did(17).state = 1) { set %Kick_kick on | did -e proper 20 }
  else { set %Kick_kick off | did -b proper 20 }
}
on *:dialog:proper:sclick:18: { 
  if ($did(18).state = 1) { set %Kick_ban on }
  else { set %Kick_ban off }
}
on *:dialog:proper:edit:20: { set %Kick_mess_kick $did(proper,20) }
on *:dialog:proper:sclick:21: { set %Kick_stato on | did -e proper 16 | did -e proper 17 | did -e proper 18 | if ($did(17).state = 1) did -e proper 20 | echo -a 7[3Kick-Protection7] 3Attivato  }
on *:dialog:proper:sclick:22: { set %Kick_stato off | did -b proper 16 | did -b proper 17 | did -b proper 18 | did -b proper 20 | echo -a 7[3Kick-Protection7]3 Disattivato  }
;<------------------------>;
on *:dialog:proper:sclick:23: { 
  if ($did(23).state = 1) { set %Ban_deop on }
  else { set %Ban_deop off }
}
on *:dialog:proper:sclick:24: { 
  if ($did(24).state = 1) { set %Ban_kick on | did -e proper 28 }
  else { set %Ban_kick off | did -b proper 28 }
}
on *:dialog:proper:sclick:25: { 
  if ($did(25).state = 1) { set %Ban_ban on }
  else { set %Ban_ban off }
}
on *:dialog:proper:sclick:26: { 
  if ($did(26).state = 1) { set %Unban_me on }
  else { set %Unban_me off }
}
on *:dialog:proper:edit:28: { set %Ban_mess_kick $did(proper,28) }
on *:dialog:proper:sclick:29: { set %Ban_stato on | did -e proper 23 | did -e proper 24 | did -e proper 25 | did -e proper 26 | if ($did(24).state = 1) did -e proper 28 | echo -a 7[3Ban-Protection7]3 Attivato  }
on *:dialog:proper:sclick:30: { set %Ban_stato off | did -b proper 23 | did -b proper 24 | did -b proper 25 | did -b proper 26 | did -b proper 28 | echo -a 7[3Ban-Protection7]3 Disattivato  }

;----------> EVENTI <-------------;

on *:ban:#: {
  if (%Ban_stato == on) {
    if ($banmask isin $address($me,0)) || ($banmask isin $address($me,1)) || ($banmask isin $address($me,2)) || ($banmask isin $address($me,3)) || ($banmask isin $address($me,4)) || ($banmask isin $address($me,5)) || ($banmask isin $address($me,6)) || ($banmask isin $address($me,7)) || ($banmask isin $address($me,8)) || ($banmask isin $address($me,9)) || ($banmask isin $address($me,10)) { 
      if ($me isop $chan) {
        if (%Unban_me = on) { cs unban $chan $me | haltdef }
        if (%Ban_deop = on) && (%Ban_ban = off) && (%Ban_kick = off) { /mode $chan -ohv $nick $nick $nick | halt }
        if (%Ban_ban = on) && (%Ban_kick = off) { ban1 | halt }
        if (%Ban_kick = on) && (%Ban_ban = off) { /mode $chan -ohv $nick $nick $nick | kick # $nick %Ban_mess_kick | /mode # -Q | kick # $nick %Ban_mess_kick | halt }
        if (%Ban_kick = on) && (%Ban_ban = on) { ban1 | kick # $nick %Ban_mess_kick | /mode # -Q | kick # $nick %Ban_mess_kick }
      }
    }
  }
  elseif (%Ban_stato == off) { return }
}

on *:deop:#: {
  if ($nick == $me) { halt | return }
  if ($opnick == $me) && ($nick != Chanserv) && ($address($nick,2) != *!*@Services.MindForge.org) {
    if (%Deop_stato == on) {
      /cs op # $me | /cs protect # $me {
        if (%Deop_deop == on) && (%Deop_ban == off) && (%Deop_kick == off) { /mode $chan -ohv $nick $nick $nick $nick | halt }
        if (%Deop_ban == on) && (%Deop_kick == off) { /mode $chan -ohv+bb $nick $nick $nick $nick $address($nick,3) | halt }
        if (%Deop_kick == on) && (%Deop_ban == off) { /mode $chan -ohv $nick $nick $nick | kick # $nick %Deop_mess_kick | /mode # -Q | kick # $nick %Deop_mess_kick | halt }
        if (%Deop_kick == on) && (%Deop_ban == on) { /mode $chan -ohv+bb $nick $nick $nick $nick $address($nick,3) | kick # $nick %Deop_mess_kick | /mode # -Q | kick # $nick %Deop_mess_kick | halt }
      }
    }
    elseif (%Deop_stato == off ) { return }
  }
}

on *:Kick:#: {
  if ($nick == $me) { halt | return }
  if ($knick == $me) && ($nick != Chanserv) { 
    if (%Kick_stato == on) {
      /hop # {
        if (%Kick_deop = on) && (%Kick_ban = off) && (%Kick_kick = off) { /mode $chan -aohv $nick $nick $nick $nick | halt }
        if (%Kick_ban = on) && (%Kick_kick = off) { /mode $chan -ohv+bb $nick $nick $nick $nick $address($nick,3) | halt }
        if (%Kick_kick = on) && (%Kick_ban = off) { /mode $chan -ohv $nick $nick $nick | kick # $nick %Kick_mess_kick | /mode # -Q | kick # $nick %Kick_mess_kick | halt }
        if (%Kick_kick = on) && (%Kick_ban = on) { /mode $chan -ohv+bb $nick $nick $nick $nick $address($nick,3) | kick # $nick %Kick_mess_kick | /mode # -Q | kick # %Kick_mess_kick | halt }
      }
    }
  elseif (%Kick_stato == off) {return }
}
}
