on *:TEXT:!vote*:#:{
if (%poll != $null) { notice $nick 2There is already a poll active. | halt }
if (!$2) || ($2 !isnum 0.001-1000000) { notice $nick 14You have to enter a time (in minutes) to say how long you want the poll to last for. | halt }
if (!$3) { notice $nick 2You have to enter a question! | halt }
set %poll $iif($right($2-,1) == ?,$3-,$3- $+ ?)
msg $chan 7 $+ $nick 2has activated a vote! The question is:4 %poll 2The poll will last for4 $2 2minutes.
set %poll.nick $address($nick,3)
set %poll.time $calc($2 * 60)
set %poll.yes 0
set %poll.no 0
set %poll.maybe 0
set %poll.chan #Pure-Project
timer 1 $calc($2 * 60) { signal end }
}
on *:TEXT:!endvote*:#:{
if (%poll == $null) { notice $nick 14There isn't a poll active. | halt }
if ($nick isop $chan) || ($nick ishop $chan) || (%poll.nick == $address($nick,3)) {
msg $chan 2The poll has been stopped by4 $nick $+ 2. 2Yes had4 %poll.yes 2votes. No had4 %poll.no 2votes. Maybe had4 %poll.maybe 2 votes.
unset %poll* | timers off
}
else { notice $nick 14You cannot end this poll! }
}
on *:TEXT:!yes*:#:{
if (%poll == $null) { notice $nick 2There isn't a poll active. | halt }
if ($address($nick,3) isin %poll.nick2) { notice $nick 14You have already voted! | halt }
else { goto erm2 }
:erm2
set %poll.nick2 %poll.nick2 $address($nick,3)
notice $nick 2Your vote has been counted.
inc %poll.yes
}
on *:TEXT:!no*:#:{
if (%poll == $null) { .notice $nick 2There isn't a poll active. | halt }
if ($address($nick,3) isin %poll.nick2) { .notice $nick 14You have already voted! | halt }
else { goto erm3 }
:erm3
set %poll.nick2 %poll.nick2 $address($nick,3)
.notice $nick 2Your vote has been counted.
inc %poll.no
}
on *:TEXT:!votecount*:#:{
if (%poll == $null) { .notice $nick 14There isn't a poll active. | halt }
else { .notice $nick 10The current question is:7 %poll | notice $nick 10Yes has7 %poll.yes 10votes. No has7 %poll.no 10votes. Maybe has7 $(%poll.maybe,3) 10votes. }
}
on *:SIGNAL:end:{
if (%poll != $null) {
//.msg %poll.chan 2The poll has ended! The question was:4 %poll
//.msg %poll.chan 2Yes had7 $(%poll.yes,3) 2votes. No had4 $(%poll.no,3) 2votes. Maybe had4 $(%poll.maybe,3) 12votes.
//unset %poll*
}
}
on *:TEXT:!maybe*:#:{
if (%poll == $null) { .notice $nick 2There isn't a poll active. | halt }
if ($address($nick,3) isin %poll.nick2) { .notice $nick 14You have already voted! | halt }
else { goto erm2 }
:erm2
set %poll.nick2 %poll.nick2 $address($nick,3)
.notice $nick 2Your vote has been counted.
inc %poll.maybe
}
on *:TEXT:!question*:#:{
if (%poll == $null) { .notice $nick 10There isn't a poll active. | halt }
else { .notice $nick 10The current question is:7 %poll 10To vote, type 7!yes14, 7!no10 or 7!maybe10. }
}