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 

Bind: same proc, different arguments

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


Joined: 11 Apr 2009
Posts: 14
Location: Germany

PostPosted: Wed Apr 22, 2009 5:52 am    Post subject: Bind: same proc, different arguments Reply with quote

Hi,

is there a possibility for calling the same procedure with different arguments with bind pub?

Like:
bind pub "-|-" !test1 proc1 "test1"
bind pub "-|-" !test2 proc1 "something else"
bind pub "-|-" !test3 proc1 "lalala"

Thanks for your help
Back to top
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Wed Apr 22, 2009 7:00 am    Post subject: Re: Bind: same proc, different arguments Reply with quote

Code:
bind pub - !test1 [list proc1 test1]
bind pub - !test2 [list proc1 "something else"]
proc proc1 {addedArg nick uhost hand chan arg} {...}

_________________
Have you ever read "The Manual"?
Back to top
View user's profile Send private message
boehmi
Voice


Joined: 11 Apr 2009
Posts: 14
Location: Germany

PostPosted: Sun May 24, 2009 5:53 pm    Post subject: Reply with quote

thank you very much, but what if i additionally want to get the arguments?

e.g.
!test1 10
!test1 20
!test2 20

something like
bind pub - !test1 [list proc1 $args test1]
bind pub - !test2 [list proc1 $args "something else"]
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun May 24, 2009 6:11 pm    Post subject: Reply with quote

You just use the last variable (arg in user's example):

Code:
bind pub - !test1 proc1
proc proc1 {nick host handle channel arg} {
  puthelp "PRIVMSG $channel :Hey $nick, thanks for the $arg"
}

The above example will make your eggie echo back whatever people pass as an argument with !test1. If we were to extend this with the previous code, it'd probably look a little like this:
Code:
bind pub - !test1 [list "proc1" "test1"]
bind pub - !test2 [list "proc1" "test2"]
proc proc1 {custom nick host handle channel arg} {
  if {$custom == "test1"} {
    puthelp "PRIVMSG $channel :Hey $nick, thanks for the $arg"
  }
  puthelp "PRIVMSG $channel :*waves*"
}

Here with the added feature that it'll do the echo only for !test1, but the *waves* for both !test1 and !test2.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
boehmi
Voice


Joined: 11 Apr 2009
Posts: 14
Location: Germany

PostPosted: Mon May 25, 2009 1:19 am    Post subject: Reply with quote

Ah ok... i thougth the [list] version would overwrite the default parameters.

Thanks a lot
Back to top
View user's profile Send private message
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