rendered paste bodyalias poll.end {
var %c = 1, %t = $numtok($remove(%poll.answers,$chr(32)),44)
while (%c <= %t) {
var %x = $gettok($remove(%poll.answers,$chr(32)),%c,44)
.timerPOLLEND $+ %c 1 %c msg %poll.chan (info) Answer $+ %c $+ ( $+ %x $+ ) - Votes: $+ $iif(%poll. [ $+ [ %x ] ],%poll. [ $+ [ %x ] ],0) $+ [ $+ $round($calc(%poll. [ $+ [ %x ] ] / %poll.total * 100),0) $+ % $+ ]
inc %c 1
}
msg %poll.chan (info) Poll finished. Total of Votes: $+ $iif(%poll.total,%poll.total,0)
unset %poll.*
}
;---events---
on *:text:!poll*:#:{
if ($timer(POLL)) { msg $chan (info) A poll is runnig at the moment. Please try again later. }
else { if ($gettok($1-,3,58) > 3)
unset %poll.answ.* %poll.answers
if ($gettok($2-,0,58) > 3) {
set %poll.question $gettok($2-,1,58) | set %poll.time $gettok($2-,2,58) | set %poll.chan $chan
var %c = 1, %t = $calc($gettok($2-,0,58) - 2)
while (%c <= %t) {
set %poll.answ. $+ %c $gettok($2-,$calc(%c + 2),58)
set %poll.answers %poll.answers $gettok($2-,$calc(%c + 2),58) $iif(%c != %t,$chr(44))
inc %c 1
}
msg $chan (info) Poll: Question: %poll.question $+ . Duration: %poll.time mins. !Vote $remove($+([,%poll.answers,]),$chr(32))
.timerPOLL 1 $calc(60* %poll.time) poll.end
}
else { msg $chan (info) !Poll Question : Duration : Answer1 : Answer2 : AnswerX }
}
}
on *:text:!vote*:#:{
if (!$timer(POLL)) { msg $chan (info) There aren't Polls at the moment. }
else {
if (!$2) || ($2 !isin %poll.answers) { msg $chan (info) Command: !Vote $remove($+([,%poll.answers,]),$chr(32)) }
else {
if ($nick isin %poll.users) { notice $nick (info) You can't vote again. }
else {
notice $nick (info) Thank's for your vote.
set %poll.users %poll.users $nick | inc %poll.total 1 | inc %poll. [ $+ [ $2 ] ] 1
}
}
}
}