menu ,menubar {
  -
  BiohazardX kick dialog:{ bio.dialog }
}

alias -l bio {
  return 15.::[12D7]Delux7[12K7]icks15::.
}

alias -l bio.dialog {
  if ($dialog(bio) != $null) { dialog -v bio bio }
  else { dialog -m bio bio }
}

alias -l bio.writefile {
  if ($isfile($scriptdirkdsettings.ini) == $false) { 
  }
  writeini " $+ $scriptdirkdsettings.ini $+ " settings $$1 $$2-
}

alias -l bio.readfile {
  if ($isfile($scriptdirkdsettings.ini) == $true) {
    return $readini($scriptdirkdsettings.ini,settings,$$1) 
  }
  else { return }
}

alias -l bio.kicking {
  ; Provide nickname, channel, and optional kick message.
  ; One alias to provide kicker sevices to all three events.
  ; Attach logo along with the message 
  kick $$1 $$2 $3- $bio
}

dialog bio {
  title "BioHazardX Kicks Main Dialog"
  option dbu
  size -1 -1 205 124
  icon SPbaun12.ico, 0
  button "OKies",5, 120 109 40 12, ok
  button "Quit This",6, 162 109 40 12, cancel

  box "Clone Kicker Options",1, 2 1 60 120
  box "Repeat Kicker Options",2, 64 1 139 30
  box "Caps Kicker Options",3, 64 35 139 25
  box "On / Off Toggle",4, 64 63 54 58

  radio "Kick Only",7, 6 12 35 10, group 1
  radio "KickBan (30 sec)",8, 6 22 50 10
  radio "KickBan (60 sec)",9, 6 32 50 10
  radio "KickBan (5 min)",10, 6 42 47 10
  radio "KickBan (10 Min)",11, 6 52 50 10

  radio "Level Ban 1",12, 6 66 39 10, group 2
  radio "Level Ban 2",13, 6 76 39 10
  radio "Level Ban 3",14, 6 86 39 10
  radio "Level Ban 4",15, 6 96 39 10

  check "bio Them",16, 6 109 42 10

  radio "2 Repeats",17, 69 12 35 10, group 3
  radio "3 Repeats",18, 117 12 35 10
  radio "4 Repeats",19, 162 12 35 10

  radio "30%  ",20, 69 45 27 10, group 4
  radio "50%  ",21, 117 45 27 10
  radio "70%  ",22, 162 45 27 10

  text "On      Off",23, 92 75 30 10
  text "Clone",24, 68 85 30 10
  text "Repeat",25, 68 95 30 10
  text "Caps",26, 68 105 30 10

  radio "",27, 92 85 7 10, group 5
  radio "",28, 108 85 7 10

  radio "",29, 92 95 7 10, group 6
  radio "",30, 108 95 7 10

  radio "",31, 92 105 7 10, group 7
  radio "",32, 108 105 7 10

  text "This is a BioHazard kick system for BioHazardX ",33, 121 65 80 40
}

on *:dialog:bio:init:0: {
  ; Check for file and if doesn't exist, select defaults.
  ; Loop through settings file reading settings.
  ; Identifier to call is $bio.readfile(ID)
  if ($isfile($scriptdirkdsettings.ini) == $false) {
    did -c $dname 7,12,18,21,28,30,32
  }
  var %i = 7
  while (%i <= 32) {
    if ($bio.readfile(%i) == 1) { did -c $dname %i }
    inc %i
  }
}

; Ok Button Event
on *:dialog:bio:sclick:5: {
  ; Run loop through ids to record their settings to the settings file.
  ; Make calls to /bio.writefile ID (1|0)
  var %i = 7
  while (%i <= 32) {
    if ($did($dname,%i).state == 1) { bio.writefile %i 1 }
    else { bio.writefile %i 0 }
    inc %i 
  } 
}

on @*:TEXT:*:#:{
  if ($isfile($scriptdirkdsettings.ini) == $false) || ($nick isop $chan) { return }
  if ($bio.readfile(29) == 1) { bio.repeat $wildsite $chan $nick $1- }
  if ($bio.readfile(31) == 1) { bio.caps $chan $nick $1- }
}


