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 

TCL bind is a Regex?

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


Joined: 26 Feb 2010
Posts: 8

PostPosted: Sun May 01, 2011 6:09 pm    Post subject: TCL bind is a Regex? Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon May 02, 2011 11:50 am    Post subject: Reply with quote

Have you checked 'bind pubm' ?
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon May 02, 2011 12:43 pm    Post subject: Reply with quote

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


Joined: 26 Feb 2010
Posts: 8

PostPosted: Mon May 02, 2011 2:10 pm    Post subject: Reply with quote

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

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue May 03, 2011 3:08 am    Post subject: Reply with quote

@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. Smile
_________________
Once the game is over, the king and the pawn go back in the same box.
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