Random winner selector

By Henco on Mar 29, 2010

Selects a random winner from the channel to win whatever prize you specify.

!winner to choose a winner
!prize * to set prize
!clprize to clear prize

;###### RANDOM WINNER SELECTOR SCRIPT - BY HENRY COLE ######
;###### MORE INFO & HELP IN #HENCO ON IRC.INFINITYIRC.COM ######

on *:text:!winner:#: {

  set %nick1 $nick($chan,$rand(1,$nick($chan,0)))

  if (%nick1 == $me) { set %nick1 $nick($chan,$rand(1,$nick($chan,0))) }

  msg $chan Randomly selecting a winner........
  timerlawl 1 1 msg $chan The winner is %nick1 $+ ! Congratulations %nick1 :) You win... %prize. [ $+ [ $network ] $+ ] . [ $+ [ $chan ] ]
}

on *:text:!prize *:#: {
  if ($nick isop $chan) {
    set %prize. [ $+ [ $network ] $+ ] . [ $+ [ $chan ] ] $2-
    msg $chan New prize set!
  }
}

on *:text:!clprize:#: {
  if ($nick isop $chan) {
    set %prize. [ $+ [ $network ] $+ ] . [ $+ [ $chan ] ] Nothing
    msg $chan Prize cleared!
  }
}

Comments

Sign in to comment.
shaneny   -  Jul 10, 2010

Nice script Henco, I'm not sure if it is the script, but the nicks aren't that random

 Respond  
michealkenny   -  Jun 30, 2010

thanks so much!

 Respond  
Jethro   -  Jun 30, 2010

I've edited it. The script will now exclude regular (mode-less) users.

 Respond  
michealkenny   -  Jun 30, 2010

thank you!:), and I know this is a lot to ask, but is there anyway to toggle if unvoiced people can or can't be chosen, if not, its great anyway, thank you!

 Respond  
Jethro   -  Jun 30, 2010

Jethro, can you do the script so only ops can use it and it just says The Winner Is: (nick) leaving out the prize details, thanks :)

on *:text:$($iif(!winner = $strip($1),$1)):#:{
  if ((!%f) && ($nick isop #)) {
    inc -u2 %f
    :r
    var %x 1
    while $nick(#,$r(%x,$nick(#,0,a,r))) {
      if $v1 = $me { goto r }
      else {
        tokenize 32 $v1
        scon -r .msg $!chan Congratulations, the winner is $* $!+ !
      }
      inc %x
    }
  }
}

Syntax: !winner

 Respond  
michealkenny   -  Jun 29, 2010

Jethro, can you do the script so only ops can use it and it just says The Winner Is: (nick) leaving out the prize details, thanks :)

 Respond  
napa182   -  Mar 30, 2010

Henco Said:

It really doesn't matter tbh >.>

As long as the script works, it is fine how it is initially written.

well it does matter tbh why else post it here.

why keep going with bad scripting habits.
why not learn from peoples comments like Jethro_'s

 Respond  
Henco   -  Mar 30, 2010

It really doesn't matter tbh >.>

As long as the script works, it is fine how it is initially written. Any real bugs I welcome your comments on.

 Respond  
napa182   -  Mar 30, 2010

Jethro_ Said:

For those who don't have a clue about regex, they wind up seeing them as a "load of craps."

now that cracked me up.

edgy Said:

Yeah, that's horrible to read code. We just use the stuff we were taught.

well theres ur chance to learn something new.

 Respond  
Henco   -  Mar 30, 2010

nice version Jethro_ - thanks for the info, I may not be that experienced, but am always willing to learn :)

 Respond  
Jethro   -  Mar 30, 2010

I don't know why you see them as symbols, but the point is, it works. Though I understand why you said that. I've seen and heard people say the same thing when they don't understand something, such as regular expressions for instance, which use achors, octal numbers, etc... The scripting language that can only be interpreted by a regex processor. For those who don't have a clue about regex, they wind up seeing them as a "load of craps."

 Respond  
edgy   -  Mar 30, 2010

It's just loads of symbols...

 Respond  
Jethro   -  Mar 30, 2010

"Horrible" is such a rhetorical word per se. If you take out the pipes, you'll see the code is not "horrible" to read. That is, if you understand how each line, identifier and operator works.

 Respond  
edgy   -  Mar 30, 2010

Yeah, that's horrible to read code. We just use the stuff we were taught.

 Respond  
Jethro   -  Mar 29, 2010

You only need one text event, and here is my take on your script:

on $*:text:/^!((cl)?prize|winner)/iS:#: {
  if (!%f) { set -u3 %f $true | goto $iif($replace($regml(1),winner,w,prize,p,clprize,clp),$ifmatch)
    :w | var %x = 1 | while ($nick(#,$r(%x,$nick(#,0)))) { if ($ifmatch = $me) { goto r }
      else { set -e %a $ifmatch | tokenize 32 %a | .msg # Congratulations, the winner is $str($*,1) , $&
      and you win the prize: $iif($($+(%,prize.,$network,.,#),2),$ifmatch,nothing) } | inc %x | halt } 
    :p | if ($nick isop #) { set $+(%,prize.,$network,.,#) $$2- | .msg # New prize set for $+(",$2,") | halt }
    :clp | if ($nick isop #) { unset $+(%,prize.,$network,.,#) | .msg # Prize Cleared! | halt }
    :r | .msg # Congratulations, the winner is %a , and you win the prize: $iif($($+(%,prize.,$network,.,#),2),$ifmatch,nothing) | halt
  }
}

A trigger flood control is needed in case people tamper with this script to flood out the client running the code. (can only be triggered every 3 seconds)

 Respond  
edgy   -  Mar 29, 2010

This works very well, it's on [^_^] in my channel!

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.