bind pubm - !give give
set givechan "#daigo"
proc give {nick host hand chan arg} {
global givechan
if {$chan eq $::givechan} {
puthelp "PRIVMSG $givechan :Here is $arg for you"
}
return 0
}
But when I do something like: !give milk and cookies
In the channel, but the bot doesn't return anything, not even an error. But if I make the bind pubm as * (bind pubm - * give) then it does work. How come?
set givechan "#daigo"
bind pub - !give pub_give
proc pub_give {nick host hand chan arg} {
# this one is "case sensitive"
if {$chan eq $::givechan} {
# you can use string match -nocase or string equal -nocase
# if {[string match -nocase $::givechan $chan]} {
# if {[string equal -nocase $::givechan $chan]} {
# or add a line outside of the proc , an user defined channel flag
# setudef flag something
# and add a line just under the proc line to check this channel flag
# activated or not
# if {[channel get $chan something]} {
# and no need to set givechan "..."
# do : .chanset #your-channel +something
# voilà if you would go this way ,don't forget to replace all
# $::givechan vars to $chan in proc too...
# !cmd first Word to last Word. it takes whole line.
set given [join [lrange [split $arg] 0 end]]
# if you want to post !cmd first-word :
# set given [lindex [split $arg] 0]
# or if you want to post !cmd three-words :
# set given [join [lrange [split $arg] 0 2]]
puthelp "PRIVMSG $::givechan :Here is $given for you"
return 0
}
}
There's no difference in the placement of the return with this "simple" procedure, but there is a condition in it. So it's better to have the return exactly when needed.
And I agree with the inline comment from heartbroken : use a nocase comparison for channel name, because if you do: