on *:TEXT:!poll*:#:{
if (%poll != $null) { notice $nick 14There 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 14You have to enter a question! | halt }
set %poll $iif($right($2-,1) == ?,$3-,$3- $+ ?)
msg $chan 7 $+ $nick 14has activated a poll! The question is:7 %poll 14The poll will last for7 $2 14minutes.
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 #
timer 1 $calc($2 * 60) { signal end }
}
on *:TEXT:!endpoll*:#:{
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 14The poll has been stopped by7 $nick $+ 14. 14Yes had7 %poll.yes 14votes. No had7 %poll.no 14votes. Maybe had7 %poll.maybe 14 votes.
unset %poll* | timers off
}
else { notice $nick 14You cannot end this poll! }
}
on *:TEXT:!yes*:#:{
if (%poll == $null) { notice $nick 14There 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 14Your vote has been counted.
inc %poll.yes
}
on *:TEXT:!no*:#:{
if (%poll == $null) { .notice $nick 14There 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 14Your 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 14The current question is:7 %poll | notice $nick 14Yes has7 %poll.yes 14votes. No has7 %poll.no 14votes. Maybe has7 $(%poll.maybe,3) 14votes. }
}
on *:SIGNAL:end:{
if (%poll != $null) {
//.msg %poll.chan 14The poll has ended! The question was:7 %poll
//.msg %poll.chan 14Yes had7 $(%poll.yes,3) 14votes. No had7 $(%poll.no,3) 14votes. Maybe had7 $(%poll.maybe,3) 14votes.
//unset %poll*
}
}
on *:TEXT:!maybe*:#:{
if (%poll == $null) { .notice $nick 14There 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 14Your vote has been counted.
inc %poll.maybe
}
on *:TEXT:!question*:#:{
if (%poll == $null) { .notice $nick 14There isn't a poll active. | halt }
else { .notice $nick 14The current question is:7 %poll 14To vote, type 7!yes14, 7!no14 or 7!maybe14. }
}