[color:green]; -----------------------------------------------------------------------------
; Channel Poll
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; Clear out the vote variables
; same with on exit, should they quit
; mirc in th emiddle of a vote[/color]
on *:START: {
/unset %poll.*
}
on *:EXIT: {
/unset %poll.*
}
[color:green]; -----------------------------------------------------------------------------
; Trigger
; --
; use:
; Type !vote <question> to start a cote on a subject[/color]
on *:TEXT:!vote *:#: {
[color:green]; time to vote in minutes[/color]
[color:Red]var %time = 2[/color]
if ($nick isop $chan) {
if (!%poll.question) {
[color:green]; make it easier below[/color]
var %c = $chr(44)
[color:green]; .info -> Voter,Channel,Votes_For,Votes_Against[/color]
/set %poll.info $+($nick,%c,$chan,%c,0,%c,0)
/set %poll.question $2-
var %secs = %time * 60
[color:green]; end the poll in 2 minutes[/color]
.timerpoll 1 %secs /pollend
[color:green]; warning timers[/color]
.timerpoll1 1 $calc(%secs - 30) [color:blue]/msg $chan 30 Seconds Remaining![/color]
.timerpoll2 1 $calc(%secs - 20) [color:blue]/msg $chan 20 Seconds Remaining![/color]
.timerpoll2 1 $calc(%secs - 10) [color:blue]/msg $chan 10 Seconds Remaining![/color]
[color:green]; enable "voting booth"[/color]
.enable #polls
[color:green]; advertise[/color]
[color:blue]/msg $chan Polls are now open! ( $+ %time minutes to vote!)
/msg $chan Current Poll: $2-
/msg $chan Please type !yes to vote yes, and !no to vote no.[/color]
}
else [color:blue]/msg $chan There is already a vote in progress.[/color]
}
else [color:blue]/msg $chan You must have operator status to initiate a vote.[/color]
}
[color:green]; -----------------------------------------------------------------------------
; "voting booth"[/color]
#polls off
on *:TEXT:!yes:#: {
if ($gettok(%poll.info,2,44) == $chan) {
if (!%poll.vote [ $+ [ $address ] ]) {
/set %poll.vote [ $+ [ $address ] ] yes
/pollyes 1
var %action = voted
}
else if (%poll.vote [ $+ [ $address ] ] == no) {
/set %poll.vote [ $+ [ $address ] ] yes
/pollyes 1
/pollno -1
var %action = change their vote to
}
else [color:blue]/msg $chan $nick $+ , you already voted yes.[/color]
if (%action) [color:blue]/describe $chan $nick has %action yes[/color]
}
}
on *:TEXT:!no:#: {
if ($gettok(%poll.info,2,44) == $chan) {
if (!%poll.vote [ $+ [ $address ] ]) {
/inc %poll.vote [ $+ [ $address ] ]
/pollno 1
var %action = voted
}
else if (%poll.vote [ $+ [ $address ] ] == yes) {
/set %poll.vote [ $+ [ $address ] ] no
/pollno 1
/pollyes -1
var %action = changed their vote to
}
else [color:blue]/msg $chan $nick $+ , you already voted no.[/color]
if (%action) [color:blue]/describe $chan $nick has %action no[/color]
}
}
#polls end
[color:Green]; -----------------------------------------------------------------------------
; Aliases Needed[/color]
alias pollyes {
if (%poll.info) {
var %yes = $calc($gettok(%poll.info,3,44) + $1)
/set %poll.info $puttok(%poll.info,%yes,3,44)
}
}
alias pollno {
if (%poll.info) {
var %no = $calc($gettok(%poll.info,4,44) + $1)
/set %poll.info $puttok(%poll.info,%no,4,44)
}
}
alias pollend {
if (%poll.question) {
[color:green]; get info into something we can easily associate[/color]
/tokenize 44 %poll.info
var %nick = $1, %chan = $2, %yes = $3, %no = $4
[color:green]; disable voting booth[/color]
.disable #polls
[color:green]; notify users[/color]
[color:blue]/msg %chan Polls are now closed!
/msg %chan Current Poll: %poll.question[/color]
[color:green]; come up with result[/color]
if (%yes > %no) [color:blue]/msg %chan Vote Passes![/color]
else if (%yes < %no) [color:blue]/msg %chan Vote Fails![/color]
else [color:blue]/msg %chan Vote has ended in a Tie![/color]
}
/unset %poll.*
}
[color:green]; ------------------------------------------------------------------------------
; EOF KingTomato[/color]