
dialog -l protection {
  title "AutoExcept    4 Angel Red Script"
  size -1 -1 150 174
  option dbu
  tab "Impostazioni", 34, 2 31 145 120 
  tab "Esclusioni", 37 
  box "Eccezioni Automatiche", 11, 12 47 130 60, tab 34
  check "Attiva su Host", 18, 20 60 50 8, tab 34
  button "Ok", 17, 46 157 56 12, ok
  check "Abilita/Disabilita +e +I", 19, 45 11 70 8, right
  box "Togli +e +I all'aggressore ", 26, 12 110 130 35, tab 34
  check "Togli Eccezioni", 27, 20 125 50 8, tab 34
  check "Attiva su Nick", 28, 20 70 50 8, tab 34
  check "Attiva su Mask", 29, 20 80 65 8, tab 34
  check "Togli Inviti", 30, 80 125 50 8, tab 34
  check "Rimetti eccezioni se tolte", 36, 20 90 70 8, tab 34
  box "Canali esclusi dalle protezioni", 38, 7 49 135 97, tab 37
  check "Check", 39, 10 60 8 8, tab 37
  check "Check", 40, 10 70 8 8, tab 37
  check "Check", 41, 10 80 8 8, tab 37
  check "Check", 42, 10 90 8 8, tab 37
  check "Check", 43, 10 100 8 8, tab 37
  check "Check", 44, 10 110 8 8, tab 37
  check "Check", 45, 10 120 8 8, tab 37
  check "Attiva", 46, 10 136 40 8, tab 37 right
  edit %ca1, 47, 20 60 119 10, tab 37
  edit %ca2, 48, 20 70 119 10, tab 37
  edit %ca3, 49, 20 80 119 10, tab 37
  edit %ca4, 50, 20 90 119 10, tab 37
  edit %ca5, 51, 20 100 119 10, tab 37
  edit %ca6, 52, 20 110 119 10, tab 37
  edit %ca7, 53, 20 120 119 10, tab 37
}

Alias prt { /dialog -m protection protection }


