| View previous topic :: View next topic |
| Author |
Message |
wier Voice
Joined: 16 Oct 2010 Posts: 2
|
Posted: Sat Oct 16, 2010 11:03 am Post subject: Bind a formatted string |
|
|
Hi,
i am trying to build a bind for a formatted string..
If User writes the following text into the channel, i would like to trigger a proc
<User> This is a test
i thought this would be it, but it doesn't work
| Code: | bind pubm - "\0034\026This is a test" pub_test
proc pub_test {nick mask hand channel args} {
puthelp "PRIVMSG $channel: Test"
} |
and to check, if "User" wrote the text, i can check it with
| Code: | | if($nick ne "User") {...} |
but.. as i said.. it doesn't work like this..
thanks for help  |
|
| Back to top |
|
 |
username Op

Joined: 06 Oct 2005 Posts: 196 Location: Russian Federation, Podolsk
|
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sat Oct 16, 2010 12:11 pm Post subject: Re: Bind a formatted string |
|
|
| wier wrote: | Hi,
i am trying to build a bind for a formatted string..
If User writes the following text into the channel, i would like to trigger a proc
<User> This is a test
i thought this would be it, but it doesn't work
| Code: | bind pubm - "\0034\026This is a test" pub_test
proc pub_test {nick mask hand channel args} {
puthelp "PRIVMSG $channel: Test"
} |
|
Because you've chosen to bind on a pubm rather than pub.
| Code: | | bind pubm - "\0034\026This is a test" pub_test |
To make this work, it would need to look like this...
| Code: | | bind pubm - "\0034\026This is a test*" pub_test |
Now it's a mask, notice the wildcard * at the end? To make it work as a regular pub bind, and not one masked, use:
| Code: | | bind pub - "\0034\026This is a test" pub_test |
Also...about "args"...
| Code: | | proc pub_test {nick mask hand channel args} { |
Here it serves no purpose. Your bind will pass a single-argument as the text the user entered. You've chosen to capture this into "args" which will allow multiple arguments. Therefore, your captured text will be conveyed instead as a list, not as a string. So rather than craft ways to convert this list back into a string for processing. Craft your procedure header correctly, like this:
| Code: | proc pub_test {nick mask hand channel arg} {
--or--
proc pub_test {nick mask hand channel text} {
--or--
proc pub_test {nick mask hand channel literally_anything_but_args} { |
_________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
wier Voice
Joined: 16 Oct 2010 Posts: 2
|
Posted: Thu Oct 21, 2010 3:15 am Post subject: |
|
|
First of all thanks for your help.
Unfortunately it didn't work like wanted it to..
Thats why, I tried to change the way I am handling the problem.
The idea is, to allow a bot-command only between two certain commands of another bot..
| Code: |
bind pubm - * test
proc test {nick host hand chan text} {
global flag
if {[string equal -nocase "!test" $text]} {
if {[$flag==0]} {
puthelp "NOTICE $nick :This a test" }
}
}
elseif {[string equal -nocase "*startpoint*" $text]} {
set flag 1
}
elseif {[string equal -nocase "*endpoint*" $text]} {
set flag 0
}
} |
but unfortunatly the if/elseif equations are never reached.
So my first question is, where the mistake is in my code, and secondly I would like to know, wheather a coloured text would trigger the proc.
Thanks,
wier |
|
| Back to top |
|
 |
thommey Halfop
Joined: 01 Apr 2008 Posts: 73
|
|
| 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
|
|