I believe this quote from the file tcl-commands.doc (comes with the source) explains any and all ways of using pub-bindings...
doc/tcl-commands.doc wrote: (4) PUB
bind pub <flags> <command> <proc>
procname <nick> <user@host> <handle> <channel> <text>
Description: used for commands given on a channel. The first word
becomes the command and everything else is the text argument.
Module: irc
<flags> would be matched against whoever tries to trigger the binding, and the associated command will only be invoked if flags match (similar matching as done by "matchattr"). If flags dont match up, no actions are taken.
This binding also allows you to check against channel-speciffic flags.
<command> is the first word in any line written to the channel. It does not support masks.
Assuming $line would be a line written on a channel, the test would look somewhat like this:
Code: Select all
if {[string equal -nocase <command> [lindex [split $line " "] 0]]} {<proc> <nick> <user@host> <handle> <channel> <text>}
<proc> would be the command-line executed whenever the binding triggers. Five (5) arguments will be added to the end of the command-line as illustrated above.
Looking at some of your previous experimenting (bind pub - [stripcodes bcr "TEST"] search_info), it would seem you're trying to make a binding trigger regardless of wether your users use control-codes or not. Your best choice here, I suppose, would be to use the pubm-binding instead, which allows the use of wildcards (and matches against the whole textline, rather than the first word).
=====================================
Your friends suggestion is (possibly) bad in one way. It relys on upvar and a static variable name, that is, it will always strip the variable named "test" regardless of what variables you use within your script. If you do not have any variable named "test" within the proc you called it from, you'll get an error roughly saing "no such variable test".
A more proper way of doing it would be something like this, which allows you to supply the variable of your choice to be stripped:
Code: Select all
#filter_mirc: remove various control-characters from the supplied variable.
#usage: filter_mirc <varname>
#Returns: The number of characters stripped.
proc filter_mirc {variable} {
upvar $variable text
if {[info exists text]} {
return [regsub -all -- "(\002|\017|\026|\037|\003(\[0-9\]\[0-9\]?(,\[0-9\]\[0-9\]?)?)?)" $text "" text]
} {
error "can't read "$variable": no such variable"
}
}
Even so, I would still recommend the use of stripcodes whenever it's available.