Bot That Parses Messages, etc. (Need Help!)

vampirewolf3

New member
Hey,

I tried to dabble in pykol for this, but I'm even more incompetent than I thought! So I turned to ASH to do this for me, and here I am, just as clueless.

I'm trying to automate Clean Comma Home (#2134115). Visiting the character profile and taking a look in the display case should make it easier to understand what I want.

To clarify, what the bot (should) do is:

1. Look for kmails or trade offers.
2. If there is a new kmail/trade offer, look at the text of the kmail/trade offer.
3. The text should be in the format [number] [item name], [number] [item name], etc. etc.
3a. If not, reject the trade or return the items via kmail.
4. Count the number of items in the kMail/trade offer, and verify that they are Mr. Familiar Equipment. (If there's no Mafia function for this, I wouldn't mind manually updating an array.)
4a. If not, reject the trade or return the items via kmail.
5. Check that they are requesting fewer or equal items than they have sent, and check that they are requesting only Mr. Familiar Equipment.
5a. If not, reject the trade or return the items via kmail.
6. Take the requested items out of the display case, and send them to the player (respond to trade or kMail).
7. Take the received items and put them in the display case.
8. Send a kMail to vAmpiRewolF3 (#433366) and Khurby (#1438106) providing a summary of the transaction.

Sorry if this is a lot of stuff to ask for. Help with any bit would be appreciated!

-vamp

P.S. Rewards may or may not be involved for people who help.
 

Spiny

Member
You might want to take a peek at this thread and examine the script(s) within. That might get you a starting point with which to work from. Mind you, I have never looked at the script myself, but it was brought up again recently as someone else wanted something to respond to trade offers.
 

Grotfang

Developer
My advice would be to first check out DaMaster0's amalgamation of other kmail functions. Also, note it may not work nicely with zlib, so be careful about implementation.

5. Mr. A equipment -- I am not aware of mafia knowing what is Mr. Store equipment and what isn't, so I would recommend building your own array to cover permitted items. That would also give you the benefit of including other items you deem acceptable. You could use equipment.txt and only include power 100 equipment with no equip requirement, but that seems too prone to error.

6 + 8. For kmailing folks, consider adapting the kmail functions in zlib (or in DaMaster0's script) so as not to avoid clashes. They are very useful functions and will save a fair amount of work.

7. DC handing is simple. Check out the wiki's item management page for more ideas.
 

zarqon

Well-known member
Spiny and Grotfang's tips are right on -- kmails and trade offers must be parsed separately since they are on different pages, and they've pointed you in both of the right directions. :)

I'm pretty sure something like

PHP:
if (item_type(it) == "familiar equipment" && mall_price(it) > 4000000)

would keep you from needing an array. But, a predifined map is cleaner (there aren't a lot of Mr. Familiar Equipments) and wouldn't have any edge cases (expensive but non-Mr. Store items).

Parsing your kmail inbox can be done by looking at a) DaMaster's compilation, or 2) my Registry script (where DaMaster got the functions). I use a variant of that same framework in my StashBot script (a craftbot / treasurer / trader bot that replaces the clan stash with superior functionality -- my best script). I believe MrEdge also posted something somewhere that takes the Registry framework and adds items/meat from the kmail message to the returned record type, which is not part of either of the examples mentioned -- but it's easy enough using extract_meat() and extract_items(), so long as the proper precautions are taken. It's probably in one of his function libraries, but I'm not sure which one.

Hope this helps!
 
Top