 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Thu Feb 26, 2009 7:33 pm
Sometimes this works, sometimes this doesn't. What am I missing? |
I have a script that emails notes to me. The note output ALWAYS looks like this:
Code: |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From : Charneus: Note Email script
Forum : Personal - #70048
To : charneus
Date : Tue Feb 24 17:42:59 2009
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is just a note to show how notes are supposed to look in the email.
Sometimes, it hits it dead on, other times it doesn't. Not sure what is
causing this, but it's annoying, and needs to be fixed.
The length of the note doesn't seem to matter. I've had short notes that were
formatted incorrectly and long notes that were, and vice versa.
Hopefully, this is an easy fix and someone can hit me upside the head for such
a simple thing.
Charneus
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Sometimes, my email script mails it to me correctly, without a flaw. Other times, it does things like this note:
Code: |
~
>From : Kyroda: Re: Paladin Spells
Forum : Feedback - #4247
To : all Accora
Date : Thu Feb 26 10:21:23 2009
~
Reply to: Idea note 1950 posted by Accora
I used to play paladin and I'll say I almost never practiced damnation or
even bothered using it when I did because before you can even 100% it yougain access to spirit strike which seemed to be much more powerful anyway.I like this idea.. lets dooo eeeeet.-Kyroda~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Or...
Code: |
~
>From : Kyroda: Re: Paladin Spells
Forum : Feedback - #4247
To : all Accora
Date : Thu Feb 26 10:21:23 2009
Reply to: Idea note 1950 posted by AccoraI used to play paladin and I'll say I almost never practiced damnation oreven bothered using it when I did because before you can even 100% it yougain access to spirit strike which seemed to be much more powerful anyway.I like this idea.. lets doooeeeeet.-Kyroda~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
As you can see, the last two examples make it very hard to read. Here's what I'm using for the script:
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<class name="NoteEmailer" copy="yes">
<alias name="note" copy="yes">
<value>#T+ "NoteEmail";~note %0;echo Note read!</value>
</alias>
<var name="noteall" copy="yes"></var>
<var name="notesubj" copy="yes"></var>
<trigger name="NoteBody" priority="13630" copy="yes">
<pattern>(*)</pattern>
<value>#VAR noteall %concat( @noteall, %1,%lf)</value>
</trigger>
<trigger name="NoteEmail" priority="13640" copy="yes">
<pattern>^([~~])$</pattern>
<value>#VAR noteall %concat(%1,%lf)</value>
<trigger enabled="false">
<pattern>^(From%s:%s%w: (*))$</pattern>
<value>#VAR noteall %concat(@noteall,%1,%lf)
#VAR notesubj %2</value>
</trigger>
<trigger enabled="false">
<pattern>^(Forum%s:%s(*))$</pattern>
<value>#VAR notesubj %concat(%2," - ",@notesubj)
#VAR noteall %concat(@noteall,%1,%lf)</value>
</trigger>
<trigger enabled="false">
<pattern>^(To%s:%s*)$</pattern>
<value>#VAR noteall %concat(@noteall,%1,%lf)</value>
</trigger>
<trigger enabled="false">
<pattern>^(Date%s:%s*)$</pattern>
<value>#VAR noteall %concat(@noteall,%1,%lf)</value>
</trigger>
<trigger enabled="false">
<pattern>^([~~])$</pattern>
<value>#VAR noteall %concat(@noteall,%1,%lf)
#T+ "NoteBody"</value>
</trigger>
<trigger enabled="false">
<pattern>^[~~]$</pattern>
<value>#T- "NoteBody"</value>
</trigger>
<trigger enabled="false">
<pattern>^Note read!$</pattern>
<value>#T- "NoteEmail"
sendnote "xxxxxxxx@xxxxxl.com" @notesubj @noteall</value>
</trigger>
</trigger>
<trigger priority="13730" copy="yes">
<pattern>^INFO: New post #%d in forum (%w) from %w Subj: *</pattern>
<value>board %1;note</value>
</trigger>
<trigger priority="13740" copy="yes">
<pattern>^No more new posts in the %w forum.</pattern>
<value>#T- "NoteEmail"</value>
</trigger>
</class>
</cmud>
|
I've actually replaced the %lf with %crlf, and it didn't help. In fact, it just doubled the spaces in between.
I'm not sure what's going on, why it works part of the time, and fails to work the remainder of the time. I would appreciate some feedback in getting this resolved.
Thanks!
Charneus |
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Fri Feb 27, 2009 1:33 am |
I thought that was quite the mess so I entirely restructured it to use loopline states. I changed all the %lf references to %cr. It sdhould work either way. Since the 'var=something' syntax is faster then '#VAR var something' I switched all of those. I also set the variables to "Use default" since the data doesn't need to be saved. Finally all the priorities were adjusted and the Stop flag is set on states appropiately.
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<class name="NoteEmailer" copy="yes">
<var name="noteall" usedef="true" copy="yes"/>
<var name="notesubj" usedef="true" copy="yes"/>
<trigger priority="13730" stop="true" copy="yes">
<pattern>^INFO: New post #%d in forum (%w) from %w Subj: *</pattern>
<value>board %1;note</value>
</trigger>
<trigger name="NoNotes" priority="1" case="true" stop="true" copy="yes">
<pattern>^No more new posts in the %w forum.$</pattern>
<value>#STATE NoteCap 0
#T- NoteTimeout</value>
</trigger>
<trigger name="NoteCap" type="Command Input" priority="1" stop="true" copy="yes">
<pattern>^note</pattern>
<value>noteall=""
#T+ NoteTimeout
#T+ NoNotes</value>
<trigger case="true">
<pattern>^From%s:%s%w: (*)$</pattern>
<value>noteall=%concat(@noteall,%line,%cr)
notesubj=%1
#T- NoteTimeout
#T- NoNotes</value>
</trigger>
<trigger case="true">
<pattern>^Forum%s:%s(*)$</pattern>
<value>notesubj=%concat(%2," - ",@notesubj)
noteall=%concat(@noteall,%line,%cr)</value>
</trigger>
<trigger type="Loop Lines" param="5">
<value>noteall=%concat(@noteall,%line,%cr)
#IF (%begins(%line,"~")) {
#STATE NoteCap 5
}</value>
</trigger>
<trigger>
<pattern>*</pattern>
<value>#ECHO Error capturing note!! Please try again.
#STATE NoteCap 0</value>
</trigger>
<trigger type="Loop Lines" param="30">
<value>noteall=%concat(@noteall,%line,%cr)
#IF (%begins(%line,"~")) {
sendnote "xxxxxxxx@xxxxxl.com" @notesubj @noteall
#STATE NoteCap 0
#THREAD "note" {#WAIT 2000;note}
}</value>
</trigger>
<trigger>
<pattern>*</pattern>
<value>noteall=%concat(@noteall,%line,%cr)
#IF (%begins(%line,"~")) {
sendnote "xxxxxxxx@xxxxxl.com" @notesubj @noteall
#STATE NoteCap 0
#THREAD "note" {#WAIT 2000;note}
} {
#STATE NoteCap 5
}</value>
</trigger>
</trigger>
<trigger name="NoteTimeout" type="Alarm" copy="yes">
<pattern>*10</pattern>
<value>#ECHO Note capture timed out!!
#STATE NoteCap 0
#T- NoteTimeout
#T- NoNotes</value>
</trigger>
</class>
</cmud> |
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Feb 27, 2009 2:53 am |
It's still doing some of the same things, like cutting off ~'s, and it's no longer showing the ~'s as the header, though I can fix that by adding an additional state at the beginning and incrementing the others by one. I do like the approach, though. Hmmmm...
Also, if I type 'note read again,' it'll work, but it stops all my other triggers from firing for a number of seconds, as well.
Charneus |
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Feb 27, 2009 3:04 am |
On a second glance here, it's only doing half of the ~s for the first two sets, and doing the full line at the foot. I may also need to change it up a little so that it will correctly parse things within the note, like if someone puts %cr in a note or whatnot. %string, maybe?
Charneus |
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Fri Feb 27, 2009 5:32 am |
No longer showing the '~'s as a header was by design. I thought that line was unnecessary.
Showing only half of the ~'s in any line is a bug. The tilde as a quote character is only supposed to have meaning outside of quotes in CMud (zMud treated all tildes as special). All string usages are supposed treated as though they are in quotes. You should bug report the specific case in handling tildes that is causing half of them to be lost, as it indicates an error where the string handling is not right.
The only possible problem I can see with my script is iff someone uses '~' in thier note and it happens to be the first character of a line. This can easily be dealt with by increasing the number of tildle in the various %begins tests. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Feb 27, 2009 7:54 am |
Yeah, the line isn't really necessary. I like it for aesthetic purposes. As far as only showing half the tildes, it only does it (with your script, anyway) for the first showing. The very last one shows the entire line.
One thing that was happening (and was ultimately creating a problem) was it wouldn't let any other scripts fire for couple of seconds afterward, and I'm not sure why. The reason why this creates a problem is because a.) I log all chats, and it was not capturing the ones right after the notes and b.) if my spells wore off within seconds after the note was read, it would not fire the proper triggers.
In any case, I'll report the bugs on tildes being lost here shortly.
Thanks for the script, by the way! I didn't mean for it to go by unappreciated.
Charneus |
|
|
 |
|
|
|
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
|
|