alias -l bio.caps { 
  var %stripped = $remove($strip($3-,burc),$chr(32))
  if ($len(%stripped) <= 6) { return }
  var %i = 1, %counter
  while (%i <= $len(%stripped)) {
    if ($asc($mid(%stripped,%i,1)) isnum 65-90) { inc %counter }
    inc %i 
  }
  var %percentage = $calc((%counter / $len(%stripped)) * 100)
  if ($bio.readfile(20) == 1) { 
    if (%percentage >= 30) { 
      bio.kicking $$1 $$2 Caps Kick: %counter / $len(%stripped) ( $+ $int(%percentage) $+ % $+ ) 
    } 
  }
  elseif ($bio.readfile(21) == 1) { 
    if (%percentage >= 50) { 
      bio.kicking $$1 $$2 Caps Kick: %counter / $len(%stripped) ( $+ $int(%percentage) $+ % $+ ) 
    } 
  }
  elseif ($bio.readfile(22) == 1) { 
    if (%percentage >= 70) { 
      bio.kicking $$1 $$2 Caps Kick: %counter / $len(%stripped) ( $+ $int(%percentage) $+ % $+ ) 
    } 
  }
}


alias -l bio.repeat {
  ; Read what user typed and set temp variables (one for counter and other for text) for 60 seconds.
  ; Check for counter existance and increment for each offense by matching their words to their text variable.
  ; If total reaches maximum, call bio.kicking with number of offenses and message.
  ; Determine setting from file.
  ; Unset users variables
  if (%offender. [ $+ [ $1 ] ] == $null) { 
    set -u60 %offender. [ $+ [ $1 ] ] 1 
    set -u60 %offender2. [ $+ [ $1 ] ] $4- 
  }
  elseif (%offender2. [ $+ [ $1 ] ] == $4-) { inc %offender. [ $+ [ $1 ] ] }
  if (%offender. [ $+ [ $1 ] ] >= 2) {
    if ($bio.readfile(17) == 1) && (%offender. [ $+ [ $1 ] ] == 2) { 
      bio.kicking $$2 $$3 Repeat(s): %offender. [ $+ [ $1 ] ] in 60 Sec(s) 
      unset %offender*. [ $+ [ $1 ] ] 
    }
    if ($bio.readfile(18) == 1) && (%offender. [ $+ [ $1 ] ] == 3) { 
      bio.kicking $$2 $$3 Repeat(s): %offender. [ $+ [ $1 ] ] in 60 Sec(s) 
      unset %offender*. [ $+ [ $1 ] ] 
    }
    if ($bio.readfile(19) == 1) && (%offender. [ $+ [ $1 ] ] >= 4) { 
      bio.kicking $$2 $$3 Repeat(s): %offender. [ $+ [ $1 ] ] in 60 Sec(s) 
      unset %offender*. [ $+ [ $1 ] ] 
    }
  }
}

alias kd.help {
  if ($isfile($scriptdirkdreadme.html)) { run $scriptdirkdreadme.html }
  else { echo -a *** Unable to detect Kick biohazard Readme. Make sure it is in the $scriptdir directory. }
}

on me:*:JOIN:#:.who $chan
on !@*:JOIN:#:{
  ; Check to see if settings exist
  ; Check clone setting to see if it is on
  if ($isfile($scriptdirkdsettings.ini) == $false) { return }
  if ($bio.readfile(27) == 1) { bio.clone $wildsite $chan $nick }

}

alias -l bio {
  ; Multi-person kicking system.
  ; Kick all those matching provided mask on provided channel.
  ; Clever kick message "You have been fuxored by $me : "
  var %i = 1
  while (%i <= $ialchan($$1,$$2,0)) {
    kick $$2 $ialchan($$1,$$2,%i).nick You have been kicked $me $+ ! $biohazardX
    inc %i
  }
} 

alias bio.clone {
  ; Needs hostname,channel,nick, and updated IAL
  ; See if total matches (using $ialchan) is greater than 1
  ; Loop through the nicks, displaying each one
  ; Read settings file to determine settings (IDs 7-11 12-15 16)
  ; Call bio.kicking to kick matches (set ban if needed)
  var %hostname = $$1 , %kickstyle
  if (%hostname iswm $address($me,5)) { return }
  if ($ialchan($$1,$$2,0) > 1) {
    if ($bio.readfile(7) == 1) { %kickstyle = plain }
    if ($bio.readfile(8) == 1) { %kickstyle = 30 }
    if ($bio.readfile(9) == 1) { %kickstyle = 60 }
    if ($bio.readfile(10) == 1) { %kickstyle = 300 }
    if ($bio.readfile(11) == 1) { %kickstyle = 600 }

    var %ban = 12 , %level = 1
    while (%ban <= 15) {
      if ($biohazard.readfile(%ban) == 1) { break }
      inc %ban
      inc %level
    }
    if (%kickstyle isnum 30-600) { ban -u [ $+ [ %kickstyle ] ] $$2 $ialchan($$1,$$2,2).nick %level } 
    if ($bio.readfile(16) == 1) { bioeem $$1 $$2 }
    else { bio.kicking $$2 $$3 Clone Detected: $$3 ( $+ %hostname $+ ) No clones here! }
  }
}
