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 

Bind a formatted string

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


Joined: 16 Oct 2010
Posts: 2

PostPosted: Sat Oct 16, 2010 11:03 am    Post subject: Bind a formatted string Reply with quote

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 Smile
Back to top
View user's profile Send private message
username
Op


Joined: 06 Oct 2005
Posts: 196
Location: Russian Federation, Podolsk

PostPosted: Sat Oct 16, 2010 12:01 pm    Post subject: Reply with quote

Try
Code:
bind pubm - "\00304\026This is a test" pub_test
and read this http://forum.egghelp.org/viewtopic.php?p=80884#80884
_________________
Архив TCL скриптов для ботов Eggdrop/Windrop:
http://egghelp.ru/
Back to top
View user's profile Send private message Send e-mail Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sat Oct 16, 2010 12:11 pm    Post subject: Re: Bind a formatted string Reply with quote

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
View user's profile Send private message
wier
Voice


Joined: 16 Oct 2010
Posts: 2

PostPosted: Thu Oct 21, 2010 3:15 am    Post subject: Reply with quote

First of all thanks for your help.
Unfortunately it didn't work like wanted it to.. Wink
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
View user's profile Send private message
thommey
Halfop


Joined: 01 Apr 2008
Posts: 73

PostPosted: Fri Oct 22, 2010 3:00 am    Post subject: Reply with quote

wier wrote:

So my first question is, where the mistake is in my code

Almost everything starting from the second if is syntactically broken, it doesn't follow Tcl syntax. Tcl syntax: http://wiki.tcl.tk/dodekalogue . To see a more fine grained complaint about all your syntax errors (oh, and of course why your braces mismatch - it's easy to see with correct indention + the [] around $flag == 0 is wrong), see: http://paste.tclhelp.net/?id=83i . You should also see errors in your partyline - you absolutely need to see them there to test your Tcl scripts.
wier wrote:

and secondly I would like to know, wheather a coloured text would trigger the proc.

Yes. However, bind pubm does not match against the text only tho, reread the documentation (that's why all pubm binds not being '*' mentioned in this thread never match), http://www.eggheads.org/support/egghtml/1.6.20/tcl-commands.html#binda_pubm and http://www.eggheads.org/support/egghtml/1.6.20/tcl-commands.html#matchchars (the % wildcard is helpful).
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