egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

$arg is not being returned?

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
daigo
Voice


Joined: 27 Jun 2014
Posts: 37

PostPosted: Sat Jul 26, 2014 1:08 am    Post subject: $arg is not being returned? Reply with quote

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
View user's profile Send private message
heartbroken
Op


Joined: 23 Jun 2011
Posts: 106
Location: somewhere out there

PostPosted: Sat Jul 26, 2014 2:02 am    Post subject: Reply with quote

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
View user's profile Send private message
daigo
Voice


Joined: 27 Jun 2014
Posts: 37

PostPosted: Sat Jul 26, 2014 2:49 am    Post subject: Reply with quote

For the last 3 lines, what is the difference between:

Code:
       return 0
      }
 }


and

Code:

      }
  return 0
 }
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Thu Jul 31, 2014 6:46 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber