;;;;Buzz-Zyrus SoulFly Multi-Gamer by d33j4y™  ©2010 EvolutionScriptz d0t c0m;;;;
;;;;;;;;;;;;Evolution Scriptz Website http://www.evolutionscriptz.com;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;SoulFly Protections by Travis;;;;;;;;;;;;;;;;;;;;;;;;;;

on *:start:{
  writeini soulfly.ini version $nopath($script) 1.5c3 | unset %schk.*
  if (%skick == $null) { set %skick -u11 }
}
on *:unload:remini soulfly.ini version $nopath($script)
on @!*:join:#:{
  if ($hget(prot,$+(all.,$gettok($address,1,64)))) return
  if ($hget(prot,$+(ban.,$gettok($address,1,64)))) && (# isin $hget(prot,banlist)) {
    qban $nick # $address BanList
    axis_find $nick $+(*!*,$right($address,-24)) $chan -k BanList
  }
  if (%hop. [ $+ [ # ] ] [ $+ [ . [ $+ [ $nick ] ] ] ] > 2) { qban $nick # $address hopflood | return }
  var %jn = $hget(prot,#), %jf = $numtok(%jn,44)
  if (%jf == 4) { q_ sockwrite -n $+(sf.,#) kick # $nick Flood | return }
  elseif (# isin $hget(prot,joinflood)) hadd -u3 prot # $addtok(%jn,$nick,44)
  if (%jf == 3) {
    .timerscript* off
    mode # +P
    sockwrite -n $+(sf.,#) access # add deny $iif(@guest isin $address,*!*@GuestGate*,*!*@*) 2 $+(:JoinFlood,$crlf,kick) # $nick Flood
    sockwrite -n $+(sf.,#) kick # $gettok(%jn,1,44) $+(Flood,$crlf,kick) # $gettok(%jn,2,44) $+(Flood,$crlf,kick) # $gettok(%jn,3,44) Flood
    .timermodeP 1 120 /mode # -P
    return
  }
  elseif (# isin $hget(prot,hopflood)) inc -u4 %hop. [ $+ [ # ] ] $+ . $+ $nick
  if (# !isin $hget(prot,scriptchk)) return
  sockwrite -n $+(sf.,$chan) PRIVMSG $chan $nick :TIME
  set %schk. [ $+ [ $nick ] ] $true
  $+(.timerscript,$nick) 1 $right(%skick,-2) /kscript $nick $chan
}
on @!*:part:#:.timerscript* off
on !@*:topic:#:{
  if (# !isin $hget(prot,topiclock)) || ($hget(prot,$+(all.,$gettok($address,1,64)))) return
  axis_find $nick $address($nick,3) # -bk TopicLock© | topic # $readini(soulfly.ini,topic,#)
}
on *:NOTICE:*:*:{
  if ($timer($+(script,$nick))) $+(.timerscript,$nick) off
  if (TIME isin $1) && ($numtok($1,2) = 2) {
    if (($right($1,3) isletter) || ($6 = $asctime(yyyy)) || ($2 isletter) || ( $len($2) = 3) || ($3 isnum) || ($len($3) < 3) || ($len($4) = 8) || ($gettok($4,3,58)) || ($left($5,3) = GMT) || ($len($4) = 8)) return
    else kscript $nick #
  }
  elseif (%schk. [ $+ [ $nick ] ]) kscript $nick #
}
on @*:text:*[br]*:#:{
  if (# !isin $hget(prot,blankflood)) || ($nick isop #) || ($hget(prot,$+(all.,$gettok($address,1,64)))) return
  if (%blank. [ $+ [ $nick ] ] > 2) { qban $nick # $address BlankFlood | return }
  var %cbr = $count($1-,[br])
  if ($1- = [br]) inc -u5 %blank. [ $+ [ $nick ] ]
  if (%cbr > 1) && ($remove($1-,[br]) = $null) qban $nick # $address BlankFlood
  elseif (%cbr > 4) q_ qban $nick # $address BlankFlood
}
on @*:text:*:#:{
  if ($hget(prot,$+(all.,$gettok($address,1,64)))) || ($nick isop #) return
  if (%txt. [ $+ [ # ] ] [ $+ [ . [ $+ [ $nick ] ] ] ] > 6) { qban $nick # $address textflood | return }
  if (# isin $hget(prot,emoteflood)) {
    if (%emote. [ $+ [ $nick ] ] > 2) { qban $nick # $address emoteflood | return }
    ;thanks to av0ider for regex
    var %tf = /([\(:\-\|~{].+?|.+?\))/g, %tfx = $regex($1-,%tf)
    if (%tfx > 25) { qban $nick # $address emoteflood | return }
    elseif (%tfx > 4) { inc -u3 %emote. [ $+ [ $nick ] ] }
  }
  if (# isin $hget(prot,urlkick)) && ($regex($1-,/(http://|)(www\.)?([^\.]+)\.(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/)) qban $nick # $address urlKick
  if (# isin $hget(prot,textflood)) { inc -u4 %txt. [ $+ [ # ] ] $+ . $+ [ $nick ] }
}
alias kscript {
  if ($1 = time) {
    var %st = $input(Set Seconds To Wait For Response. $crlf $crlf Currently: $right(%skick,-2) seconds,e, $v_ Script Kick)
    if (%st != $null) { set %skick $+(-u,%st) | echo -a 2,9 Script Kick will wait %st seconds for a response.  }
    return
  }
  if (%s_nix) cline 4 $2 $1
  if ($hget(prot,$+(all.,$gettok($ial($$1).addr,1,64)))) return
  if (%scriptchk != kick) $v1 $2 CAUTION! a script has entered the room. ( $1 )
  else axis_find $1 $address($1,3) $2 -bk ScriptKick( $1 )
}
raw 821:*:{
  if ($me !isop $1) || ($nick isop $1) || ($hget(prot,$+(all.,$gettok($address,1,64)))) return
  if ($len($2-) > 80) && ($1 isin $hget(prot,textflood)) inc -u4 %txt. [ $+ [ $1 ] ] $+ . $+ [ $nick ]
  var %aa = $numtok(%away. [ $+ [ $1 ] ],44)
  if (%aa >= 6) { q_ sockwrite -n $+(sf.,$1) kick $1 $nick Away/Return Floods | return }
  elseif ($1 isin $hget(prot,awayflood)) {
    set -u3 %away. [ $+ [ $1 ] ] $addtok(%away. [ $+ [ $1 ] ],$nick,44)
    inc -u4 %away. [ $+ [ $nick ] ]
  }
  if (%aa = 5) {
    sockwrite -n $+(sf.,$1) mode $1 $+(+P,$crlf,access) $1 add deny $iif(@guest isin $address,*!*@GuestGate*,*!*@*) 1 $+(:AwayFlood,$crlf,kick) $1 $nick $+(AwayFlood,$crlf,kick) $1 $gettok(%away. [ $+ [ $1 ] ],1,44) $+(AwayFlood,$crlf,kick) $1 $gettok(%away. [ $+ [ $1 ] ],2,44) $+(AwayFlood,$crlf,kick) $1 $gettok(%away. [ $+ [ $1 ] ],3,44) AwayFlood
    .timermodeP 1 120 /mode $chan -P
    return
  }
  if (%txt. [ $+ [ $1 ] ] $+ . $+ [ $nick ] > 3) || (%away. [ $+ [ $nick ] ] >= 5) qban $nick $1 $address AwayFlood
  halt
}
raw 822:*:{
  if ($me !isop $1) || ($nick isop $1) || ($hget(prot,$+(all.,$gettok($address,1,64)))) return
  if ($len($2-) > 80) && ($1 isin $hget(prot,textflood)) inc -u4 %txt. [ $+ [ $1 ] ] $+ . $+ [ $nick ]
  if ($1 isin $hget(prot,urlkick)) && ($regex($1-,/(http://|)(www\.)?([^\.]+)\.(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/)) qban $nick $1 $address urlKick
  var %aa = $numtok(%away. [ $+ [ $1 ] ],44)
  if (%aa >= 6) { q_ sockwrite -n $+(sf.,$1) kick $1 $nick Away/Return Floods | return }
  elseif ($1 isin $hget(prot,awayflood)) {
    set -u3 %away. [ $+ [ $1 ] ] $addtok(%away. [ $+ [ $1 ] ],$nick,44)
    inc -u4 %away. [ $+ [ $nick ] ]
  }
  if (%aa = 5) {
    sockwrite -n $+(sf.,$1) mode $1 $+(+P,$crlf,access) $1 add deny $iif(@guest isin $address,*!*@GuestGate*,*!*@*) 1 $+(:AwayFlood,$crlf,kick) $1 $nick $+(AwayFlood,$crlf,kick) $1 $gettok(%away. [ $+ [ $1 ] ],1,44) $+(AwayFlood,$crlf,kick) $1 $gettok(%away. [ $+ [ $1 ] ],2,44) $+(AwayFlood,$crlf,kick) $1 $gettok(%away. [ $+ [ $1 ] ],3,44) AwayFlood
    .timermodeP 1 120 /mode $chan -P
    return
  }
  if (%txt. [ $+ [ $1 ] ] $+ . $+ [ $nick ] > 3) || (%away. [ $+ [ $nick ] ] >= 5) qban $nick $1 $address AwayFlood
  halt
}
alias banlist {
  if (!$1-2) return
  var %bn = $+(ban.,$2)
  hpp prot %bn $3
  echo -ac info $3 has been $iif(!$hget(prot,%bn),Removed from,Added to) the Ban List
  if (!$hget(prot,%bn)) || ($me !isop $1) || ($1 !isin $hget(prot,banlist)) return
  qban $3 $1 $2 banlist
}
;--Custom Kick ban dialog(Drafted from Nuclear msn :p)
alias ckb { set %ckb1 $1 | set %ckb2 $2 | dialog -m ckb ckb }
dialog ckb {
  title "Custom Kick/Ban"
  size -1 -1 149 62
  icon $md_icon(w)
  option dbu
  text "Room:" 1, 2 2 15 8
  text "User:" 2, 75 2 15 8
  text "" 3, 2 10 70 8
  text "" 4, 75 10 70 8
  text "Kick Message" 5, 2 21 40 8
  combo 6, 42 20 105 10, autohs drop edit
  check "Ban User" 7, 42 33 32 10
  combo 8, 77 33 70 10, drop, disable
  button "OK" 9, 41 48 35 12, ok
  button "Cancel" 10, 77 48 35 12, cancel
}
on *:dialog:ckb:init:*:{
  didtok ckb 6 44 Disruptive Behavior,Profanity,Scrolling
  didtok ckb 8 44 15 Minutes, 1 Hour,24 Hours,Indefinitely
  did -c ckb 6 1 | did -ra ckb 3 $hcd(%ckb1) | did -ra ckb 4 $bdc(%ckb2)
}
on *:dialog:ckb:sclick:*:{
  if ($did = 7) {
    if ($did(7).state = 1) { did -ec ckb 8 1 | else did -ub ckb 8 }
  }
  elseif ($did = 9) {
    if ($did(7).state = 1) { sockwrite -n $+(sf.,%ckb1) access %ckb1 add deny $address(%ckb2,3) $replace($gettok($did(8).seltext,1,32),Indefinitely,0, 1,60,24,1440) $+(:,$did(6)) }
    sockwrite -n $+(sf.,%ckb1) kick %ckb1 %ckb2 $did(6) $iif($did(7).state = 1,( $+ $iif($gettok($did(8).seltext,1,32) isnum,$ifmatch minute ban,Indefinite Ban) $+ ))
  }
}
on *:dialog:ckb:close:*:unset %ckb*
menu channel {
  $iif($me isop $chan,-)
  $iif($me isop $chan,Protections)
  .Lists Manager $chr(160) $chr(160) S+F4:lists
  .-
  .Script Check
  ..$iif($chan isin $hget(prot,scriptchk),$style(1)) $hget(soulfly,$chan) ( $iif($v1 isin $v2,On,Off) ):{ hpp prot scriptchk $chan }
  ..-
  ..Message Type
  ...$iif(%scriptchk == echo,$style(1)) Echo:{ set %scriptchk echo | echo 2 -a ScriptCheck will ECHO $hget(soulfly,$chan) }
  ...$iif(%scriptchk == describe,$style(1)) Action:{ set %scriptchk describe | echo 2 -a ScriptCheck will Message $hget(soulfly,$chan) }
  ...$iif(%scriptchk == msg,$style(1)) Message:{ set %scriptchk msg | echo 2 -a ScriptCheck will Message $hget(soulfly,$chan) }
  ..-
  ..$str($chr(160),16) $iif(%scriptchk == kick,$style(1)) Kick:{ $iif(%scriptchk == kick,unset,set) %scriptchk kick | echo 2 -a ScriptCheck will kick on $hget(soulfly,$chan) }
  ..-
  ..Time to wait ( $+($right(%skick,-2),s) ):{ kscript time }
  .-
  .$iif($chan isin $hget(prot,banlist),$style(1)) Ban List:hpp prot banlist $chan
  .-
  .$iif($chan isin $hget(prot,mute),$style(1)) Mute:vmute $chan
  .-
  .$iif($chan isin $hget(prot,joinflood),$style(1)) Join Flood:hpp prot joinflood $chan
  .$iif($chan isin $hget(prot,hopflood),$style(1)) Hop Flood:hpp prot hopflood $chan
  .$iif($chan isin $hget(prot,awayflood),$style(1)) Away Flood:hpp prot awayflood $chan
  .$iif($chan isin $hget(prot,emoteflood),$style(1)) Emote Flood:hpp prot emoteflood $chan
  .$iif($chan isin $hget(prot,textflood),$style(1)) Text Flood:hpp prot textflood $chan
  .$iif($chan isin $hget(prot,blankflood),$style(1)) Blank Flood:hpp prot blankflood $chan
  .$iif($chan isin $hget(prot,urlkick),$style(1)) Url Kick:hpp prot urlkick $chan
  .-
  .$iif($chan isin $hget(prot,topiclock),$style(1)) Topic Lock:hpp prot topiclock $chan
  $iif($me isop $chan,-)
}
menu nicklist {
  $iif($me isop $chan,-)
  $iif($$1 != $me && $me isop $chan,Kicks && Bans for $bdc($$1))
  .$iif($hget(prot,$+(ban.,$gettok($ial($$1).addr,1,64))),$style(1)) Ban List:banlist $chan $gettok($ial($$1).addr,1,64) $$1
  .Custom Kick $chr(38) Ban:ckb $chan $$1
  .-
  .$iif($$1 isop $chan,Ban Host):axis_find $$1 $address($$1,3) $chan -bk $$1 Banned by $me
  .Quick Ban:qban $$1 $chan $address($$1,3) $$1 Banned by $me
  .-
  .Profanity:{ sockwrite -n $+(sf.,$chan) kick $chan $$1 Profanity }
  .Scrolling:{ sockwrite -n $+(sf.,$chan) kick $chan $$1 Scrolling }
  .Disruption:{ sockwrite -n $+(sf.,$chan) kick $chan $$1 Disruption }
  -
  $iif($hget(prot,$+(all.,$gettok($ial($$1).addr,1,64))),$style(1)) Allowed Option for $bdc($$1):{ $iif($hget(prot,$+(all.,$gettok($ial($$1).addr,1,64))),hdel,hadd) prot $+(all.,$gettok($ial($$1).addr,1,64)) $$1 }
  -
}
