Code: Select all
proc per:say { nick host handle chan text } {
if { [legalchan $text] } {
unset chan
set chan [lindex $text 0]
set text_ [lrange $text 1 end]
unset text
set text $text_
}
putquick "PRIVMSG $chan :[join [lrange $text 0 end]]"
mydebug "Said \"$text\" in $chan requested by $nick ($handle)"
}
proc legalchan { text } {
if { [string index [lindex $text 0] 0] == "#" && [botonchan [lindex $text 0]] } {
return 1
} else {
return 0
}
}
1) I want to make it so the unsetting and setting of variables is in the legalchan proc and will return those values back into the per:say proc. I've also seen something like this related to "return -code" and "upvar" (so I don't have to pass the variables to the legalproc ?)
2) It's not working if I do something like "?say #adsf test" (and the bot isn't on #asdf). I get the error of "Tcl error [per:say]: illegal channel: #asdf." It seems the "botonchan" check isn't working?
3) Is there a "reset" command so I don't have to do unset/set and especially with the $text variable? (unset/set as another name/set again).
Thanks,
scr0llwheel