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