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.

TCL bind is a Regex?

Help for those learning Tcl or writing their own scripts.
Post Reply
p
pzOr
Voice
Posts: 8
Joined: Fri Feb 26, 2010 12:43 am

TCL bind is a Regex?

Post by pzOr »

So is it possible? And how should I do it?

-> I have decent TCL capablities, and i can easily read up on code and understand it.

I haven't found however anything, anywhere on how to have a Regular Expression as a bind.

Let's say Youtube for instance.
Someone would type a link
http://youtube.com/watch?v=12121212121

By testing what was typed against my regex, it would then enter my proc to query youtube.
I just need the first part, a functional regex bind, which can work like this:

Nick: http://youtube.com/watch?v=12121212121
Nick: Here is my video http://youtube.com/watch?v=12121212121
Nick: www.youtube.com/watch?v=121212121&featured

I can create my own regex tho, after i know how to enter a proc if it matches.

Seeing as how every code i've seen, has a specific bind to a proc.

Thanks.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Have you checked 'bind pubm' ?
Once the game is over, the king and the pawn go back in the same box.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

The pubm binding only supports glob-style patterns, no regex pattern. Unfortunately, glob-patterns aren't that powerful.
I'd probably use a rough glob-pattern to look for "% *youtube.com*", and do some more advanced matching within the proc, using regexp and/or regsub
NML_375
p
pzOr
Voice
Posts: 8
Joined: Fri Feb 26, 2010 12:43 am

Post by pzOr »

I just finished doing this, just as your helped arrived, but i was too stressed :P

Took me a while tho. I did exactly what nml375 suggested.

Here it is:

Code: Select all

bind pubm - "% *http://*website-name*" handle_gameurl

set watch [regexp -nocase -- {(?:http://www\.)?site\.com/.{0,2}code/([-_0-9A-Za-z]+)&?.*?} $text url gameid]	

if {$watch} {
	
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

@nml375 : A "% *youtube.com*" pubm bind is exactly what I had in mind when suggested it in the first place, although I should have mentioned that too. :)
Once the game is over, the king and the pawn go back in the same box.
Post Reply