Heh. I'm actually in the process of doing the same thing. I might as well share what I have since it might help you out even though it's not done and has a couple issues. This is what I have written for it so far.
;************************************************
;********************** POLL ********************
;************************************************
on *:TEXT:!poll *:#: {
if (($nick !isop $chan) && ($$2 != results)) {
msg $chan Only mods may use this feature.
}
else {
; *********
; OPEN POLL
; *********
if ($$2 == open) {
unset %polloptions
unset %pollvotes
unset %hasvoted
set %polloptions $3-
var %numberofoptions $numtok($3-,124)
while ( %numberofoptions > 0 ) {
dec %numberofoptions
set %pollvotes %pollvotes 0
}
var %number $numtok(%polloptions,124)
while (%number > 0) {
if (%number == $numtok(%polloptions,124)) {
var %finalresults %number - $gettok(%polloptions,%number,124) %finalresults
}
else {
var %finalresults %number - $gettok(%polloptions,%number,124) || %finalresults
}
dec %number
}
msg $chan A new poll has been opened: %finalresults
}
; ************
; POLL RESULTS
; ************
elseif ($$2 == results) {
if (%polloptions != $null) {
msg $chan Current Results are: $pollresults
}
else {
msg $chan Results for previous poll are: %oldresults
}
}
; **********
; POLL CLOSE
; **********
elseif ($$2 == close) {
msg $chan $nick has closed the poll! Results are: $pollresults
set %oldresults $pollresults
unset %polloptions
unset %pollvotes
unset %hasvoted
}
}
}
alias pollresults {
var %number $numtok(%polloptions,124)
while (%number > 0) {
if (%number == $numtok(%polloptions,124)) {
var %finalresults $gettok(%polloptions,%number,124) : $gettok(%pollvotes,%number,32) votes %finalresults
}
else {
var %finalresults $gettok(%polloptions,%number,124) $+ : $gettok(%pollvotes,%number,32) votes || %finalresults
}
dec %number
}
return %finalresults
}
on *:TEXT:!vote *:#: {
if ( %polloptions == $null) {
msg $chan There is no open poll to vote on!
}
elseif ($nick isin %hasvoted) {
msg $chan $nick $+ , you have already voted in this poll!
}
elseif ($$2 !isnum 1 - $numtok(%pollvotes,32)) {
msg $chan $$2- is not a valid poll option!
}
else {
set %hasvoted %hasvoted $nick
var %voteupdate $gettok(%pollvotes,$$2,32)
inc %voteupdate
set %pollvotes $puttok(%pollvotes,%voteupdate,$$2,32)
msg $chan $nick has voted for option $$2 $+ : $gettok(%polloptions,$$2,124)
}
}
So, you can get stuff like this
[00:46:43] <teksura> !poll open This | That | The other thing
[00:46:45] <tekbot_v2> A new poll has been opened: 1 - This || 2 - That || 3 - The other thing
[00:46:50] <teksura> !vote 1
[00:46:51] <tekbot_v2> teksura has voted for option 1: This
[00:46:55] <teksura> !poll results
[00:46:59] <tekbot_v2> Current Results are: This : 1 votes || That : 0 votes || The other thing : 0 votes
[00:47:00] <teksura> !vote 2
[00:47:01] <tekbot_v2> teksura, you have already voted in this poll!
[00:47:04] <teksura> !poll close
[00:47:05] <tekbot_v2> teksura has closed the poll! Results are: This : 1 votes || That : 0 votes || The other thing : 0 votes
[00:47:08] <teksura> !poll results
[00:47:10] <tekbot_v2> Results for previous poll are: This : 1 votes || That : 0 votes || The other thing : 0 votes
I had to add a function to allow recalling the results of the last already closed poll due to the occasional problem with twitch chat. This protects you by ensuring that you can still get the results if the message doesn't get through.
This is still a work in progress for me, but you certainly can use it as it stands. It should work fine IF that is the only channel you intend to use the bot in.
The current issue I'm trying to solve though is giving each channel their own unique set of variables so that opening a poll in one channel doesn't wipe the poll in another channel. As written, this script will have pretty disastrous results if 2 different channels attempt to have polls open at the same time.
I tried doing something simple like %polloptions $+ $chan in the hopes that I'd be able to use %polloption#channelname as a variable, but that just seems to give me strange results when I try to actually call the variable. It'll generally just look at %polloptions and then just add the channel name to the end of whatever is at %polloptions.
Does anyone know how I can resolve that issue?