How can I grab my mall sales activity in a script?

visit_url( "any url at backoffice.php" ) returns nothing. Googling leads me to believe that this is intended. (To hamper mallbots?)

Is there some scriptwise way that I can interact with this data? My goal for today was "sum up how many of Item X I've sold in the last two weeks," but I can imagine all sorts of similar applications.
 
Last edited:

ereinion

Member
I'd also be very interested in this, mostly because it is a pain finding out what big sales have happened inbetween all the 100-1000000 meat sales with the current layout. Just an option to sort the store log in the mall manager by the size of the purchases would be much appreciated, really.
 

Malurth

Member
Yeah, also interested in this. I would like a log of my mall sales/purchases to be automatically generated, but afaik KoLMafia doesn't do this and I can't do it through scripting due to this limitation.
 

fronobulax

Developer
Staff member
Back when hola was active, I asked that the Store Manager open up and display the log immediately. The answer was no, because it was a server hit that could be deferred until the player actually wanted the data.

Off the top of my head, I am not really interested in re-implementing Excel (or the spreadsheet of your choice) in Java to sort and filter the log. But if that is easier than I think it is because of libraries we already have I might do it.

I can see some benefit from a get_sales_log command, assuming no one smarter than me can figure out how to use it for a mall bot. It would dump a text file in the data directory and the user would have to use ash or something else to process it. I'll investigate.
 

lostcalpolydude

Developer
Staff member
If get_sales_log() is being added, it could just return the page HTML. Or it could return a string[], split up the same way the Store Manager does (so a lot of the parsing code should already exist).

I see nothing wrong with that existing.
 

fronobulax

Developer
Staff member
Having looked at the code there is both a "log list" and a "sold list". I'm not sure yet how they differ or if one is derived from the other. I'm inclined to look at the log list first. I note there is a lot of parsing going on already and it actually might be easier for the command to return an array rather than write a file. I'm also rethinking the name. Most of the ash commands relating to "my mall store" seem to use "shop".
 

fronobulax

Developer
Staff member
Try r13382

Code:
string[int] shopLog;
shopLog = get_shop_log();
foreach x in shopLog {
	print(shopLog[x]);
}

> call scripts\ShopLogTest.ash

Examining store logs...
Store purchase logs retrieved.
14: 12/21/17 13:53:12 TDay93 bought 1 (Trivial Avocations Card: Who?) for 100 Meat.
13: 12/20/17 09:40:31 George P Burdell bought 1 (filthy knitted dread sack) for 160 Meat.
12: 12/19/17 23:07:43 KimorKnossos bought 1 (hand grenegg) for 208 Meat.
11: 12/19/17 20:59:54 Ereinion bought 1 (Trivial Avocations Card: Who?) for 100 Meat.
10: 12/19/17 13:16:18 disfunctionalmember4 bought 1 (Taco Dan's Taco Stand Taco) for 101 Meat.
9: 12/18/17 02:06:40 Pastahead bought 1 (giant giant moth dust) for 100 Meat.
8: 12/18/17 02:06:35 Pastahead bought 1 (giant giant moth dust) for 100 Meat.
7: 12/12/17 13:49:28 Doctor Adventure bought 1 (magical ice cubes) for 100 Meat.
6: 12/12/17 13:49:21 Doctor Adventure bought 1 (magical ice cubes) for 100 Meat.
5: 12/12/17 12:48:15 Deaidth bought 5 (magical ice cubes) for 500 Meat.
4: 12/11/17 18:40:49 Nanimonai3 bought 14 (coconut shell) for 1400 Meat.
3: 12/11/17 17:13:38 Nanimonai3 bought 30 (pink pony) for 6900 Meat.
2: 12/09/17 22:15:57 Loafing Doom Knight bought 1 (magical ice cubes) for 100 Meat.
1: 12/09/17 03:38:13 Buhuguyga bought 2 (hot coal) for 352 Meat.

Only lightly tested.

It turns out KoLmafia doesn't really have good hooks to retrieve the parsed data, so the string returned needs to be parsed by the user. That said, it should not be too difficult to parse in ash.

If anyone feels like adding this to the wiki, that would help me.
 

ereinion

Member
Thanks a ton for implementing this :)

I wrote this for some simple parsing of my store-log, feel free to use it if you want to:
Code:
void write_big_sales(int limit) {
    string[int] shopLog = get_shop_log();
    matcher meat_gain;
    string pattern = "for (\\d+) Meat";
    int meat;
    
    foreach i in shopLog {
        meat_gain = create_matcher(pattern, shopLog[i]);
        if (find(meat_gain)) {
            meat = to_int(group(meat_gain, 1));
            if (meat >= limit) {
                print_html("<font color=0000FF>" + shopLog[i] + "</font>");
            }
        }
    }
}

void main() {
    write_big_sales(500000);
}

I suppose I could also try to add some info about this to the wiki, but if I do, what is it that should be added there?
 

fronobulax

Developer
Staff member
Thanks a ton for implementing this :)

I wrote this for some simple parsing of my store-log, feel free to use it if you want to:
Code:
void write_big_sales(int limit) {
    string[int] shopLog = get_shop_log();
    matcher meat_gain;
    string pattern = "for (\\d+) Meat";
    int meat;
    
    foreach i in shopLog {
        meat_gain = create_matcher(pattern, shopLog[i]);
        if (find(meat_gain)) {
            meat = to_int(group(meat_gain, 1));
            if (meat >= limit) {
                print_html("<font color=0000FF>" + shopLog[i] + "</font>");
            }
        }
    }
}

void main() {
    write_big_sales(500000);
}

I suppose I could also try to add some info about this to the wiki, but if I do, what is it that should be added there?

Thanks. Wiki has lists of functions - parameters, description, etc. When the next person asks for this and you tell them to check the wiki, what do they need to find there so "check the wiki" is helpful, not snarky.
 
Top