Copyright © 2010 – Brandin Arsenault, Known Syntax – BOINC Services, Int. – All rights reserved.
Editing of this script is allowed.
This script is originally from the iKnown IRC Bot which is now discontinued.
-
25% of this script I edited and wrote as it didn't fit my needs. This was used on the iKnown IRC Bot and was a very fun script for all of the members of my bot to use. To join the lottery they use the join command which is defined below or the command you set. To quit they type the quit command below or the command you set. An AOP (@) must be the one to do the next round command which is below or the command you set.
-
Commands:
!ljoin - Joins the lottery.
!lremove - Quits the lottery.
!lnr - Next Round of lottery (declares winner). (AOP's (@)'s only)
on *:start:{
if !$hget(Lotto) { .hmake Lotto 10 }
}
on *:text:!ljoin:#:{
if ($numtok($hget(Lotto,$+($network,.,$chan)),44) <= 10) {
.hadd -m Lotto $+($network,.,$chan) $addtok($hget(Lotto,$+($network,.,$chan)),$nick,44)
describe # smiles as $nick starts playing in the lottery.
.msg $chan Current lottery participants are $replace($sorttok($hget(Lotto,$+($network,.,$chan)),44),$chr(44),$+($chr(44),$chr(32))).
}
else {
describe # apologizes to $nick $+ . Sorry, but the lottery list is full.
}
.msg $chan If everyone is done being added, have an op (@) type !lnr to find out who the winners are.
}
on *:text:!lnr:#:{
if $nick ishop $chan {
while $numtok($hget(Lotto,$+($network,.,$chan)),44) > 1 {
.hinc -m Lotto $+(round.,$network,.,$chan)
.msg $chan Winners in round $hget(Lotto,$+(round.,$network,.,$chan))) are: $getwinners($chan,$network).
}
.hdel Lotto $+(round.,$network,.,$chan)
}
}
alias -l getwinners {
var %a = 1, %b = $int($calc($numtok($hget(Lotto,$+($2,.,$1)),44) / 2))
while %a <= %b {
var %winner = $numtok($hget(Lotto,$+($2,.,$1)),44)
%winner = $r(1,%winner)
%winner = $gettok($hget(Lotto,$+($2,.,$1)),%winner,44)
var %winners = $addtok(%winners,%winner,44)
.hadd -m Lotto $+($2,.,$1) $remtok($hget(Lotto,$+($2,.,$1)),%winner,1,44)
inc %a
}
.hadd -m Lotto $+($2,.,$1) %winners
return $replace(%winners,$chr(44),$+($chr(44),$chr(32)))
}
on *:text:!lremove:#:{
describe # sighs as $nick decides to leave the lottery.
msg $chan Current lottery participants are $replace($sorttok($hget(Lotto,$+($network,.,$chan)),44),$chr(44),$+($chr(44),$chr(32))).
lotto rem $nick
}
alias -l lotto {
.hadd -m Lotto $+($network,.,$2) $remtok($hget(Lotto,$+($network,.,$2)),$1,1,44)
var %winners = $remtok(%winners,$1,1,44)
}
on *:part:#: lotto $nick $chan
on *:kick:#: lotto $knick $chan
on *:quit:{
var %a = 1, %b = $comchan($nick,0)
while %a <= %b {
lotto $nick $comchan($nick,%a)
inc %a
}
}