;
;  Vote Master Custom Identifiers
;
alias vote.percent {
  set %vote.percent $round($calc($1 / $2),2)
  if ($left(%vote.percent,1) == 0) {
    if ($right(%vote.percent,2) == 00) { return 0% }
    elseif ($mid(%vote.percent,3,1) == 0) { return $mid(%vote.percent,4,1) $+ $chr(37) }
    else { return $right(%vote.percent,2) $+ $chr(37) }
  }
  elseif ($mid(%vote.percent,2,1) == $chr(46)) { return $remove(%vote.percent,$chr(46)) $+ $chr(37) }
}
;
;  Vote Master Aliases
;
alias vote.timesup {
  if ($chan(%vote.chan) == $null) { echo 6 -a Voting Booth Closed - %adv | echo 4 -a ERROR: Unable to display results! You're not on %vote.chan | goto end }
  msg %vote.chan 0,4Voting Booth Closed - %adv
  msg %vote.chan 12Topic was: %vote.topic
  msg %vote.chan 0,4People who said Yes:8 %vote.yes 2(12 $+ $vote.percent(%vote.yes,%vote.total) $+ 2)
  msg %vote.chan 0,4People who said No:8 %vote.no 2(12 $+ $vote.percent(%vote.no,%vote.total) $+ 2)
  msg %vote.chan 4By:10,1[0,1 Th15,1un0,1der-15,1Bo0,1y10,1 ] 
  if (%vote.no == 0 && %vote.yes == 0) { msg %vote.chan 5No one voted! Geez... } 8,1[-14,1Tee4,1ns 9,1c0,1t8,1 v4.0-] 
  elseif (%vote.no == %vote.yes) { msg %vote.chan 5It's a Tie! }
  elseif (%vote.no > %vote.yes) { msg %vote.chan 5The Majority Voted NO }
  elseif (%vote.no < %vote.yes) { msg %vote.chan 5The Majority Voted YES }
  :end
  unset %vote.*
}
;
;  Vote Master Events
;
on 1:text:!yes*:#: {
  if (%vote.topic != $null && $chan == %vote.chan) {
    if (%vote.nick. [ $+ [ $nick ] ] != $null) { notice $nick You've already placed your vote! 8,1[-14,1Tee4,1ns 9,1c0,1t8,1 v4.0-]
      inc %vote.yes 1
      inc %vote.total 1
      notice $nick Thanks for placing your vote! 8,1[-14,1Tee4,1ns 9,1c0,1t8,1 v4.0-]
      set %vote.nick. [ $+ [ $nick ] ] voted
    }
  }
  on 1:text:!no*:#: {
    if (%vote.topic != $null && $chan == %vote.chan) {
      if (%vote.nick. [ $+ [ $nick ] ] != $null) { notice $nick You've already placed your vote!| halt }
      inc %vote.no 1
      inc %vote.total 1
      notice $nick Thanks for placing your vote! 8,1[-14,1Tee4,1ns 9,1c0,1t8,1 v4.0-]
      set %vote.nick. [ $+ [ $nick ] ] voted
    }
  }
  on 1:connect:unset %vote.*
  ;
  ;  Vote Master Version Reply
  ;
