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 

I need help with binding multiple commands to one proc

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


Joined: 11 Oct 2010
Posts: 3

PostPosted: Mon Oct 11, 2010 2:34 am    Post subject: I need help with binding multiple commands to one proc Reply with quote

I have a bind,
Code:
 bind pub - !sysinfo pub:syscmd

What I'd like to do is something like this:
Code:

bind pub - !sysinfo pub:syscmd(sysinfo)
bind pub - !date pub:syscmd(date)
etc


So that I can have just one proc for the command rather than having to copy/paste it (and keep the code synced when I want to make changes) for each command I add.

Is this possible?

Additionally, it'd be great if there was some way to only have one bind with some sort of boolean to only match the specific commands I want to add and then reference the matched text in the command, but I can't find anything in the reference manuals. Something like
Code:

bind pub - !{sysinfo|date} pub:syscmd($matchedtext}
but I can't find that in the manual either.

Any help would be greatly appreciated. Thanks
[/code]
Back to top
View user's profile Send private message
thommey
Halfop


Joined: 01 Apr 2008
Posts: 73

PostPosted: Mon Oct 11, 2010 6:43 am    Post subject: Reply with quote

If you need an additional static parameter, use this:
Code:

bind pub - !sysinfo "myproc sysinfo"
bind pub - !bla "myproc bla"
proc myproc {param nick host hand chan text} {
# $param is now either "sysinfo" or "bla"
}

If you want to know which bindmask (trigger for bind pub) matched, do this:
Code:

bind pub - !sysinfo myproc
bind pub - !bla myproc
proc myproc {nick host hand chan text} {
# $::lastbind contains either "!sysinfo" or "!bla" here
}

If you want a generic bind and do the matching yourself, use a bind type that supports wildcards instead of pub/msg (resp. pubm/msgm)
Code:

# % is a one word wildcards and stands for channel here
bind pubm - "% *" myproc
proc myproc {nick host hand chan text} {
# $text contains the full text including !bla/!sysinfo as first word
}

The last thing you suggest is not possible. However, it just seems to be a shortcut to binding all commands to the respective proc, which you could just do with a loop
Code:

set trigger !
foreach cmd {sysinfo bla uptime foobar} {
bind pub - ${trigger}$cmd "myproc $cmd"
}

here's the reference manual explaining bind types
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