| View previous topic :: View next topic |
| Author |
Message |
boehmi Voice
Joined: 11 Apr 2009 Posts: 14 Location: Germany
|
Posted: Wed Apr 22, 2009 5:52 am Post subject: Bind: same proc, different arguments |
|
|
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 |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Wed Apr 22, 2009 7:00 am Post subject: Re: Bind: same proc, different arguments |
|
|
| 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 |
|
 |
boehmi Voice
Joined: 11 Apr 2009 Posts: 14 Location: Germany
|
Posted: Sun May 24, 2009 5:53 pm Post subject: |
|
|
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 |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun May 24, 2009 6:11 pm Post subject: |
|
|
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 |
|
 |
boehmi Voice
Joined: 11 Apr 2009 Posts: 14 Location: Germany
|
Posted: Mon May 25, 2009 1:19 am Post subject: |
|
|
Ah ok... i thougth the [list] version would overwrite the default parameters.
Thanks a lot |
|
| Back to top |
|
 |
|