All pastes #476279 Raw Edit

Stuff

public text v1 · immutable
·published 2007-05-07 23:39 UTC
rendered paste body
Alias c1 return $+($chr(3),10,$1-,$chr(3))
Alias c2 return $+($chr(3),02,$1-,$chr(3))

on $*:TEXT:/^[!@.]S(et)?(tart)?p(oll)?/Si:#:{
  if ($readini(Status.ini,$network,$chan) == DChan) halt
  elseif ($chr(42) isin $2-) {
    hadd -m $+(poll,.,$network,.,$chan) $GETTOK($2-,2-,42)
    msg $chan $c1(Poll has been started) $c2($gettok($2-,2-,42)) $c1(is the topic your choices are) $c2($GETTOK($1-2,2-,42))
    tokenize 32 $gettok($1,2-,42)
    var %i = 1
    while (%i < $0) {
      var %question $+ %i $($+($,%i),2)
      hadd $+(poll,.,$network,.,$chan) $($+(%,question,%i)
      inc %i
      var %ql = %ql $($+(%,question,%i) $($+($,%i),2)
    }
    unset %questionlist
    unset %question*
  }
  elseif ($chr(42) !isin $2-) {
    notice $nick SYNTAX - !setpoll Answers * Question
  }
}


on $*:text:/^[!@]v(ote)?/Si:#:{
  if ($2- == $hfind($+(poll,.,$network,.,$chan),$2-,1,w)) {
    hinc $+(poll,.,$network,.,$chan) $1 1
    notice $nick you're vote has been counted
  }
}

on $*:TEXT:/^[!@]end(poll)?/Si:#:{
  if ($readini(Status.ini,$network,$chan) == DChan) halt
  elseif (!$hget($($+(poll,.,$network,.,$chan)))) Msg $chan $c1(No current) $c2(poll)
  else {
    set %hget 2
    while (%hget <= $calc($hget($($+(poll,.,$network,.,$chan)),0).item - 1))  {
      $iif(%hget == 2,msg $chan starting results)
      set %results %results $hget($($+(poll,.,$network,.,$chan)), $+ %hget $+ )
      inc %hget
    }
    Msg $chan $c1(The results for) $c2($hfind($($+(poll,.,$network,.,$chan)),1).item) $c1(Are) $c2(%results)
    hfree $($+(poll,.,$network,.,$chan))
  }
}