rendered paste bodyon *:text:*:#: {
if ((%publicoff [ $+ [ $chan ] ]) && ($left($1,1) == @)) { halt }
if ($1 == !results) {
if (%polltype [ $+ [ $chan ] ] == 1) {
notice $nick 5Current Results: Yes:2 $hpget($chan,yes) 5No:2 $hpget($chan,no) | Halt
}
if (%polltype [ $+ [ $chan ] ] == 2) {
notice $nick 5Current results:05 %option1 [ $+ [ $chan ] ] $+ -02 $hpget($chan,%option1 [ $+ [ $chan ] ]) 05 $+ %option2 [ $+ [ $chan ] ] $+ -02 $hpget($chan,%option2 [ $+ [ $chan ] ])
}
}
if ($1 == !endpoll) {
if (%polltype [ $+ [ $chan ] ] == 1) {
polltally $chan | timerpoll $+ $chan off | halt
}
if (%polltype [ $+ [ $chan ] ] == 2) {
polltally2 $chan | timerpoll $+ $chan off | halt
}
if (!%polltype [ $+ [ $chan ] ]) {
notice $nick 5There is no current active poll in2 $chan $+ 5.
}
}
if ($1 == !poll || $1 == !vote) {
if ($2 != -s) {
if ($2 !isnum) { notice $nick 5Syntax: 2!poll time in minutes Question | halt }
var %i = $chan
set %polltype [ $+ [ $chan ] ] 1
hmake poll $+ %i 2
hpadd %i Yes 0 | hpadd %i No 0 | hpadd %i question $3- | hpadd %i nick $nick | hpadd %i chan $chan
msg $hpget(%i,chan) 2 $+ $nick 5has started a new poll in2 %i $+ 5. Question:02 $hpget(%i,question) $+ .
msg $hpget(%i,chan) 5To vote, type 2!yes 5or2 !no $+ 5. Vote will last2 $iif($2 < 1,$calc($2 * 60) 5Second(s).,$2 5minute(s).)
timerpoll $+ $chan 1 $calc($2 * 60) polltally %i
}
else {
if ($3 !isnum) { notice $nick 5Syntax:2 !poll -s Time in minutes Option 1 Option 2 Question | halt }
var %i = $chan
set %polltype [ $+ [ $chan ] ] 2
%option1 [ $+ [ $chan ] ] = $4
%option2 [ $+ [ $chan ] ] = $5
hmake poll $+ %i 2
hpadd %i %option1 [ $+ [ $chan ] ] 0 | hpadd %i %option2 [ $+ [ $chan ] ] 0 | hpadd %i question $6- | hpadd %i nick $nick | hpadd %i chan $chan
msg $hpget(%i,chan) 2 $+ $nick 5has started a new poll in2 %i $+ 5. Question:02 $hpget(%i,question) $+ .
msg $hpget(%i,chan) 5To vote, type 2! $+ %option1 [ $+ [ $chan ] ] 5or2 ! $+ %option2 [ $+ [ $chan ] ] $+ 5. Vote will last2 $iif($3 < 1,$calc($3 * 60) 5Second(s).,$3 5minute(s).)
timerpoll $+ $chan 1 $calc($3 * 60) polltally2 %i
}
}
elseif ($1 == !yes || $1 == !no) && (%polltype [ $+ [ $chan ] ] == 1) {
if (%polltype [ $+ [ $chan ] ] == 1) {
if ($hpget($chan,voted. $+ $address($nick,2))) { notice $nick 5You have already voted. }
else {
hpinc $chan $iif($1 == !yes,yes,no) | hpadd $chan voted. $+ $address($nick,2) 1
notice $nick 5Your vote of2 $mid($1,2) 5has been recieved. Thank you for voting. Current Results: 5Yes-2 $hpget($chan,yes) 5No-2 $hpget($chan,no)
}
}
}
elseif ($1 == ! $+ %option1 [ $+ [ $chan ] ] || $1 == ! $+ %option2 [ $+ [ $chan ] ]) {
if (%polltype [ $+ [ $chan ] ] == 2) {
if ($hpget($chan,voted. $+ $address($nick,2))) { notice $nick 5You have already voted. }
else {
hpinc $chan $iif($1 == ! $+ %option1 [ $+ [ $chan ] ],%option1 [ $+ [ $chan ] ],%option2 [ $+ [ $chan ] ]) | hpadd $chan voted. $+ $address($nick,2) 1
notice $nick 5Your vote of2 $mid($1,2) 5has been recieved. Thank you for voting. Current results:05 %option1 [ $+ [ $chan ] ] $+ -02 $hpget($chan,%option1 [ $+ [ $chan ] ]) 05 $+ %option2 [ $+ [ $chan ] ] $+ -02 $hpget($chan,%option2 [ $+ [ $chan ] ])
}
}
}
elseif ($1 == !current) {
if (%polltype [ $+ [ $chan ] ] == 1) {
notice $nick 5Current Question:2 $hpget($chan,question)
notice $nick 5Current Results:02 05Yes-02 $hpget($1,yes) 05No-02 $hpget($1,no)
}
elseif (%polltype [ $+ [ $chan ] ] == 2) {
notice $nick 5Current Question:2 $hpget($chan,question)
notice $nick 5Current Results:5 %option1 [ $+ [ $chan ] ] $+ -02 $hpget($1,%option1 [ $+ [ $chan ] ]) 05 $+ %option2 [ $+ [ $chan ] ] -02 $hpget($1,%option2 [ $+ [ $chan ] ])
}
else {
notice $nick 5There is no current active poll in2 $chan $+ 5.
}
}
}
alias polltally {
if ($hpget($1,no) == $hpget($1,yes)) {
msg $hpget($1,chan) 5The poll for:2 $hpget($1,question) 5has ended!
msg $hpget($1,chan) 5Yes-2 $hpget($1,yes) 5No-2 $hpget($1,no)
msg $hpget($1,chan) 5There has been a 2Tie5!
hfree poll $+ $1 | unset %polltype [ $+ [ $1 ] ]
}
else {
msg $hpget($1,chan) 5The poll for:2 $hpget($1,question) 5has ended!
msg $hpget($1,chan) 5Yes:2 $hpget($1,yes) 5No:2 $hpget($1,no)
msg $hpget($1,chan) 5Winner:02 $iif($hpget($1,yes) > $hpget($1,no),yes,no) 5(02 $+ $round($calc((100 / ($hpget($1,yes) + $hpget($1,no))) * $iif($hpget($1,yes) > $hpget($1,no),$hpget($1,yes),$hpget($1,no))),0) $+ 5 $+ $chr(37) $+ 5)
hfree poll $+ $1 | unset %polltype [ $+ [ $1 ] ]
}
}
alias polltally2 {
if ($hpget($1,%option1 [ $+ [ $1 ] ]) == $hpget($1,%option2 [ $+ [ $1 ] ])) {
msg $hpget($1,chan) 5The poll for:02 $hpget($1,question) 5has ended!
msg $hpget($1,chan) 05 $+ %option1 [ $+ [ $1 ] ] $+ -2 $hpget($1,%option1 [ $+ [ $1 ] ]) 05 $+ %option2 [ $+ [ $1 ] ] $+ -02 $hpget($1,%option2 [ $+ [ $1 ] ])
msg $hpget($1,chan) 5There has been a 2Tie5!
hfree poll $+ $1 | unset %polltype [ $+ [ $1 ] ]
}
else {
msg $hpget($1,chan) 5The poll for:02 $hpget($1,question) 5has ended!
msg $hpget($1,chan) 05 $+ %option1 [ $+ [ $1 ] ] $+ -2 $hpget($1,%option1 [ $+ [ $1 ] ]) 05 $+ %option2 [ $+ [ $1 ] ] $+ -02 $hpget($1,%option2 [ $+ [ $1 ] ])
msg $hpget($1,chan) 5Winner:02 $iif($hpget($1,%option1 [ $+ [ $1 ] ]) > $hpget($1,%option2 [ $+ [ $1 ] ]),%option1 [ $+ [ $1 ] ],%option2 [ $+ [ $1 ] ]) 05(02 $+ $round($calc((100 / ($hpget($1,%option1 [ $+ [ $1 ] ]) + $hpget($1,%option2 [ $+ [ $1 ] ]))) * $iif($hpget($1,%option1 [ $+ [ $1 ] ]) > $hpget($1,%option2 [ $+ [ $1 ] ]),$hpget($1,%option1 [ $+ [ $1 ] ]),$hpget($1,%option2 [ $+ [ $1 ] ]))),0) $+ 05 $+ $chr(37) $+ 05)
hfree poll $+ $1 | unset %polltype [ $+ [ $1 ] ]
}
}
alias -l hpadd hadd poll $+ $1 $2-
alias -l hpget return $hget(poll $+ $1,$2-)
alias -l hpinc {
if (%polltype [ $+ [ $1 ] ]) {
hinc poll $+ $1 $2
}
}
;NOTE i will still update it in the future