proc ::comm::detect { nick uhost hand chan rest } {
#what i need to write this for get command1 or command2 or command3
return 0
}
bind pub - "!command1" ::comm::detect
bind pub - "!command2" ::comm::detect
bind pub - "!command3" ::comm::detect
proc ::comm::detect { nick uhost hand chan rest } {
#what i need to write this for get command1 or command2 or command3
return 0
}
bind pub - "!command1" ::comm::detect
bind pub - "!command2" ::comm::detect
bind pub - "!command3" ::comm::detect
it would help if we knew what you were trying to accomplish...ergo, what command?
Sounds like you're looking for the global variable named 'lastbind'.
But then you'd have to update the proc if you change the binds... a way to get around this would be to add an argument to the code in your binds:
bind pub - !cmd1 {theProc 1}
bind pub - !cmd2 {theProc 2}
proc theProc {cmd nick uhost hand chan arg} {
# $cmd = 1 or 2 depending on what bind was used
}
nml375 wrote:A more generic way of doing it would be to use the "lastbind" global variable
Well, I did mention lastbind in my first sentence... I don't know what's "more generic" about it though
My point was to avoid having to update the proc if the keywords change...and you could have several keywords triggering the same command without having to add words to the switch statement:
Must've been reading your post too quickly I suppose, my bad.
Advantages of using 'lastbind', imho, is the possibility of wildcard matching, no need to keep track of additional parameters when creating the binding (you can continue to use the same number of parameters as with any other binding of that kind). I also find it easier to use when adding/removing commands/functions to the triggers.
I guess my biggest consern with using added parameters, is to make sure users don't remove/forget the use of list. Last example of yours was nice tho.