<PROTEZIONI>
alias prot { if ($dialog(prot)) { dialog -x prot } | dialog -m prot prot }

dialog prot {
  title "Protezioni - Ms3.1"
  size -1 -1 350 240
  tab "Canale",500, 1 1 348 240
  tab "Personale", 501, 1 1 348 240
  icon 1, 8 201 35 32, images\icone\protection.ico
  box "Anti Flood", 2, 5 28 168 170,tab 500
  box "Righe   Secs", 3, 95 36 74 157, tab 500
  check "Testo..", 4, 10 51 50 19,tab 500
  edit "",5, 105 50 18 19,right, tab 500
  edit "", 6, 140 50 18 19,right, tab 500
  check "Notice..", 7, 10 71 50 19,tab 500
  edit "",8, 105 70 18 19,right, tab 500
  edit "", 9, 140 70 18 19,right, tab 500
  check "Action..", 10, 10 91 55 19,tab 500
  edit "",11, 105 90 18 19,right, tab 500
  edit "", 12, 140 90 18 19,right, tab 500
  check "Cambio Nick..", 13, 10 111 80 19,tab 500
  edit "",14, 105 110 18 19,right, tab 500
  edit "", 15, 140 110 18 19,right, tab 500
  check "Join..", 16, 10 131 80 19,tab 500
  edit "",17, 105 130 18 19,right, tab 500
  edit "", 18, 140 130 18 19,right, tab 500
  check "Topic..", 19, 10 151 80 19,tab 500
  edit "",20, 105 150 18 19,right, tab 500
  edit "", 21, 140 150 18 19,right, tab 500
  check "Mode..", 22, 10 171 80 19,tab 500
  edit "",23, 105 170 18 19,right, tab 500
  edit "", 24, 140 170 18 19,right, tab 500
  box "Anti mass action", 25, 178 28 168 110, tab 500
  box "Azioni   Secs", 26, 263 36 79 97, tab 500
  check "Mass Op..", 27, 183 51 60 19,tab 500
  edit "",28, 278 50 18 19,right, tab 500
  edit "", 29, 310  50 18 19,right, tab 500
  check "Mass Deop..", 30, 183 71 70 19,tab 500
  edit "",31, 278 70 18 19,right, tab 500
  edit "", 32, 310  70 18 19,right, tab 500
  check "Mass Kick..", 33, 183 91 65 19,tab 500
  edit "",34, 278 90 18 19,right, tab 500
  edit "", 35, 310  90 18 19,right, tab 500
  check "Mass Ban..", 36, 183 111 65 19,tab 500
  edit "",37, 278 110 18 19,right, tab 500
  edit "", 38, 310  110 18 19,right, tab 500
  box "Altre", 39, 178 138 168 55, tab 500
  check "ServerOp", 40, 183 150 60 19, tab 500
  check "Bitch Mode", 41, 270 150 70 19, tab 500
  check "Parole proibite",68, 183 170 85 19,tab 500
  check "No caps",69, 270 170 70 19,tab 500

  box "Anti Flood", 42, 5 28 168 172,tab 501
  box "Righe   Secs", 43, 95 36 74 117, tab 501
  check "Testo..", 44, 10 51 50 19,tab 501
  edit "",45, 105 50 18 19,right, tab 501
  edit "", 46, 140 50 18 19,right, tab 501
  check "Notice..", 47, 10 71 50 19,tab 501
  edit "",48, 105 70 18 19,right, tab 501
  edit "", 49, 140 70 18 19,right, tab 501
  check "Action..", 50, 10 91 55 19,tab 501
  edit "",51, 105 90 18 19,right, tab 501
  edit "", 52, 140 90 18 19,right, tab 501
  check "Invite..", 53, 10 111 80 19,tab 501
  edit "",54, 105 110 18 19,right, tab 501
  edit "", 55, 140 110 18 19,right, tab 501
  check "Ctcp..", 56, 10 131 80 19,tab 501
  edit "",57, 105 130 18 19,right, tab 501
  edit "", 58, 140 130 18 19,right, tab 501
  box "Altre", 59, 178 167 168 33, tab 501
  check "AntiBan (@)", 60, 185 178 80 19,tab 501
  check "Rifiuta query", 63, 265 178 75 19, tab 501
  box "", 64, 15 150 150 8,tab 501
  text "Ignora l'utente per secondi:", 65, 10 164 140 19,tab 501
  edit "", 66, 140 159 18 19,right, tab 501
  check "Avvisalo della fine dell'ignore", 67, 10 178 150 19,tab 501
  check "Attiva antispam",70, 185 143 100 19,tab 501
  box "Antispam", 77, 178 28 168 135,tab 501
  edit "",78, 181 43 115 19,autohs,tab 501
  button "+", 79, 298 43 20 19,tab 501
  button "-",80, 318 43 20 19,tab 501
  list 81, 181 64 160 78,size,tab 501
  list 82, 355 20 140 200,size
  text "www.mIRCscript.it",83, 380 223 150 19
  button "&Chiudi", 100, 195 210 70 21,ok
  button "&Guida >>", 101, 275 210 70 21
  button "&Avanzate", 102, 115 210 70 21,tab 500
}
on *:dialog:prot:*:*:{
  if ($devent == init) {
    mdxbegin
    mdx SetFont 2,25,39,42,59,77 12 700 Tahoma
    mdx SetFont 100,101,102,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29,30,31,32,33,34,35,36,37,38,40,41,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,60,63,65,66,67,68,69,70,78,79,80,81,82,83 12 400 Tahoma
    mdx SetBorderStyle 79,80,100,101,102 staticedge
    mdx SetControlMDX 81 Listview report rowselect icon grid showsel single labeltip headerdrag  > sistema\dlls\views.mdx
    did -i prot 81 1 headerdims 140:1 | did -i prot 81 1 headertext + 0 Lista: | caricaantispam
    mdx SetControlMDX 82 ListView report rowselect showsel single labeltip headerdrag > sistema\dlls\ $+ views.mdx
    did -i prot 82 1 headerdims 120:1 | did -i prot 82 1 headertext + 0 Guida all'uso:
    var %rigo = 1 | while $lines(dati\guide\protchan.txt) >= %rigo { did -az prot 82 $read -l $+ %rigo dati\guide\protchan.txt | inc %rigo } 
    if (%pft) { did -c prot 4 } | else { did -b prot 5,6 }
    did -ra prot 5 %pftrighi | did -ra prot 6 %pftsec 
    if (%pfnot) { did -c prot 7 } | else { did -b prot 8,9 }
    did -ra prot 8 %pfnotrighi | did -ra prot 9 %pfnotsec 
    if (%pfact) { did -c prot 10 } | else { did -b prot 11,12 }
    did -ra prot 11 %pfactrighi | did -ra prot 12 %pfactsec 
    if (%pfnk) { did -c prot 13 } | else { did -b prot 14,15 }
    did -ra prot 14 %pfnkrighi | did -ra prot 15 %pfnksec 
    if (%pfj) { did -c prot 16 } | else { did -b prot 17,18 }
    did -ra prot 17 %pfjrighi | did -ra prot 18 %pfjsec 
    if (%pftp) { did -c prot 19 } | else { did -b prot 20,21 }
    did -ra prot 20 %pftprighi | did -ra prot 21 %pftpsec 
    if (%pfmd) { did -c prot 22 } | else { did -b prot 23,24 }
    did -ra prot 23 %pfmdrighi | did -ra prot 24 %pfmdsec 
    if (%pmop) { did -c prot 27 } | else { did -b prot 28,29 }
    did -ra prot 28 %pmoprighi | did -ra prot 29 %pmopsec 
    if (%pmdeop) { did -c prot 30 } | else { did -b prot 31,32 }
    did -ra prot 31 %pmdeoprighi | did -ra prot 32 %pmdeopsec 
    if (%pmk) { did -c prot 33 } | else { did -b prot 34,35 }
    did -ra prot 34 %pmkrighi | did -ra prot 35 %pmksec 
    if (%pmban) { did -c prot 36 } | else { did -b prot 37,38 }
    did -ra prot 37 %pmbanrighi | did -ra prot 38 %pmbansec 
    if (%pserverop) { did -c prot 40 } | if (%bitchmode) { did -c prot 41 }

    if (%pftxtp) { did -c prot 44 } | else { did -b prot 45,46 }
    did -ra prot 45 %pftxtprighi | did -ra prot 46 %pftxtpsec 
    if (%pfnotp) { did -c prot 47 } | else { did -b prot 48,49 }
    did -ra prot 48 %pfnotprighi | did -ra prot 49 %pfnotpsec 
    if (%pfactp) { did -c prot 50 } | else { did -b prot 51,52 }
    did -ra prot 51 %pfactprighi | did -ra prot 52 %pfactpsec 
    if (%pfinvp) { did -c prot 53 } | else { did -b prot 54,55 }
    did -ra prot 54 %pfinvprighi | did -ra prot 55 %pfinvpsec
    if (%pfctcpp) { did -c prot 56 } | else { did -b prot 57,58 }
    did -ra prot 57 %pfctcpprighi | did -ra prot 58 %pfctcppsec
    if (%ignoreavvisafine) { did -c prot 67 } | did -ra prot 66 %ignoreflood
    if (%antiban) { did -c prot 60 } | if (%bitchquery) { did -c prot 63 }
    if (%bword) { did -c prot 68 } | if (%caps.prot) { did -c prot 69 } | if (%antispam) { did -c prot 70 }
    unset %guidaProt
  }
  if ($devent == sclick) {
    if ($did == 4) { if ($did(prot,4).state == 1) { .enable #FLDTESTO | set %pft on | did -e prot 5,6  } | else { .disable #FLDTESTO | unset %pft | did -b prot 5,6 } }
    if ($did == 7) { if ($did(prot,7).state == 1) { .enable #FLDNOTICE | set %pfnot on | did -e prot 8,9  } | else { .disable #FLDNOTICE | unset %pfnot | did -b prot 8,9 } }
    if ($did == 10) { if ($did(prot,10).state == 1) { .enable #FLDACTION | set %pfact on | did -e prot 11,12  } | else { .disable #FLDACTION | unset %pfact | did -b prot 11,12 } }
    if ($did == 13) { if ($did(prot,13).state == 1) { .enable #FLDNICK | set %pfnk on | did -e prot 14,15  } | else { .disable #FLDNICK | unset %pfnk | did -b prot 14,15 } }
    if ($did == 16) { if ($did(prot,16).state == 1) { .enable #FLDJOIN | set %pfj on | did -e prot 17,18  } | else { .disable #FLDJOIN | unset %pfj | did -b prot 17,18 } }
    if ($did == 19) { if ($did(prot,19).state == 1) { .enable #FLDTOPIC | set %pftp on | did -e prot 20,21  } | else { .disable #FLDTOPIC | unset %pftp | did -b prot 20,21 } }
    if ($did == 22) { if ($did(prot,22).state == 1) { .enable #FLDMODE | set %pfmd on | did -e prot 23,24  } | else { .disable #FLDMODE | unset %pfmd | did -b prot 23,24 } }
    if ($did == 27) { if ($did(prot,27).state == 1) { .enable #MASSOP | set %pmop on | did -e prot 28,29  } | else { .disable #MASSOP | unset %pmop | did -b prot 28,29 } }
    if ($did == 30) { if ($did(prot,30).state == 1) { .enable #MASSDEOP | set %pmdeop on | did -e prot 31,32  } | else { .disable #MASSDEOP | unset %pmdeop | did -b prot 31,32 } }
    if ($did == 33) { if ($did(prot,33).state == 1) { .enable #MASSKICK | set %pmk on | did -e prot 34,35  } | else { .disable #MASSKICK | unset %pmk | did -b prot 34,35 } }
    if ($did == 36) { if ($did(prot,36).state == 1) { .enable #MASSBAN | set %pmban on | did -e prot 37,38  } | else { .disable #MASSBAN | unset %pmban | did -b prot 37,38 } }
    if ($did == 40) { if ($did(prot,40).state == 1) { set %pserverop on } | else { unset %pserverop } }
    if ($did == 41) { if ($did(prot,41).state == 1) { set %bitchmode on } | else { unset %bitchmode } }

    if ($did == 44) { if ($did(prot,44).state == 1) { .enable #PFLDTESTO | set %pftxtp on | did -e prot 45,46  } | else { .disable #PFLDTESTO | unset %pftxtp | did -b prot 45,46 } }
    if ($did == 47) { if ($did(prot,47).state == 1) { .enable #PFLDNOTICE | set %pfnotp on | did -e prot 48,49  } | else { .disable #PFLDNOTICE | unset %pfnotp | did -b prot 48,49 } }
    if ($did == 50) { if ($did(prot,50).state == 1) { .enable #PFLDACTION | set %pftactp on | did -e prot 51,52  } | else { .disable #PFLDACTION | unset %pfactp | did -b prot 51,52 } }
    if ($did == 53) { if ($did(prot,53).state == 1) { .enable #PFLDINVITE | set %pfinvp on | did -e prot 54,55  } | else { .disable #PFLDINVITE | unset %pfinvp | did -b prot 54,55 } }   
    if ($did == 56) { if ($did(prot,56).state == 1) { .enable #PFLDCTCP | set %pfctcpp on | did -e prot 57,58  } | else { .disable #PFLDCTCP | unset %pfctcpp | did -b prot 57,58 } }   
    if ($did == 60) { if ($did(prot,60).state == 1) { set %antiban on } | else { unset %antiban } }   

    if ($did == 63) { if ($did(prot,63).state == 1) { set %bitchquery on } | else { unset %bitchquery } }
    if ($did == 67) { if ($did(prot,67).state == 1) { set %ignoreavvisafine on } | else { unset %ignoreavvisafine } }
    if ($did == 67) { if ($did(prot,67).state == 1) { set %ignoreavvisafine on } | else { unset %ignoreavvisafine } }   
    if ($did == 68) { if ($did(prot,68).state == 1) { set %bword on } | else { unset %bword } }    
    if ($did == 69) { if ($did(prot,69).state == 1) { set %caps.prot on } | else { unset %caps.prot } }

    if ($did == 70) { if ($did(prot,70).state == 1) { set %antispam on } | else { unset %antispam } }
    if ($did == 79) { if ($did(78) != $null) { write sistema\antispam.txt $did(78) | did -r prot 78 |  caricaantispam } }
    if ($did == 80) { if ($did(81).sel != $null) { write -dl $+ $calc($did(81).sel - 1) sistema\antispam.txt | caricaantispam } }  
    if ($did == 101) { if (%guidaProt) { did -ra $dname 101 Guida >> | guidainProt } | else { did -ra $dname 101 Guida << | guidaoutProt } }  
    if ($did == 102) { dialog -m protavanzate protavanzate }
    if ($did == 500) { did -r $dname 82 | var %rigo = 1 | while $lines(dati\guide\protchan.txt) >= %rigo { did -az prot 82 $read -l $+ %rigo dati\guide\protchan.txt | inc %rigo } }
    if ($did == 501) { did -r $dname 82 | var %rigo = 1 | while $lines(dati\guide\protpers.txt) >= %rigo { did -az prot 82 $read -l $+ %rigo dati\guide\protpers.txt | inc %rigo } }
  }
  if ($devent == edit) {
    if ($did == 5) { set %pftrighi $did(prot,5).text }
    if ($did == 6) { set %pftsec $did(prot,6).text }
    if ($did == 8) { set %pfnotrighi $did(prot,8).text }
    if ($did == 9) { set %pfnotsec $did(prot,9).text }
    if ($did == 11) { set %pfactrighi $did(prot,11).text }
    if ($did == 12) { set %pfactsec $did(prot,12).text }
    if ($did == 14) { set %pfnkrighi $did(prot,14).text }
    if ($did == 15) { set %pfnksec $did(prot,15).text }
    if ($did == 17) { set %pfjrighi $did(prot,17).text }
    if ($did == 18) { set %pfjsec $did(prot,18).text }
    if ($did == 20) { set %pftprighi $did(prot,20).text }
    if ($did == 21) { set %pftpsec $did(prot,21).text }
    if ($did == 23) { set %pfmdrighi $did(prot,23).text }
    if ($did == 24) { set %pfmdsec $did(prot,24).text }
    if ($did == 28) { set %pmoprighi $did(prot,28).text }
    if ($did == 29) { set %pmopsec $did(prot,29).text }
    if ($did == 31) { set %pmdeoprighi $did(prot,31).text }
    if ($did == 32) { set %pmdeopsec $did(prot,32).text }
    if ($did == 34) { set %pmkrighi $did(prot,34).text }
    if ($did == 35) { set %pmksec $did(prot,35).text }
    if ($did == 37) { set %pmbanrighi $did(prot,37).text }
    if ($did == 38) { set %pmbansec $did(prot,38).text }
    if ($did == 45) { set %pftxtprighi $did(prot,45).text }
    if ($did == 46) { set %pftxtpsec $did(prot,46).text }
    if ($did == 48) { set %pfnotprighi $did(prot,48).text }
    if ($did == 49) { set %pfnotpsec $did(prot,49).text }  
    if ($did == 51) { set %pfactprighi $did(prot,51).text }
    if ($did == 52) { set %pfactpsec $did(prot,52).text }  
    if ($did == 54) { set %pfinvprighi $did(prot,54).text }
    if ($did == 55) { set %pfinvpsec $did(prot,55).text }  
    if ($did == 57) { set %pfctcpprighi $did(prot,57).text }
    if ($did == 58) { set %pfctcppsec $did(prot,58).text }  
    if ($did == 66) { set %ignoreflood $did(prot,66).text }  
  }
}
alias guidainProt { 
  unset %guidaProt | var %guidainProtX 500 | :diminuisci 
  if (%guidainProtX > 350) { dialog -s Prot -1 -1 %guidainProtX 240 | dec %guidainProtX | goto diminuisci } | else { halt }
}

alias guidaoutProt { 
  set %guidaProt on | var %guidaoutProtX 350 | :incrementa 
  if (%guidaoutProtX < 500) { dialog -s Prot -1 -1 %guidaoutProtX 240 | inc %guidaoutProtX | goto incrementa } | else { halt }
}
dialog protavanzate {
  title "Settaggi avanzati per il canale"
  size -1 -1 330 170
  box "Punizione per",1, 5 1 165 65 
  text "Flood", 2,13 20 40 19
  combo 3, 70 15 95 50,drop,size
  text "Mass Action", 4, 13 43 60 19
  combo 5, 70 38 95 50,drop,size

  box "Parole Proibite", 6, 175 1 150 140
  edit "",7, 180 15 95 19,autohs
  button "+", 8, 278 15 20 19
  button "-",9, 298 15 20 19
  list 10, 178 40 140 95,size
  box "Livello Protezioni", 11, 5 67 165 41
  text "Seleziona", 12, 10 87 70 19
  combo 13, 70 82 95 50,drop,size
  box "Esenta dalle protezioni", 14, 5 108 165 33
  check "Operatori", 15, 10 120 80 19
  check "Voices",16, 100 120 60 19
  button "&Chiudi", 100,120 147 90 19,ok
}
on *:dialog:protavanzate:*:*:{
  if ($devent == init) {
    mdxbegin
    mdx SetFont 1,6,11,14 12 700 Tahoma
    mdx SetFont 2,3,4,5,7,8,9,10,12,13,15,16,100 12 400 Tahoma 
    mdx SetBorderStyle 8,9,100 staticedge
    mdx SetControlMDX 10 Listview report rowselect icon grid showsel single labeltip headerdrag  > sistema\dlls\views.mdx
    did -i protavanzate 10 1 headerdims 120:1 | did -i protavanzate 10 1 headertext + 0 Lista: | caricabword

    if (%pena == kick) { did -a protavanzate 3 kick | did -a protavanzate 3 bantemporaneo | did -a protavanzate 3 perban | did -c protavanzate 3 1 }
    if (%pena == bantemporaneo) { did -a protavanzate 3 bantemporaneo | did -a protavanzate 3 perban | did -a protavanzate 3 kick | did -c protavanzate 3 1 }
    if (%pena == perban) { did -a protavanzate 3 perban | did -a protavanzate 3 kick | did -a protavanzate 3 bantemporaneo | did -c protavanzate 3 1 }
    if (%pena2 == kick) { did -a protavanzate 5 kick | did -a protavanzate 5 bantemporaneo | did -a protavanzate 5 perban | did -c protavanzate 5 1 }
    if (%pena2 == bantemporaneo) { did -a protavanzate 5 bantemporaneo | did -a protavanzate 5 perban | did -a protavanzate 5 kick | did -c protavanzate 5 1 }
    if (%pena2 == perban) { did -a protavanzate 5 perban | did -a protavanzate 5 kick | did -a protavanzate 5 bantemporaneo | did -c protavanzate 5 1 }

    if (%plivello == permissivo) { did -a protavanzate 13 permissivo | did -a protavanzate 13 normale | did -a protavanzate 13 dispostico | did -c protavanzate 13 1 }
    if (%plivello == normale) { did -a protavanzate 13 normale | did -a protavanzate 13 dispotico | did -a protavanzate 13 permissivo | did -c protavanzate 13 1 }
    if (%plivello == dispostico) { did -a protavanzate 13 dispotico | did -a protavanzate 13 permissivo | did -a protavanzate 13 normale | did -c protavanzate 13 1 }
    if (%esentaop) { did -c protavanzate 15 } | if (%esentavoice) { did -c protavanzate 16 }
  }
  if ($devent == sclick) {
    if ($did == 3) { set %pena $did(protavanzate,3).seltext } 
    if ($did == 5) { set %pena2 $did(protavanzate,5).seltext }
    if ($did == 8) { if ($did(7) != $null) { write sistema\bword.txt $did(7) | did -r protavanzate 7 |  caricabword } }
    if ($did == 9) { if ($did(10).sel != $null) { write -dl $+ $calc($did(10).sel - 1) sistema\bword.txt | caricabword } }  
    if ($did == 13) { set %plivello $did(protavanzate,13).seltext | livelloprot }
    if ($did == 15) { if ($did(protavanzate,15).state == 1) { set %esentaop on } | else { unset %esentaop } }
    if ($did == 16) { if ($did(protavanzate,16).state == 1) { set %esentavoice on } | else { unset %esentavoice } }
  }
}
alias bword { 
  if ($me isop $chan) {
    if (%bword == $null) { return $1- | halt }
    set %rigoword 1 | :uffa
    if ($lines(sistema\bword.txt) >= %rigoword) {
      if ($read(sistema\bword.txt,%rigoword) isin $1-) { kick $chan $nick La parola menzionata  è una parola proibita! } | else { inc %rigoword | goto uffa }
    }
  }  
  return $1-
}
alias caricabword { did -r protavanzate 10 1 | var %i = 1 | while $lines(sistema\bword.txt) >= %i { did -a protavanzate 10 1 $read(sistema\bword.txt,%i) | inc %i } }
alias caricaantispam { did -r prot 81 1 | var %i = 1 | while $lines(sistema\antispam.txt) >= %i { did -a prot 81 1 $read(sistema\antispam.txt,%i) | inc %i } }

<GROUPS>
#FLDTESTO off
on @*:TEXT:*:#: {
  if ($nick == $me) { halt }
  if (%esentaop) && ( $nick isop $chan ) { halt }
  if (%esentavoice) && ( $nick isvo $chan ) { halt }
  inc %txtinc [ $+ [ $nick ] ] | .timerftxt 1 %pftsec unset %txtinc [ $+ [ $nick ] ]
  if (%txtinc [ $+ [ $nick ] ] == %pftrighi) { unset %txtinc [ $ + [ $nick ] ] | punisci  }
}
#FLDTESTO end

#FLDNOTICE off
on @*:NOTICE:*:#: {
  if ($nick == $me) { halt }
  if (%esentaop) && ( $nick isop $chan ) { halt }
  if (%esentavoice) && ( $nick isvo $chan ) { halt }
  inc %notinc [ $+ [ $nick ] ] | .timerfnot 1 %pfnotsec unset %notinc [ $+ [ $nick ] ]
  if (%notinc [ $+ [ $nick ] ]  == %pfnotrighi) { unset %notinc [ $+ [ $nick ] ] | punisci }
}
#FLDNOTICE end

#FLDACTION off
on @*:ACTION:*:#: {
  if ($nick == $me) { halt }
  if (%esentaop) && ( $nick isop $chan ) { halt }
  if (%esentavoice) && ( $nick isvo $chan ) { halt }
  inc %actinc [ $+ [ $nick ] ]  | .timerfact 1 %pfactsec unset %actinc [ $+ [ $nick ] ]
  if (%actinc [ $+ [ $nick ] ] == %pfactrighi) { unset %actinc [ $ + [ $nick ] ] | punisci }
}
#FLDACTION end

#FLDNICK off
on !*:NICK: {
  if ($nick == $me) { halt }
  if (%esentaop == on) && ( $nick isop $chan ) { halt }
  if (%esentavoice == on) && ( $nick isvo $chan ) { halt }
  inc %nkinc [ $+ [ $address ] ] | .timerfnk 1 %pfnksec unset %nkinc [ $+ [ $address ] ]
  if (%nkinc [ $+ [ $address ] ] > %pfnkrighi) { 
    set %nk1 $comchan($newnick,0) | unset %nk | :wewe | inc %nk      
    if (%nk > %nk1) { unset %nk %nk1 | halt }    
    if ($me isop $comchan($newnick,%nk)) { 
      if (%pena = kick) { unset %nkinc [ $+ [ $address ] ] | kick $comchan($newnick,%nk) $newnick  }
      if (%pena = bantemporaneo) { unset %nkinc [ $+ [ $address ] ] | ban -u30 $comchan($newnick,%nk) $newnick 2 |  kick $comchan($newnick,%nk) $newnick }
      if (%pena = perban) { unset %nkinc [ $+ [ $address ] ] | ban $comchan($newnick,%nk) $newnick 2 |  kick $comchan($newnick,%nk) $newnick }
    }      
    goto wewe  
  }    
}
#FLDNICK end

#FLDJOIN off
on @*:JOIN:#:{
  if ($nick == $me) { halt }
  if (%esentaop == on) && ( $nick isop $chan ) { halt }
  if (%esentavoice == on) && ( $nick isvo $chan ) { halt }
  inc %joininc [ $+ [ $nick ] ]  
  .timerfj 1 %pfjsec unset %joininc [ $+ [ $nick ] ]
  if (%joininc [ $+ [ $nick ] ] == %pfjrighi) { unset %joininc [ $+ [ $nick ] ] | punisci }
}
#FLDJOIN end

#FLDTOPIC off
on @*:TOPIC:#: {
  if ($nick == $me) { halt }
  if (%esentaop == on) && ( $nick isop $chan ) { halt }
  if (%esentavoice == on) && ($nick isvo $chan) { halt }
  inc %tpinc [ $+ [ $nick ] ] | .timerftp 1 %pftpsec unset %tpinc [ $+ [ $nick ] ]
  if (%tpinc [ $+ [ $nick ] ] == %pftprighi) { unset %tpinc [ $+ [ $nick ] ] | punisci }   
}
#FLDTOPIC end

#FLDMODE off
on @*:MODE:#: {
  if ($nick == $me)  { halt }
  if (%esentaop == on) && ( $nick isop $chan ) { halt }
  if (%esentavoice == on) && ($nick isvo $chan) { halt }
  inc %pfmdinc [ $+ [ $nick ] ] | .timerfmd 1 %pfmdsec unset %pfmdinc [ $+ [ $nick ] ]
  if (%pfmdinc [ $+ [ $nick ] ] == %pfmdrighi) { unset %pfmdinc [ $+ [ $nick ] ] | punisci }   
}
#FLDMODE end

#MASSOP off
on @*:OP:#:{
  if ($nick == $me) { halt }
  inc %pmopinc [ $+ [ $nick ] ]  
  .timermassop 1 %pmopsec unset %pmopinc [ $+ [ $nick ] ]
  if (%pmopinc [ $+ [ $nick ] ] == %pmoprighi) { unset %pmopinc [ $+ [ $nick ] ] | punisci2  }  
}
#MASSOP end

#MASSDEOP off
on @*:DEOP:#:{
  if ($nick == $me) { halt }
  inc %pmdeopinc [ $+ [ $nick ] ]  
  .timermassdeop 1 %pmdeopsec unset %pmdeopinc [ $+ [ $nick ] ]
  if (%pmopinc [ $+ [ $nick ] ] == %pmdeoprighi) { unset %pmdeopinc [ $+ [ $nick ] ] | punisci2  }  
}
#MASSDEOP end

#MASSKICK off
on @*:KICK:#:{
  if ($nick == $me) { halt }
  inc %pmkinc [ $+ [ $nick ] ] | .timermasskick 1 %pmksec unset %pmkinc [ $+ [ $nick ] ]
  if %pmkinc [ $+ [ $nick ] ] == %pmkrighi { unset %pmkinc [ $+ [ $nick ] ] | punisci2 }
}
#MASSKICK end

#MASSBAN off
on @1!:BAN:#:{
  if ($nick == $me) { halt }
  inc %pmbaninc [ $+ [ $nick ] ] | .timer 1 %pmbansec unset %pmbaninc [ $+ [ $nick ] ]
  if (%pmbaninc [ $+ [ $nick ] ] == %pmbanrighi) { unset %pmbaninc [ $+ [ $nick ] ] | punisci2 }  
}
#MASSBAN end
</GROUPS>
<ALTRE PROTEZIONI>
on @*:SERVEROP:#:if (($nick != $me) && (%pservop)) { kick $chan $opnick Server Op Rilevato - %pic }
on @*:OP:#:if (($nick != $me) && (%bitchmode)) { mode # -o $opnick }
</ALTRE PROTEZIONI>

alias punisci {
  if (%pena == kick) { kick $chan $nick %pic }
  if (%pena == bantemporaneo) { ban -u30  $chan $nick 2 | kick $chan $nick Ban Per 30 Sec. %pic  }
  if (%pena == perban) { ban $chan $nick 2 | kick $chan $nick Bannato! %pic }
}
alias punisci2 {
  if (%pena2 == kick) { kick $chan $nick %pic }
  if (%pena2 == bantemporaneo) { ban -u30  $chan $nick 2 | kick $chan $nick Ban Per 30 Sec. %pic  }
  if (%pena2 == perban) { ban $chan $nick 2 | kick $chan $nick Bannato! %pic }
}

#PFLDTESTO off
on *:text:*:?: {
  inc %ppftinc [ $+ [ $nick ] ]
  .timer 1 %pftxtpsec unset %ppftinc [ $+ [ $nick ] ]
  if (%ppftinc [ $+ [ $nick ] ] == %pftxtprighi) {
    unset %ppftinc [ $+ [ $nick ] ] | close -m $nick | .ignore -u $+ %ignoreflood $nick 2
    .notice $nick Query Text Flood - Inutile che continui a scrivere, sei in ignore per %ignoreflood secondi! %script
    echo 4 -a %prefisso Tentato flood di  testo da parte di $nick ( $+ $address $+ ). Sarà ignorato per %ignoreflood secondi 
    if (%ignoreavvisafine) { .timer 1 %ignoreflood notice $nick 4[Auto Info4] Non Sei Più in Ignore, adesso non scrivere troppo %script }
  }
}
#PFLDTESTO end

#PFLDNOTICE off
on *:notice:*:?: {
  inc %ppfnotinc [ $+ [ $nick ] ]
  .timer 1 %pfnotpsec unset %ppfnotinc [ $+ [ $nick ] ]
  if (%ppfnotinc [ $+ [ $nick ] ] == %pfnotprighi) {
    unset %ppfnotinc [ $+ [ $nick ] ] | close -m $nick | .ignore -u $+ %ignoreflood $nick 2
    .notice $nick Query Notice Flood - Inutile che continui a scrivere, sei in ignore per %ignoreflood secondi! %script
    echo 4 -a %prefisso Tentato flood di  notice da parte di $nick ( $+ $address $+ ). Sarà ignorato per %ignoreflood secondi 
    if (%ignoreavvisafine) { .timer 1 %ignoreflood notice $nick 4[Auto Info4] Non Sei Più in Ignore, adesso non scrivere troppo %script }
  }
}
#PFLDNOTICE end

#PFLDACTION off
on *:action:*:?: {
  inc %ppfactinc [ $+ [ $nick ] ]
  .timer 1 %pfactpsec unset %ppfactinc [ $+ [ $nick ] ]
  if (%ppfactinc [ $+ [ $nick ] ] == %pfactprighi) {
    unset %ppfactinc [ $+ [ $nick ] ] | close -m $nick | .ignore -u $+ %ignoreflood $nick 2
    .notice $nick Query Action Flood - Inutile che continui a scrivere, sei in ignore per %ignoreflood secondi! %script
    echo 4 -a %prefisso Tentato flood di action da parte di $nick ( $+ $address $+ ). Sarà ignorato per %ignoreflood secondi 
    if (%ignoreavvisafine) { .timer 1 %ignoreflood notice $nick 4[Auto Info4] Non Sei Più in Ignore, adesso non scrivere troppo %script }
  }
}
#PFLDACTION end

#PFLDINVITE off
on *:invite:#: {
  inc %ppfinvinc [ $+ [ $nick ] ]
  .timer 1 %pfinvpsec unset %ppfinvinc [ $+ [ $nick ] ]
  if (%ppfinvinc [ $+ [ $nick ] ] == %pfinvprighi) {
    unset %ppfinvinc [ $+ [ $nick ] ] | close -m $nick | .ignore -u $+ %ignoreflood $nick 2
    .notice $nick Invite Flood - Inutile che continui a scrivere, sei in ignore per %ignoreflood secondi! %script
    echo 4 -a %prefisso Tentato flood di invite da parte di $nick ( $+ $address $+ ). Sarà ignorato per %ignoreflood secondi 
    if (%ignoreavvisafine) { .timer 1 %ignoreflood notice $nick 4[Auto Info4] Non Sei Più in Ignore, adesso non scrivere troppo %script }
  }
}
#PFLDINVITE end

#PFLDCTCP off
ctcp *:*:?: { 
  inc %ppfctcpinc [ $+ [ $nick ] ]
  .timer 1 %pfctcppsec unset %ppfctcpinc [ $+ [ $nick ] ]
  if (%ppfctcpinc [ $+ [ $nick ] ] == %pfctcpprighi) {
    unset %ppfctcpinc [ $+ [ $nick ] ] | close -m $nick | .ignore -u $+ %ignoreflood $nick 2
    .notice $nick Ctcp Flood - Inutile che continui a scrivere, sei in ignore per %ignoreflood secondi! %script
    echo 4 -a %prefisso Tentato flood di CTCP da parte di $nick ( $+ $address $+ ). Sarà ignorato per %ignoreflood secondi 
    if (%ignoreavvisafine) { .timer 1 %ignoreflood notice $nick 4[Auto Info4] Non Sei Più in Ignore, adesso non scrivere troppo %script }
  }
}
#PFLDINVITE end

on @*:ban:#:{
  if (%antiban) {
    if ($nick == $me) { halt }
    if ($bnick == $me) { mode $chan -ob $nick $banmask | kick $chan $nick NO BAN ME %script | goto end }
    if ($address($me,0) iswm $banmask) { mode $chan -ob $nick $banmask | kick $chan $nick No Ban $address($me,0) %script  | goto end }
    if ($address($me,1) iswm $banmask) { mode $chan -ob $nick $banmask | kick $chan $nick No Ban $address($me,1) %script  | goto end }
    if ($address($me,2) iswm $banmask) { mode $chan -ob $nick $banmask | kick $chan $nick No Ban $address($me,2) %script  | goto end }
    if ($address($me,3) iswm $banmask) { mode $chan -ob $nick $banmask | kick $chan $nick No Ban $address($me,3) %script  | goto end }
    if ($address($me,4) iswm $banmask) { mode $chan -ob $nick $banmask | kick $chan $nick No Ban $address($me,4) %script  | goto end }
    if ($address($me,5) iswm $banmask) { mode $chan -ob $nick $banmask | kick $chan $nick No Ban $address($me,5) %script  | goto end }
    if ($address($me,6) iswm $banmask) { mode $chan -ob $nick $banmask | kick $chan $nick No Ban $address($me,6) %script  | goto end }
    if ($address($me,7) iswm $banmask) { mode $chan -ob $nick $banmask | kick $chan $nick No Ban $address($me,7) %script  | goto end }
    if ($address($me,8) iswm $banmask) { mode $chan -ob $nick $banmask | kick $chan $nick No Ban $address($me,8) %script  | goto end }
    if ($address($me,9) iswm $banmask) { mode $chan -ob $nick $banmask | kick $chan $nick No Ban $address($me,9) %script  | goto end }
    :end
  }
}
on 1:OPEN:?:*:{ 
  if (%bitchquery) { close -m $nick | .notice $nick Mi Dispiace Ma Non Accetto Più Query Ciao :) %script | goto end } 
  if (%antispam) { set %spam $1- | antispam }
  :end
}
alias antispam { 
  set %rigospam 1 | :uffa
  if ($lines(sistema\antispam.txt) >= %rigospam) {
    if ($read(sistema\antispam.txt,%rigospam) isin %spam) && (www.mircscript.it !isin %spam) { .notice $nick l'unico spam che accetto è quello del %script $+ , scaricalo ora da www.mircscript.it | close -m $nick | .ignore -u30 $nick | set %notextspam %spam } | else { inc %rigospam | goto uffa }
  }
}
alias caps { 
  unset %capsnum | var %i = 1 | while $len($1-) >= %i { if ($mid($1-,%i,1) isletter ABCDEFGHILMNOPQRSTUVZWYJKX) { inc %capsnum } | inc %i }
  return $calc(%capsnum * 100 / $len($1-))
}
alias livelloprot {
  if (%plivello == permissivo) { set %livellorighi 10 | set %livellosec 3 | modprot }
  if (%plivello == normale) { set %livellorighi 7 | set %livellosec 5 | modprot }
  if (%plivello == dispotico) { set %livellorighi 3 | set %livellosec 3 | modprot }
}
alias modprot {
  set  %pftrighi %livellorighi | set %pftsec %livellosec | did -ra prot 5 %pftrighi | did -ra prot 6 %pftsec 
  set  %pfnotrighi %livellorighi | set %pfnotsec %livellosec |  did -ra prot 8 %pfnotrighi | did -ra prot 9 %pfnotsec 
  set  %pfactrighi %livellorighi | set %pfactsec %livellosec | did -ra prot 11 %pfactrighi | did -ra prot 12 %pfactsec 
  set  %pfnkrighi %livellorighi | set %pfnksec %livellosec | did -ra prot 14 %pfnkrighi | did -ra prot 15 %pfnksec 
  set  %pfjrighi %livellorighi | set %pfjsec %livellosec | did -ra prot 17 %pfjrighi | did -ra prot 18 %pfjsec 
  set  %pftprighi %livellorighi | set %pftpsec %livellosec | did -ra prot 20 %pftprighi | did -ra prot 21 %pftpsec 
  set  %pfmdrighi %livellorighi | set %pfmdsec %livellosec | did -ra prot 23 %pfmdrighi | did -ra prot 24 %pfmdsec 
  set  %pmoprighi %livellorighi | set %pmopsec %livellosec | did -ra prot 28 %pmoprighi | did -ra prot 29 %pmopsec 
  set  %pmdeoprighi %livellorighi | set %pmdeopsec %livellosec | did -ra prot 31 %pmdeoprighi | did -ra prot 32 %pmdeopsec 
  set  %pmkrighi %livellorighi | set %pmksec %livellosec | did -ra prot 34 %pmkrighi | did -ra prot 35 %pmksec 
  set  %pmbanrighi %livellorighi | set %pmbansec %livellosec | did -ra prot 37 %pmbanrighi | did -ra prot 38 %pmbansec 
}
</PROTEZIONI>
