All pastes #75309 Raw Edit

Someone

public text v1 · immutable
#75309 ·published 2006-06-30 01:16 UTC
rendered paste body
#getvotes off
on $*:TEXT:/^[!@.]vote/Si:#:{
  if ((%vote. [ $+ [ $address($nick,3) ] ] == 1) && ($findtok(yes;no,$2,59))) { notice $nick You have already voted on this poll! }
  elseif ($2 == yes) { %vote. [ $+ [ $address($nick,3) ] ] = 1 | inc %vote.yes | notice $nick Your vote has been counted as Yes. }
  elseif ($2 == no) { %vote. [ $+ [ $address($nick,3) ] ] = 1 | inc %vote.no | notice $nick Your vote has been counted as No. }
  elseif (($findtok(end;stop;halt,$2,59)) && ($nick isop $chan)) { endvoting $nick }
}

on *:join:#:{
  if ($chan == %vote.chan) {
    notice $nick has started a poll:7 %vote.topic 
    notice $nick type 4!vote yes or 4!vote no to participate (4Auto-Ending in %vote.time Minutes.)
  }
}
#getvotes end

alias endvoting {
  .disable #getvotes
  .timervote off
  if ($1 == !timeup) { msg %vote.chan Poll started by %vote.nick has expired. }
  else { msg %vote.chan Poll started by %vote.nick has been ended by $1 }
  msg $chan Results are Yes:4 %vote.yes  $+ $chr(124) No:4 %vote.no 
  if (%vote.yes == %vote.no) { msg %vote.chan %vote.topic - Results: 4It's a TIE!! }
  else { msg %vote.chan %vote.topic - Results: $iif(%vote.yes > %vote.no,4YES!,4NO!)  }
  unset %vote.*
}

; # Usage: !vote start <time_in_mins> <topic>
; # To end a poll "now": !vote end  OR  !vote stop  OR  !vote halt
on *:TEXT:!vote start*:#: {

  ; # Default - Anyone can start a poll. Remember to comment out to change this setting.
  if (($2 == start) && ($group(#getvotes) == off)) {

  ; # Uncomment this to allow only channel Ops to start a poll.
  ;if (($2 == start) && ($group(#getvotes) == off) && ($nick isop $chan)) {
  
  ; # Uncomment this to allow only channel Op and Hops to start a poll.
  ;if (($2 == start) && ($group(#getvotes) == off) && (($nick isop $chan) || ($nick ishop $chan))) {

    set %vote.nick $nick
    set %vote.chan $chan
    set %vote.time $3
    set %vote.topic $4-
    msg $chan $nick has started a poll:7 %vote.topic 
    msg $chan type 4!vote yes or 4!vote no to participate (4Auto-Ending in %vote.time Minutes.)
    .enable #getvotes
    .timervote 1 $calc(%vote.time * 60) endvoting !timeup!
  }
}