Code: Select all
bind pub o "!set" pub:set
proc pub:set {nick host handle chan arg} {
global players
switch -- [lindex $arg 0] {
"players" {
array set players "[strlwr $chan] [list [lrange $arg 1 end]]"
putserv "PRIVMSG $chan :added [llength [lrange $arg 1 end]] players: [lrange $arg 1 end]"
}
}
}
bind pub o "@players" pub:get:players
proc pub:get:players {nick host handle chan arg} {
global players
foreach channel [array names players] {
if {![string match [strlwr $chan] [strlwr $chan]]} {
array set players "[strlwr $chan] 0"
}
}
putserv "PRIVMSG $chan :$players([strlwr $chan])"
}
Code: Select all
set playersfile "players.txt"
bind pub o "!set" pub:set
bind pub o "@players" get:players
if {![file exists $playersfile]} {close [open $playersfile w]}
set file [open $playersfile r]
while {![eof $file]} {
gets $file line
if {[string trim $line] == ""} { continue }
foreach chan [channels] {
if {![string match -nocase [strlwr $chan] [lindex $line 0]]} { continue }
array set players "[strlwr $chan] [lrange $line 1 end]"
putlog "[strlwr $chan] [lrange $line 1 end]"
}
}
close $file
proc pub:set {nick host handle chan arg} {
global players
switch -- [lindex $arg 0] {
"players" {
array set players "[strlwr $chan] [list [lrange $arg 1 end]]"
set file [open "$::playersfile" w]
foreach ch [channels] {
puts $file "$ch $players([strlwr $ch])"
}
catch {close $file}
putserv "PRIVMSG $chan :Added [llength [lrange $arg 1 end]] players: [lrange $arg 1 end]."
}
}
}
proc get:players {nick host handle channel arg} {
global players
if {![info exists players([strlwr $channel])]} {
array set players "[strlwr $channel] 0"
}
putserv "PRIVMSG $channel :Players: $players([strlwr $channel])"
}
Code: Select all
putlog "[strlwr $chan] [lrange $line 1 end]"
Code: Select all
if {[info exists players([strlwr $chan])]} { continue }
and should do fine..if {![string match -nocase [strlwr $chan] [lindex $line 0]]} { continue }
(10:06:27) ::: <caesar> .tcl array get players
(10:06:27) ::: <looser> Tcl: #bla moo