All pastes #766569 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-11-08 23:36 UTC
rendered paste body
on 1:EXIT: {
  set %inprogress $false
  remove e:\testmirc\voters.txt
}
on 100:TEXT:startvote *:?: {
  if (%inprogress) {
    msg $nick a vote is already in progress, please wait until the vote ends in $duration($timer(votetimer).secs),1)
  }
  else {
    if ($2 == chserver || $2 == chchannel) {
      set %cmd $$2
      set %param $$3
      set %issue $$4-
      set %startedby $nick
      set %inprogress $true
      set %vyes 0
      set %vno 0
      timer 1 60 endvote
      msg #!CHINKSPEAK  A vote has been started by $nick - %cmd %param - %issue
    }
  }
}
on 100:TEXT:vote *:?: {
  if ( %inprogress ) {
    if ( $read(e:\testmirc\voters.txt,w,$address($nick,1)) ) {
      msg $nick you have already voted!
      halt
    }
    if ( $2 == yes ) {
      inc %vyes
      msg $nick thanks for voting!
      write e:\testmirc\voters.txt $address($nick,1)
    }
    if ( $2 == no ) {
      inc %vno
      msg $nick thanks for voting.
      write e:\testmirc\voters.txt $address($nick,1)
    }
  }
}
alias endvote {
  set %inprogress $false
  remove e:\testmirc\voters.txt
  if ( $calc( %vyes / ( %vyes + %vno ) ) >= 0.50 ) {
    msg #!CHINKSPEAK vote passed the needed ratio of 65%
    .%cmd [ [ $replace(%param,-,$chr(32)) ] ]
  }
  else {
    msg #!CHINKSPEAK vote was unable to reach the needed ratio of 65%
  }
}
alias chserver {
  msg #!CHINKSPEAK switching to server $1 and joining $2
  scid 23
  server $1
  join $2
  scid 1
}
alias chchannel {
msg #!CHINKSPEAK Joining $1
scid 23
join $1
scid 1
}