rendered paste body#getvotes off
on $*:TEXT:/^[!@.]vote/Si:#trulyinsane:{
if ((%vote. [ $+ [ $nick ] ] == 1) && ($findtok(yes;no,$2,59))) { notice $nick You have already voted on this poll! }
elseif ($2 == yes) { %vote. [ $+ [ $nick ] ] = 1 | inc %vote.yes | notice $nick Your vote has been counted as Yes. }
elseif ($2 == no) { %vote. [ $+ [ $nick ] ] = 1 | inc %vote.no | notice $nick Your vote has been counted as No. }
elseif (($findtok(end;stop;halt,$2,59)) && ($nick isop $chan)) { endvoting $nick }
}
#getvotes end
alias -l endvoting {
disable #getvotes
.timervote off
if ($1 == !timeup) { msg $chan Poll started by %vote.nick has expired. }
else { msg $chan Poll started by %vote.nick has been ended by $1 }
msg $chan Results are Yes:4 %vote.yes $+ $chr(124) No:4 %vote.no
if (%vote.yes == %vote.no) { msg $chan %vote.topic - Results: 4It's a TIE!! }
else { msg $chan %vote.topic - Results: $iif(%vote.yes > %vote.no,4YES!,4NO!) }
unset %vote.*
}
; # Usage: !vote start <time_in_mins> <topic>
on *:TEXT:!vote start*:#trulyinsane: {
if (($2 == start) && ($group(#getvotes) == off) && ($nick isop $chan)) {
msg $chan $nick has started a poll:7 $4-
msg $chan type 4!vote yes or 4!vote no to participate (4Auto-Ending in $3 Minutes.)
set %vote.nick $nick
set %vote.yes 0
set %vote.no 0
set %vote.topic $4-
enable #getvotes
.timervote 1 $calc($3 * 60) endvoting !timeup!
}
}