Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Bofinth
Newbie


Joined: 01 May 2002
Posts: 0
Location: Netherlands

PostPosted: Fri Mar 29, 2002 7:47 am   

My URL-grabbing script doesn't catch tildes
 
I've been trying to write a trigger that will find any URLs in the text sent from the MUD and list them in a separate window, as well as putting the last one in a variable so that I can make a button to bring it up in my browser.

Here's what I have so far:

Trigger-> (%a://%*%a)
Value---> #VA lasturl = %expand( %1, 1)
#WIN URLs %expand( %1, 1)

Trigger-> ([a-zA-Z0-9_~-].[a-zA-Z0-9_~-].%w%*%a)
Value---> #VA lasturl = %expand( %1, 1)
#WIN URLs %expand( %1, 1)

I need two triggers, actually, because there are two different formats of URLs I want to capture-- the ones that start with http:// (or telnet:// or ftp:// etc) and the ones that just start with server.domain.suffix. The second pattern will match most of the ones that match the first, but not all (for instance, telnet URLs). I haven't yet figured out a way to match both with one pattern, and if I try to put both patterns in the same trigger with a pipe between them, it doesn't seem to work.

But what's really stumping me now is that if the URL has a tilde in it, which they frequently do, zMUD interprets it as the quote character when handling the matched string, which makes it go away and renders the URL inoperable (eg, members.aol.com/~gronf becomes members.aol.com/gronf). I've tried %expand, %quote, and %literal on %1 to try to make the tildes stay in place, without any luck. I've also tried disabling the quote character on the URLs window; that doesn't help either. It does work if I turn off the quote character on my main connection window... but I'd rather not do that, to avoid messing with other scripts.

Any suggestions?
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Fri Mar 29, 2002 9:25 am   
 
The other idea is to temporary change
your special character before you work with
%1 maybe.

I haven't tested this myself, but I found this
just recently and was going to explore it
for some log processing:

quote:

DEFAULT

Syntax: #DE [special-char-string]
Related: #NODEF

Saves your current special characters on the stack and sets the defaults. This is useful at the beginning of a script to make sure standard parse characters are used while reading the script. Use the #NODEF command at the end of the script to restore the characters.
A string can be given as an argument to specify the new values of the special characters. This is a 9 character string which must be enclosed in quotes. Each character in the string represents one of the special characters. To leave the character as the default, you can use the x character as a placeholder. The characters are:

1 Command Char (#)

2 Separator Char (;)

3 Variable Char (@)

4 History Char (!)

5 Parameter Char (%)

6 Movement Char (.)

7 Focus Char (:)

8 Quote Char (~)

9 Must be a space at the end

DEFAULT example

#DEF

Saves your special characters and restores the defaults

#DEF {xx$xxxxx }

Saves your special characters, then restores defaults, then sets the Variable char (3rd char in string) to $.






Ton Diening
Reply with quote
Bofinth
Newbie


Joined: 01 May 2002
Posts: 0
Location: Netherlands

PostPosted: Fri Mar 29, 2002 6:06 pm   
 
I tried the following for a value, to temporarily set the quote character to the backslash:


#DEF {xxxxxxx }
#VA lasturl = %1
#WIN URLs %1
#NODEF

But it didn't change anything. It looks as though the tildes are being parsed as quote characters at the moment that the matching pattern is put into %1. There isn't any way to change the special characters before the trigger activates and then change them back, is there?

I have another idea that might work, though I don't have time right now to work on it. Maybe if I set up a trigger in my main window to #CAPTURE a whole line to my URLs window if it contains a URL. Then in my URLs window, which has the quote character disabled, I can have a trigger to separate out the URL, gag the incoming line and just show the URL.

I'll report back on that when I've tried it...
Reply with quote
Bofinth
Newbie


Joined: 01 May 2002
Posts: 0
Location: Netherlands

PostPosted: Sat Mar 30, 2002 5:29 am   
 
That idea worked, basically. I had to leave the quote character enabled, because I need to match domain names against the range [a-zA-Z0-9_-] and the hyphen needs to be quoted, so I changed it to the backslash character instead. I don't recall ever seeing a URL with a backslash in it, so hopefully that will be ok.

I did encounter one strange bit of behavior from zMUD that I don't understand. I had my two triggers set up in the main window so that each line with a URL got sent to the URLs window once and only once. Then I had two matching triggers in the URLs window that found the URL in the line, gagged the line, echoed the URL, and put the URL in the @lasturl variable. The values for both of these triggers (in the URLs window) were identical; only the trigger patterns were different. Originally I had them set @lasturl with the syntax "lasturl = %1", but when I did that, @lasturl was only set by the trigger that found URLs not starting with "%w://" -- even though both triggers were working to gag the incoming line and show the URL. When I changed the syntax to "#VAR lasturl %1" in both triggers, they both set the variable properly.

Bug or feature? Anyone?
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
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

© 2009 Zugg Software. Hosted by Wolfpaw.net