This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Help for those learning Tcl or writing their own scripts.
boehmi
Voice
Posts: 14 Joined: Sat Apr 11, 2009 7:55 am
Location: Germany
Post
by boehmi » Wed Apr 22, 2009 5:52 am
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
user
Posts: 1452 Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway
Post
by user » Wed Apr 22, 2009 7:00 am
Code: Select all
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"?
boehmi
Voice
Posts: 14 Joined: Sat Apr 11, 2009 7:55 am
Location: Germany
Post
by boehmi » Sun May 24, 2009 5:53 pm
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"]
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Sun May 24, 2009 6:11 pm
You just use the last variable (arg in user's example):
Code: Select all
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: Select all
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
boehmi
Voice
Posts: 14 Joined: Sat Apr 11, 2009 7:55 am
Location: Germany
Post
by boehmi » Mon May 25, 2009 1:19 am
Ah ok... i thougth the
version would overwrite the default parameters.
Thanks a lot