set family {
pubchan #chan1
famchan #chan2
capochan #chan3
topchan #chan4
}
proc test {nick host handle chan args} {
global family
set fam [split [string trim $family] "\n"]
set pubchan [lindex [split [string trim [lsearch -inline $fam "*pubchan *"]]] 1]
set famchan [lindex [split [string trim [lsearch -inline $fam "*famchan *"]]] 1]
set capochan [lindex [split [string trim [lsearch -inline $fam "*capochan *"]]] 1]
set topchan [lindex [split [string trim [lsearch -inline $fam "*topchan *"]]] 1]
putserv "PRIVMSG $chan :pubchan is $pubchan, famchan is $famchan, capochan is $capochan, topchan is $topchan"
}
set family {
pubchan #chan1
famchan #chan2
capochan #chan3
topchan #chan4
}
proc test {nick host handle chan text} {
array set fam $::family
puthelp "PRIVMSG $chan :pubchan is $fam(pubchan), famchan is $fam(famchan), capochan is $fam(capochan), topchan is $fam(topchan)"
}
Worth mentioning,
array set expects a valid list of key-value pairs as input. For a trivial case, you'll be able to craft lists by hand; though I generally recommend using the list command for building more complex lists. This is especially important if you have strings containing spaces or brackets/braces.
mrNobody wrote:I'm learning a lot of tcl principles by looking at your beer.tcl script, but the lack of comments makes it difficult to decipher sometimes xD
Nice to hear you gather inspiration from my beer:)
Sorry there are few comments in the script, but at least it's short.
I would be glad to answer any specific questions you have about beer.
You can always contact me here, or at the contact info in beer.tcl
Last edited by SpiKe^^ on Sat Dec 21, 2013 3:25 pm, edited 2 times in total.