| View previous topic :: View next topic |
| Author |
Message |
terron Voice
Joined: 11 Oct 2010 Posts: 3
|
Posted: Mon Oct 11, 2010 2:34 am Post subject: I need help with binding multiple commands to one proc |
|
|
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 |
|
 |
thommey Halfop
Joined: 01 Apr 2008 Posts: 73
|
Posted: Mon Oct 11, 2010 6:43 am Post subject: |
|
|
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 |
|
 |
|
|
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
|
|