| View previous topic :: View next topic |
| Author |
Message |
daigo Voice
Joined: 27 Jun 2014 Posts: 37
|
Posted: Sat Jul 26, 2014 1:08 am Post subject: $arg is not being returned? |
|
|
Here is my script:
| Code: |
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? |
|
| Back to top |
|
 |
heartbroken Op

Joined: 23 Jun 2011 Posts: 106 Location: somewhere out there
|
Posted: Sat Jul 26, 2014 2:02 am Post subject: |
|
|
you need bind pub instead of pubm there...
and you already have "global" line for "givechan" in give proc..
you have to choose one of :
global givechan
.. $givechan
or remove "global" line and just use :
.. $::givechan
| Code: | 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
}
}
|
_________________ Life iS Just a dReaM oN tHE wAy to DeaTh |
|
| Back to top |
|
 |
daigo Voice
Joined: 27 Jun 2014 Posts: 37
|
Posted: Sat Jul 26, 2014 2:49 am Post subject: |
|
|
For the last 3 lines, what is the difference between:
and
|
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Thu Jul 31, 2014 6:46 am Post subject: |
|
|
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:
| Code: | # In party-line
.+chan #DaIgO
# In tcl
set givechan "#daigo" |
The eggdrop will see that the channel is #DaIgO, doesn't equal #daigo. _________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
|