Code: Select all
# Author: tomekk
# e-mail: tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html
bind pub - !start start_proc
bind pub - !prize prize_proc
bind pub - !reg reg_proc
bind pub - !regs regs_proc
set game_status 0
set game_prize ""
set reg_status 0
set max_players 0
set player_list [list]
proc start_proc { nick uhost hand chan arg } {
global max_players game_status
if {$game_status == 0} {
set players_num [lindex [split $arg] 0]
if {[regexp {^([0-9]+)$} $players_num]} {
set max_players $players_num
set game_status 1
}
}
}
proc prize_proc { nick uhost hand chan arg } {
global game_status reg_status max_players game_prize
if {$game_prize == ""} {
if {$game_status == 1} {
if {$arg != ""} {
set game_prize $arg
set reg_status 1
putquick "PRIVMSG $chan :Lottery starting! Max users: $max_players (prize: $game_prize)"
}
}
}
}
proc reg_proc { nick uhost hand chan arg } {
global reg_status player_list max_players game_status game_prize
if {$reg_status == 1} {
set player_exists 0
foreach new_player $player_list {
set gimme_host [lindex [split $new_player ";"] 1]
if {$gimme_host == $uhost} {
set player_exists 1
break
}
}
if {$player_exists == 0} {
lappend player_list "$nick;$uhost"
if {[llength $player_list] == $max_players} {
set lottery_winner [expr {int(rand() * $max_players)}]
set the_winner_is [lindex [split [lindex $player_list $lottery_winner] ";"] 0]
putquick "PRIVMSG $chan :Ok we have a winner ! $the_winner_is"
set game_status 0
set game_prize ""
set reg_status 0
set max_players 0
set player_list [list]
}
}
}
}
proc regs_proc { nick uhost hand chan arg } {
global reg_status max_players game_prize player_list
set current_in [llength $player_list]
set rdy_player_list [list]
foreach lt_player $player_list {
if {$lt_player != ""} {
set need_only_nick [lindex [split $lt_player ";"] 0]
lappend rdy_player_list $need_only_nick
}
}
if {$rdy_player_list == ""} {
set rdy_player_list "-"
} {
set rdy_player_list [join $rdy_player_list ", "]
}
if {$reg_status == 1} {
putquick "PRIVMSG $chan :Regs atm $current_in/$max_players: $rdy_player_list (prize: $game_prize)"
}
}
putlog "lottery.tcl ver 0.1 by tomekk loaded"
Code: Select all
# Author: tomekk
# e-mail: tomekk/@/tomekk/./org
# home page: http://tomekk.org/
#
# Version 0.2
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html
# lottery setup (stop/start/prize) only for channel ops?
# 1 - only ops
# 0 - everyone
set lottery_setup_for_ops 1
bind pub - !start start_proc
bind pub - !stop stop_proc
bind pub - !prize prize_proc
bind pub - !lottery lottery_proc
bind pub - !reg reg_proc
bind pub - !regs regs_proc
proc set_defaults {} {
global game_status game_prize reg_status max_players player_list started_by
set game_status 0
set game_prize ""
set reg_status 0
set max_players 0
set player_list [list]
set started_by ""
}
set_defaults
proc start_proc { nick uhost hand chan arg } {
global max_players game_status started_by lottery_setup_for_ops
if {$lottery_setup_for_ops == 1} {
if {[isop $nick $chan] == 0} {
putquick "PRIVMSG $chan :Sorry, @ needed."
return
}
}
if {$game_status == 0} {
set players_num [lindex [split $arg] 0]
if {[regexp {^([0-9]+)$} $players_num]} {
set max_players $players_num
set game_status 1
set started_by "$nick <$uhost>"
}
} else {
putquick "PRIVMSG $chan :Lottery already started by: $started_by"
}
}
proc stop_proc { nick uhost hand chan arg } {
global game_status lottery_setup_for_ops
if {$lottery_setup_for_ops == 1} {
if {[isop $nick $chan] == 0} {
putquick "PRIVMSG $chan :Sorry, @ needed."
return
}
}
if {$game_status == 1} {
putquick "PRIVMSG $chan :Lottery wiped."
set_defaults
} else {
putquick "PRIVMSG $chan :Lottery not started."
}
}
proc prize_proc { nick uhost hand chan arg } {
global game_status reg_status max_players game_prize lottery_setup_for_ops
if {$lottery_setup_for_ops == 1} {
if {[isop $nick $chan] == 0} {
putquick "PRIVMSG $chan :Sorry, @ needed."
return
}
}
if {$game_prize == ""} {
if {$game_status == 1} {
if {$arg != ""} {
set game_prize $arg
set reg_status 1
putquick "PRIVMSG $chan :Lottery starting! Max users: $max_players (prize: $game_prize)"
}
} else {
putquick "PRIVMSG $chan :Lottery not started."
}
} else {
putquick "PRIVMSG $chan :Prize already set: $game_prize"
}
}
proc lottery_proc { nick uhost hand chan arg } {
global game_status game_prize max_players started_by
if {$game_status == 1} {
if {$game_prize != ""} {
putquick "PRIVMSG $chan :Lottery started by: $started_by, max players: $max_players, prize: $game_prize"
} else {
putquick "PRIVMSG $chan :Lottery started by: $started_by, max players: $max_players, prize: *not set*"
}
} else {
putquick "PRIVMSG $chan :Lottery not started."
}
}
proc reg_proc { nick uhost hand chan arg } {
global reg_status player_list max_players game_status game_prize
if {$reg_status == 1} {
set player_exists 0
foreach new_player $player_list {
set gimme_host [lindex [split $new_player ";"] 1]
if {$gimme_host == $uhost} {
set player_exists 1
break
}
}
if {$player_exists == 0} {
lappend player_list "$nick;$uhost"
if {[llength $player_list] == $max_players} {
set lottery_winner [expr {int(rand() * $max_players)}]
set the_winner_is [lindex [split [lindex $player_list $lottery_winner] ";"] 0]
putquick "PRIVMSG $chan :Ok we have a winner ! $the_winner_is"
set_defaults
}
}
} else {
putquick "PRIVMSG $chan :Prize not set, can't register - sorry."
}
}
proc regs_proc { nick uhost hand chan arg } {
global reg_status max_players game_prize player_list
if {$reg_status == 1} {
set current_in [llength $player_list]
set rdy_player_list [list]
foreach lt_player $player_list {
if {$lt_player != ""} {
set need_only_nick [lindex [split $lt_player ";"] 0]
lappend rdy_player_list $need_only_nick
}
}
if {$rdy_player_list == ""} {
set rdy_player_list "-"
} {
set rdy_player_list [join $rdy_player_list ", "]
}
if {$current_in > 0} {
putquick "PRIVMSG $chan :Regs atm $current_in/$max_players: $rdy_player_list (prize: $game_prize)"
} else {
putquick "PRIVMSG $chan :No regs atm."
}
} else {
putquick "PRIVMSG $chan :Prize not set, so no regs stats."
}
}
putlog "lottery.tcl ver 0.2 by tomekk loaded"
sorry my bad..DasBrain wrote:The documentation for the script is essentially:
#well just read the script, you'll understand :p
Code: Select all
https://pasteboard.co/JZrJCsh.jpg
Code: Select all
https://pasteboard.co/JZrK1ov.jpg
Code: Select all
proc start_proc { nick uhost hand chan arg } {
global max_players game_status started_by lottery_setup_for_ops
if {$lottery_setup_for_ops == 1} {
if {[isop $nick $chan] == 0} {
putquick "PRIVMSG $chan :Sorry, @ needed."
return
}
}
if {$game_status == 0} {
set players_num [lindex [split $arg] 0]
if {[regexp {^([0-9]+)$} $players_num]} {
set max_players $players_num
set game_status 1
set started_by "$nick <$uhost>"
}
} else {
putquick "PRIVMSG $chan :Lottery already started by: $started_by"
}
}
Code: Select all
proc start_proc { nick uhost hand chan arg } {
global max_players game_status started_by lottery_setup_for_ops
if {$lottery_setup_for_ops == 1} {
if {[isop $nick $chan] == 0} {
putquick "PRIVMSG $chan :Sorry, @ needed."
return
}
}
putserv "PRIVMSG $chan :ok, tryin' to start"
if {$game_status == 0} {
set players_num [lindex [split $arg] 0]
if {[regexp {^([0-9]+)$} $players_num]} {
set max_players $players_num
set game_status 1
set started_by "$nick <$uhost>"
} else {
putserv "PRIVMSG $chan :Syntax is !start <nb players>"
}
} else {
putquick "PRIVMSG $chan :Lottery already started by: $started_by"
}
}
Code: Select all
# Author: tomekk
# e-mail: tomekk/@/tomekk/./org
# home page: http://tomekk.org/
#
# Version 0.2
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html
# lottery setup (stop/start/prize) only for channel ops?
# 1 - only ops
# 0 - everyone
set lottery_setup_for_ops 0
bind pub - !start start_proc
bind pub - !stop stop_proc
bind pub - !prize prize_proc
bind pub - !lottery lottery_proc
bind pub - !reg reg_proc
bind pub - !regs regs_proc
proc set_defaults {} {
global game_status game_prize reg_status max_players player_list started_by
set game_status 0
set game_prize "0"
set reg_status 0
set max_players 0
set player_list [list]
set started_by ""
}
set_defaults
proc start_proc { nick uhost hand chan arg } {
global max_players game_status started_by lottery_setup_for_ops
if {$lottery_setup_for_ops == 1} {
if {[isop $nick $chan] == 0} {
putquick "PRIVMSG $chan :Sorry, @ needed."
return
}
}
putserv "PRIVMSG $chan :ok, tryin' to start"
if {$game_status == 0} {
set players_num [lindex [split $arg] 0]
if {[regexp {^([0-9]+)$} $players_num]} {
set max_players $players_num
set game_status 1
set started_by "$nick <$uhost>"
} else {
putserv "PRIVMSG $chan :Syntax is !start <nb players>"
}
} else {
putquick "PRIVMSG $chan :Lottery already started by: $started_by"
}
}
proc stop_proc { nick uhost hand chan arg } {
global game_status lottery_setup_for_ops
if {$lottery_setup_for_ops == 1} {
if {[isop $nick $chan] == 0} {
putquick "PRIVMSG $chan :Sorry, @ needed."
return
}
}
if {$game_status == 1} {
putquick "PRIVMSG $chan :Lottery wiped."
set_defaults
} else {
putquick "PRIVMSG $chan :Lottery not started."
}
}
proc prize_proc { nick uhost hand chan arg } {
global game_status reg_status max_players game_prize lottery_setup_for_ops
if {$lottery_setup_for_ops == 1} {
if {[isop $nick $chan] == 0} {
putquick "PRIVMSG $chan :Sorry, @ needed."
return
}
}
if {$game_prize == ""} {
if {$game_status == 1} {
if {$arg != ""} {
set game_prize $arg
set reg_status 1
putquick "PRIVMSG $chan :Lottery starting! Max users: $max_players (prize: $game_prize)"
}
} else {
putquick "PRIVMSG $chan :Lottery not started."
}
} else {
putquick "PRIVMSG $chan :Prize already set: $game_prize"
}
}
proc lottery_proc { nick uhost hand chan arg } {
global game_status game_prize max_players started_by
if {$game_status == 1} {
if {$game_prize != ""} {
putquick "PRIVMSG $chan :Lottery started by: $started_by, max players: $max_players, prize: $game_prize"
} else {
putquick "PRIVMSG $chan :Lottery started by: $started_by, max players: $max_players, prize: *not set*"
}
} else {
putquick "PRIVMSG $chan :Lottery not started."
}
}
proc reg_proc { nick uhost hand chan arg } {
global reg_status player_list max_players game_status game_prize
if {$reg_status == 1} {
set player_exists 0
foreach new_player $player_list {
set gimme_host [lindex [split $new_player ";"] 1]
if {$gimme_host == $uhost} {
set player_exists 1
break
}
}
if {$player_exists == 0} {
lappend player_list "$nick;$uhost"
if {[llength $player_list] == $max_players} {
set lottery_winner [expr {int(rand() * $max_players)}]
set the_winner_is [lindex [split [lindex $player_list $lottery_winner] ";"] 0]
putquick "PRIVMSG $chan :Ok we have a winner ! $the_winner_is"
set_defaults
}
}
} else {
putquick "PRIVMSG $chan :Prize not set, can't register - sorry."
}
}
proc regs_proc { nick uhost hand chan arg } {
global reg_status max_players game_prize player_list
if {$reg_status == 1} {
set current_in [llength $player_list]
set rdy_player_list [list]
foreach lt_player $player_list {
if {$lt_player != ""} {
set need_only_nick [lindex [split $lt_player ";"] 0]
lappend rdy_player_list $need_only_nick
}
}
if {$rdy_player_list == ""} {
set rdy_player_list "-"
} {
set rdy_player_list [join $rdy_player_list ", "]
}
if {$current_in > 0} {
putquick "PRIVMSG $chan :Regs atm $current_in/$max_players: $rdy_player_list (prize: $game_prize)"
} else {
putquick "PRIVMSG $chan :No regs atm."
}
} else {
putquick "PRIVMSG $chan :Prize not set, so no regs stats."
}
}
putlog "lottery.tcl ver 0.2 by tomekk loaded"
Code: Select all
<@JohnDoe> !start
<@Janebot> ok, tryin' to start
<@Janebot> Syntax is !start <nb players>
<@JohnDoe> !start 10
<@Janebot> ok, tryin' to start
<@JohnDoe> !lottery
<@Janebot> Lottery started by: JohnDoe <jd@[censored].happens>, max players: 10, prize: 1000000
Code: Select all
<@JohnDoe> !start 4
<@Janebot> ok, tryin' to start
<@testers> !prize 1000000000
<@Janebot> Prize already set: 1000000
<@testers> !regs
<@Janebot> Prize not set, so no regs stats.
<@testers> !reg
<@Janebot> Prize not set, so no regs stats.