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
Aennor
Apprentice


Joined: 06 Dec 2001
Posts: 131
Location: USA

PostPosted: Mon Jan 14, 2002 11:35 pm   

Help needed with logging to a file
 
I'm attempting to write a script (actually modify one that Charbal provided that I can't get to work for me). I want to be able to read my mail and automagically log it to a file. I want to strip out page prompts and I want it to close the file again whenever I'm done.

This seems so simple to me but for the life of me I can't get it to work.

Here's what I came up with so far:

#CLASS {MailLog}
#VAR filenum {1}
#VAR filename {maillog.txt}
#TRIGGER {There is something written upon it:$$ ~* ~* ~* ~* Wheel of Time Mail System ~* ~* ~* ~*} {#t+ {MailLog|Log};#file @filenum @filename}
#CLASS {MailLog|Log}
#TRIGGER {^(%*)$} {#if %1="~* Press ~<Return~> to continue, q to quit ~*~>" {#cr};#if %1="^[o|~*] * > $" {#t- {MailLog|Log};#close @filenum};#if %1="^~* Press ~<Return~> to continue, q to quit ~*~>$" {#cr;#gag -1;#gag};#write @filenum %1;} "" {"prompt"}
#CLASS 0

A mail message will look like this:

* * * * Wheel of Time Mail System * * * *
Date: Thu Dec 20 23:28:57 2001
To: Aennor
From: Lysette

blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah

* Press <Return> to continue, q to quit *>
blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah

And then the prompt (that I want to close the file) always begins with a "o" or a "*" and ends with a "> ". Example:

* I104 R:14399 S:Inside >

I'm also trying to strip out the paging prompt and the line before it in the log... I *know* this is possible... I'm just a bit frustrated.

I don't even have a consistent error to point at... it just doesn't work! *pout* :P

Can someone lend a hand?

TIA for any help.



--
Aennor the Paragon of Gratuitous Agony
Staff on WoTMUD
wotmud.org 2222
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Jan 15, 2002 1:59 am   
 
Step 1 to fixing it put "'s around %1 in the trigger! You are using %* in your patter and without those quotes your script could fry your stuff. All someone would have to do is mail you with "HI;;#KILLALL;Bye have a nice day" and it wouldn't be a nice day.

Step 2 remove the ~'s from inside the text you have quotes around. The quotes overide parsing of special characters meaning it won't match until your mud starts sending ~'s.

Step 3 Pattern matching is for trigger patterns, not if statements. Remove the ^ and $ where appropriate.

Step 4 Rewrite the if statement that currently compares %1="^[o|~*] * > $". I will give you the solution to this one:
#IF ((%begins("%1","o")|%begins("%1","*"))&%ends("%1","> ")) {#T- {MailLog|Log};#CLOSE @FileNum}
Reply with quote
Aennor
Apprentice


Joined: 06 Dec 2001
Posts: 131
Location: USA

PostPosted: Tue Jan 15, 2002 3:38 am   
 
Ah, I see.. thank you for the help.

Of course the mud crashed when I saw this (critical need detector :P) so I'll check in a little bit.

This is what I end up with based on your comments though:

#CLASS {MailLog}
#VAR filenum {1}
#VAR filename {maillog.txt}
#TRIGGER {There is something written upon it:$$ ~* ~* ~* ~* Wheel of Time Mail System ~* ~* ~* ~*} {#t+ {MailLog|Log};#file @filenum @filename}
#CLASS {MailLog|Log}
#TRIGGER {^(%*)$} {#IF "%1"="* Press Return to continue, q to quit *>" {#CR} {#IF ((%begins( "%1", "o")|%begins( "%1", "*"))&%ends( "%1", "> ")) {#T- {MailLog|Log};#CLOSE @FileNum}{#write @filenum "%1"}}} "" {"prompt"}
#CLASS 0

Did I understand you correctly?

--
Aennor the Paragon of Gratuitous Agony
Staff on WoTMUD
wotmud.org 2222
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Jan 15, 2002 4:41 am   
 
Looks like you got it all beautiful. Hope everything works right. If you have the maillog class on all the time you might wish to change the 3 line trigger to 2 one line triggers if you mudding runs a little slow. If you are interested in doing that look at what I posted here http://www.zuggsoft.com/forum/topic.asp?TOPIC_ID=5199&FORUM_ID=7&CAT_ID=1&Topic_Title=Text+Capturing+problem&Forum_Title=zMUD+General+Discussion and adapt it your situation.
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