holatuwol
Developer
There's two new functions I've added to ASH to help out people who have been attempting to write kmail parsers (these are getting more popular). They'll be available in the next release, which is more or less ready.
int extract_meat( string text )
int [item] extract_items( string text )
The first is self-explanatory. The second takes the text you have provided and parses it for any items that KoLmafia would have found normally. This means you have access to the built-in pluralization handler as well as the ability to NOT have to lookup description IDs or whatever other loops you had to use to access that information.
For example, the following statement will give you all the items that have been sent to you; of course, it doesn't tell you who sent it, but it should give you a basic idea of what's going on, or where you can go from there:
int extract_meat( string text )
int [item] extract_items( string text )
The first is self-explanatory. The second takes the text you have provided and parses it for any items that KoLmafia would have found normally. This means you have access to the built-in pluralization handler as well as the ability to NOT have to lookup description IDs or whatever other loops you had to use to access that information.
For example, the following statement will give you all the items that have been sent to you; of course, it doesn't tell you who sent it, but it should give you a basic idea of what's going on, or where you can go from there:
Code:
string response_text = visit_url( "messages.php?box=Inbox&begin=1" );
int mailed_meat = extract_meat( response_text );
int [item] mailed_items = extract_items( response_text );
foreach received_item in mailed_items
print( received_item + ": " + mailed_items[received_item] + " received in total" );
print( "You gained " + mailed_meat + " meat." );