Simply type /poll in a channel to get things started, then enter your question, possible responses, time limit, and your poll is launched.
Only allows polls in one channel right now. Other than that, it works great.
To vote, type: !vote [choice number]
Or for info, type: !poll
; It's Hyper's Poll script for mIRC!
alias poll {
set %poll.step 1
window -aei @PollSetup
echo @PollSetup What is the poll question?
set %poll.chan $iif($1,$1,$chan)
set %poll.net $cid
}
on *:INPUT:@PollSetup:{
scid %poll.net
if (%poll.polling == 1 || $timer(Poll)) {
echo @PollSetup 0,4STOP! You cannot create a new poll while one is already in progress!
halt
}
if (%poll.step == 1) {
set %poll.question $1-
set %poll.step 2
echo @PollSetup OK, now enter the possible choices for this poll.
halt
}
elseif (%poll.step == 2) {
if ($1- == end) {
if ($numtok(%poll.choices,46) < 2) {
echo @PollSetup Sorry! You must have two or more choices to start a poll.
echo @PollSetup Please enter a poll choice.
halt
}
else {
set %poll.step 3
echo @PollSetup Now enter a time limit (in minutes) to run the poll. Must be from 1-1440. A value of 0 will leave the poll running forever.
}
}
else {
set %poll.choices $addtok(%poll.choices,$remove($1-,$chr(46)),46)
echo @PollSetup $+ $remove($1-,$chr(46)) $+ Added to Choices.
echo @PollSetup Please enter another choice. Or, if finished, type END to finish entering choices.
}
}
elseif (%poll.step == 3) {
if ($1 isnum 1-1440) {
set %poll.timelimit $calc($1 * 60)
set %poll.step 4
echo @PollSetup It appears we are ready to go! Type start to launch poll.
}
elseif ($1 isnum 0) {
set %poll.timelimit Infinite
set %poll.step 4
echo @PollSetup It appears we are ready to go! Type start to launch poll.
}
else {
echo @PollSetup Uh oh! There's a problem here. Please enter a value from 0 to 1440.
}
}
elseif (%poll.step == 4) {
if ($1 == start) {
if (%poll.timelimit != Infinite) {
.timerPoll 1 %poll.timelimit /spoll
set %poll.loop 1
set %poll.polling 1
msg %poll.chan Poll Time! Question: $+ %poll.question %+
while (%poll.loop <= $numtok(%poll.choices,46)) {
msg %poll.chan $+ %poll.loop $+ . $gettok(%poll.choices,%poll.loop,46)
set $($+(%,poll.votes,%poll.loop)) 0
inc %poll.loop
}
msg %poll.chan Type !vote <number> to vote!
}
else {
set %poll.polling 1
msg %poll.chan Poll Time! Question: $+ %poll.question %+
while (%poll.loop <= $numtok(%poll.choices,46)) {
msg %poll.chan $+ %poll.loop $+ . $gettok(%poll.choices,%poll.loop,46)
set $($+(%,poll.votes,%poll.loop)) 0
inc %poll.loop
}
msg %poll.chan Type !vote <number> to vote!
}
}
}
}
on *:TEXT:!vote &:%poll.chan:{
scid %poll.net
if ($timer(Poll) || %poll.polling == 1) {
if ($var($($+(%,poll.voted.,$address($nick,1))),1).value == 1) {
notice $nick You have already voted.
halt
}
if ($gettok(%poll.choices,$2,46) && $2 > 0 && $2 isnum && $2 == $int($2)) {
inc $($+(%,poll.votes,$2))
inc %poll.votes.total
notice $nick Vote counted!
set $($+(%,poll.voted.,$address($nick,1))),1))) 1
}
else {
notice $nick Ha ha ha. Aren't you the funny one today.
}
}
else {
halt
}
}
on *:INPUT:%poll.chan:{
scid %poll.net
if ($1 == !vote) {
if ($timer(Poll) || %poll.polling == 1) {
if ($var($($+(%,poll.voted.,$address($nick,1))),1).value == 1) {
echo -a You have already voted.
halt
}
if ($gettok(%poll.choices,$2,46) && $2 > 0 && $2 isnum && $2 == $int($2)) {
inc $($+(%,poll.votes,$2))
inc %poll.votes.total
echo -a Vote counted!
set $($+(%,poll.voted.,$address($nick,1))) 1
}
else {
echo -a Sorry, that choice is not available. Choose a proper choice.
}
}
else {
echo -a No poll in progress...
}
}
}
alias results {
scid %poll.net
if (!$timer(Poll)) { halt }
msg %poll.chan Poll Results: %poll.question
set %poll.loop 1
while (%poll.loop <= $numtok(%poll.choices,46)) {
msg %poll.chan $+ %poll.loop $+ . $gettok(%poll.choices,%poll.loop,46) -- $var($($+(%,poll.votes,%poll.loop)),1).value Votes -- $round($calc($var($($+(%,poll.votes,%poll.loop)),1).value * 100 / %poll.votes.total),2) $+ $chr(37)
inc %poll.loop
}
}
alias spoll {
scid %poll.net
if (%poll.polling != 1) { halt }
msg %poll.chan Poll has ended!
results
msg %poll.chan Thanks for voting!
if ($timer(Poll)) { /timer 1 3 /timerPoll off }
unset %poll*
window -c @PollSetup
}
on *:JOIN:%poll.chan:{
if ($cid != %poll.net) { halt }
scid %poll.net
if ($var($($+(%,poll.voted.,$address($nick,1))),1).value == 1) { halt }
notice $nick Poll in Progess! For info, or to vote, type !poll in $chan $+ .
}
on *:TEXT:!poll:%poll.chan:{
scid %poll.net
results
msg %poll.chan Type !vote <number> to vote!
}
Its not a bad script, I can see how it could be useful
It would be nice to be able to run multiple polls on a few channels
Also, variables are slow and... consuming for someone that might have a few hundred votes
I\'d recommend ini files or hash tables
That would make multiple polls more plausible
Bear