| View previous topic :: View next topic |
| Author |
Message |
pzOr Voice
Joined: 26 Feb 2010 Posts: 8
|
Posted: Sun May 01, 2011 6:09 pm Post subject: TCL bind is a Regex? |
|
|
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. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon May 02, 2011 11:50 am Post subject: |
|
|
Have you checked 'bind pubm' ? _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon May 02, 2011 12:43 pm Post subject: |
|
|
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, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
pzOr Voice
Joined: 26 Feb 2010 Posts: 8
|
Posted: Mon May 02, 2011 2:10 pm Post subject: |
|
|
I just finished doing this, just as your helped arrived, but i was too stressed
Took me a while tho. I did exactly what nml375 suggested.
Here it is:
| Code: |
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} {
|
|
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue May 03, 2011 3:08 am Post subject: |
|
|
@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. |
|
| Back to top |
|
 |
|