on *:DIALOG:protection:sclick:18: { Set %ck13 $did(18) }
on *:DIALOG:protection:sclick:19: { Set %ck14 $did(19) }
on *:DIALOG:protection:sclick:27: { Set %ck20 $did(27) }
on *:DIALOG:protection:sclick:28: { Set %ck21 $did(28) }
on *:DIALOG:protection:sclick:29: { Set %ck22 $did(29) }
on *:DIALOG:protection:sclick:30: { Set %ck23 $did(30) }
on *:DIALOG:protection:sclick:36: { Set %ck24 $did(36) }
on *:DIALOG:protection:sclick:39: { Set %f1 $did(39) }
on *:DIALOG:protection:sclick:40: { Set %f2 $did(40) }
on *:DIALOG:protection:sclick:41: { Set %f3 $did(41) }
on *:DIALOG:protection:sclick:42: { Set %f4 $did(42) }
on *:DIALOG:protection:sclick:43: { Set %f5 $did(43) }
on *:DIALOG:protection:sclick:44: { Set %f6 $did(44) }
on *:DIALOG:protection:sclick:45: { Set %f7 $did(45) }
on *:DIALOG:protection:edit:47: { Set %ca1 $did(47) }
on *:DIALOG:protection:edit:48: { Set %ca2 $did(48) }
on *:DIALOG:protection:edit:49: { Set %ca3 $did(49) }
on *:DIALOG:protection:edit:50: { Set %ca4 $did(50 }
on *:DIALOG:protection:edit:51: { Set %ca5 $did(51) }
on *:DIALOG:protection:edit:52: { Set %ca6 $did(52) }
on *:DIALOG:protection:edit:53: { Set %ca7 $did(53) }
on *:DIALOG:protection:sclick:46: { Set %fatt $did(45) }

on *:dialog:protection:init:*: {
  if %ck13 = ON { did -c protection 18 }  
  if %ck14 = ON { did -c protection 19 }
  if %ck20 = ON { did -c protection 27 }       
  if %ck21 = ON { did -c protection 28 } 
  if %ck22 = ON { did -c protection 29 } 
  if %ck23 = ON { did -c protection 30 } 
  if %ck24 = ON { did -c protection 36 } 
  if %f1 = ON { did -c protection 39 }
  if %f2 = ON { did -c protection 40 }
  if %f3 = ON { did -c protection 41 }
  if %f4 = ON { did -c protection 42 }
  if %f5 = ON { did -c protection 43 }
  if %f6 = ON { did -c protection 44 }
  if %f7 = ON { did -c protection 45 }
  if %fatt = ON { did -c protection 46 }
}

on *:dialog:protection:sclick:17: {
  if ($did(protection,18).state = 1) { %ck13 = on } | else { %ck13 = off }
  if ($did(protection,19).state = 1) { %ck14 = on } | else { %ck14 = off }
  if ($did(protection,27).state = 1) { %ck20 = on } | else { %ck20 = off }
  if ($did(protection,28).state = 1) { %ck21 = on } | else { %ck21 = off }
  if ($did(protection,29).state = 1) { %ck22 = on } | else { %ck22 = off }
  if ($did(protection,30).state = 1) { %ck23 = on } | else { %ck23 = off }
  if ($did(protection,36).state = 1) { %ck24 = on } | else { %ck24 = off }
  if ($did(protection,39).state = 1) { %f1 = on } | else { %f1 = off }
  if ($did(protection,40).state = 1) { %f2 = on } | else { %f2 = off }
  if ($did(protection,41).state = 1) { %f3 = on } | else { %f3 = off }
  if ($did(protection,42).state = 1) { %f4 = on } | else { %f4 = off }
  if ($did(protection,43).state = 1) { %f5 = on } | else { %f5 = off }
  if ($did(protection,44).state = 1) { %f6 = on } | else { %f6 = off }
  if ($did(protection,45).state = 1) { %f7 = on } | else { %f7 = off }
  if ($did(protection,46).state = 1) { %fatt = on } | else { %fatt = off }
}

on *:Deop:#:{
  if (%ck20 == on) { .timer 1 1 /mode # -e $nick | .timer 1 1 /mode $chan -e $mask($ial($nick,1),2) | .timer 1 1 /mode $chan -e $mask($ial($nick,1),3) | .timer 1 1 /mode $chan -e $address($nick,1) }
  if (%ck23 == on) { .timer 1 1 /mode $chan -I $mask($ial($nick,1),3) | .timer 1 1 /mode # -I $nick | .timer 1 1 /mode $chan -I $mask($ial($nick,1),2) | .timer 1 1 /mode $chan -I $address($nick,1) }   
  if ($chan == %ca1) && (%f1 == on) && (%fatt == on) { halt }
}

on 1:Kick:#:{
  if ( $knick == $me ) && (%ck20 == on) && (%ck14 == on) && ($nick ison $chan) && ($nick !== $me) { /mode # -e $nick | /mode $chan -e $mask($ial($nick,1),2) | /mode $chan -e $mask($ial($nick,1),3) | /mode $chan -e $address($nick,1) }
  if ( $knick == $me ) && (%ck23 == on) && (%ck14 == on) && ($nick ison $chan) && ($nick !== $me) { /mode $chan -I $mask($ial($nick,1),3) | /mode # -I $nick | mode $chan -I $mask($ial($nick,1),2) | /mode $chan -I $address($nick,1) }
}

on *:ban:#:{ 
  if ($banmask iswm $address($me,6)) && ($me isop $chan) && ($nick ison $chan) && ($nick != $me) && ($nick != ChanServ) && (%ck20 == on) && (%ck14 == on) { /mode # -e $nick | /mode $chan -e $mask($ial($nick,1),2) | /mode $chan -e $mask($ial($nick,1),3) | /mode $chan -e $address($nick,1) }
  if ($banmask iswm $address($me,6)) && ($me isop $chan) && ($nick ison $chan) && ($nick != $me) && ($nick != ChanServ) && (%ck23 == on) && (%ck14 == on) { /mode $chan -I $mask($ial($nick,1),3) | /mode # -I $nick | mode $chan -I $mask($ial($nick,1),2) | /mode $chan -I $address($nick,1) }
}

ON *:RAWMODE:#:{ 
  if ($chan == %ca1) && (%f1 == on) && (%fatt == on) && (%ck14 == on) { halt }
  if ($chan == %ca2) && (%f2 == on) && (%fatt == on) && (%ck14 == on) { halt }
  if ($chan == %ca3) && (%f3 == on) && (%fatt == on) && (%ck14 == on) { halt }
  if ($chan == %ca4) && (%f4 == on) && (%fatt == on) && (%ck14 == on) { halt }
  if ($chan == %ca5) && (%f5 == on) && (%fatt == on) && (%ck14 == on) { halt }
  if ($chan == %ca6) && (%f6 == on) && (%fatt == on) && (%ck14 == on) { halt }
  if ($chan == %ca7) && (%f7 == on) && (%fatt == on) && (%ck14 == on) { halt }
  if (%ck13 == on) && (%ck14 == on) && (+a isin $1) && ($2 == $me) { /mode $chan +e $mask($ial($me,1),2) | mode $chan +I $mask($ial($me,1),2) }
  if (%ck13 == on) && (%ck14 == on) && (+o isin $1) && ($2 == $me) { /mode $chan +e $mask($ial($me,1),2) | mode $chan +I $mask($ial($me,1),2) }
  if (%ck13 == on) && (%ck14 == on) && (+h isin $1) && ($2 == $me) { /mode $chan +e $mask($ial($me,1),2) | mode $chan +I $mask($ial($me,1),2) }
  if (%ck13 == on) && (%ck14 == on) && (+q isin $1) && ($2 == $me) { /mode $chan +e $mask($ial($me,1),2) | mode $chan +I $mask($ial($me,1),2) }
  if (%ck21 == on) && (%ck14 == on) && (+a isin $1) && ($2 == $me) { /mode # +e $me | /mode # +I $me }
  if (%ck21 == on) && (%ck14 == on) && (+o isin $1) && ($2 == $me) { /mode # +e $me | /mode # +I $me }
  if (%ck21 == on) && (%ck14 == on) && (+h isin $1) && ($2 == $me) { /mode # +e $me | /mode # +I $me }
  if (%ck21 == on) && (%ck14 == on) && (+q isin $1) && ($2 == $me) { /mode # +e $me | /mode # +I $me }
  if (%ck22 == on) && (%ck14 == on) && (+a isin $1) && ($2 == $me) { /mode $chan +e $mask($ial($me,1),3) | /mode $chan +I $mask($ial($me,1),3) }
  if (%ck22 == on) && (%ck14 == on) && (+o isin $1) && ($2 == $me) { /mode $chan +e $mask($ial($me,1),3) | /mode $chan +I $mask($ial($me,1),3) }
  if (%ck22 == on) && (%ck14 == on) && (+h isin $1) && ($2 == $me) { /mode $chan +e $mask($ial($me,1),3) | /mode $chan +I $mask($ial($me,1),3) }
  if (%ck22 == on) && (%ck14 == on) && (+q isin $1) && ($2 == $me) { /mode $chan +e $mask($ial($me,1),3) | /mode $chan +I $mask($ial($me,1),3) }
  if (%ck14 == on) && (%ck24 == on) && (-e isin $1) && (%ck21 == on) && ($me isop $chan) { /mode # +e $me }
  if (%ck14 == on) && (%ck24 == on) && (-e isin $1) && (%ck13 == on) && ($me isop $chan) { /mode $chan +e $mask($ial($me,1),2) }
  if (%ck14 == on) && (%ck24 == on) && (-e isin $1) && (%ck22 == on) && ($me isop $chan) { /mode $chan +e $mask($ial($me,1),3) }
  if (%ck14 == on) && (%ck24 == on) && (-I isin $1) && (%ck21 == on) && ($me isop $chan) { /mode # +I $me }
  if (%ck14 == on) && (%ck24 == on) && (-I isin $1) && (%ck13 == on) && ($me isop $chan) { /mode $chan +I $mask($ial($me,1),2) }
  if (%ck14 == on) && (%ck24 == on) && (-I isin $1) && (%ck22 == on) && ($me isop $chan) { /mode $chan +I $mask($ial($me,1),3) }
  if (%ck14 == on) && (%ck24 == on) && (+i isincs $1) && (%ck21 == on) && ($me isop $chan) { /mode # +I $me }
  if (%ck14 == on) && (%ck24 == on) && (+i isincs $1) && (%ck13 == on) && ($me isop $chan) { /mode $chan +I $mask($ial($me,1),2) }
  if (%ck14 == on) && (%ck24 == on) && (+i isincs $1) && (%ck22 == on) && ($me isop $chan) { /mode $chan +I $mask($ial($me,1),3) }
}
