Parsing incoming kmails

dj_d

Member
I'd like to write a script that replies to kmails that contain a particular item with a stock reply. Exceptionally clever readers might even figure out why I want this. Zarqon's kmail library is great for sending kmails, and I looked at using registry.ash to see if I could use that for parsing incoming mails, but I don't see that it breaks out attachments. Anyone have a code snippet that will parse incoming kmails including attachments? TIA!
 

Bale

Minion
nevermind. wish I could delete this. I missed that you'd already looked at registry.
 

dj_d

Member
Registry.ash is good for parsing strings in the HTML, but not for saying "is there an actual item attached" AFAIK. But thanks for the thought. :)
 

Bale

Minion
I just took a look at the html of a message in my inbox where I am being sent an item and I see no reason that registry.ash won't work as a good base for this problem with a bit of modification. You just need to change the matching expression. Here's a message in my inbox that has a package attached:

<tr><td valign=top><input type=checkbox name="sel91112107"></td><td class=small><b>From</b> <a href="showplayer.php?who=6666666">Name deleted to protect privacy</a> (#7777777) [<a href="sendmessage.php?toid=1826144">reply</a>] [<a href="sendmessage.php?toid=1826144&quoteid=91112107&box=Inbox">quoted</a>]<br><b>Date:</b> Friday, July 31, 2009, 08:46PM</b><!--07/31/09 20:46:46--><br><blockquote>Hey Bale - I meant to sent you this stuffed Hodgman when it dropped, but I was just going through my inventory and noticed I still had it.<br><br>Take care.<center><table><tr><td><img src="http://images.kingdomofloathing.com/itemimages/plainbrown.gif" alt="plain brown wrapper" title="plain brown wrapper" class=hand onClick='descitem(546961999)'></td><td valign=center class=effect>You acquire an item: <b>plain brown wrapper</b></td></tr></table></center></blockquote></td></tr>

Note that it has all the information about an item being sent. I recommend that you send a Mr. A to yourself and see exactly what the html displays so that you can search for that text in a message. Sorry that I didn't have any actual items sent to my inbox, just various packages since I'm often in hardcore.
 
Last edited:

dj_d

Member
The problem is you can't just match text on the page, or it will incorrectly match a message where the body text is <img src="http://images.kingdomofloathing.com/itemimages/plainbrown.gif" alt="plain brown wrapper" title="plain brown wrapper" class=hand onClick='descitem(546961999)'></td><td valign=center class=effect>You acquire an item: <b>plain brown wrapper</b>.
 

bumcheekcity

Active member
a) Nobody's ever going to send that message, so I think you could safely set up the regex :p
b) You can't use HTML in messages. So the < would be <, etc.
 

mredge73

Member
Hey Guys
Is there a way for ash to know the moment you receive a new Kmail?
I want the ability to auto-respond to kmails as they come in without having to parse the kmail page every 1, 5, 10 or so minutes.

Also, I am trying to build a kmail forwarding function and I have the meat and potatoes done but I am having trouble making the forwarded Kmail's readable. Do you guys know any trick on how to format a <blockquote> one kmail, line break, another kmail </blockquote>? HTML <br/> does not work nor does /n for line breaks.
 
Last edited:
Top