matcher / create_matcher not processing the match on raidlogs.php

dapanda

Member
I am trying to automate my slimetube turns (and soon to be the rest of the dungeon for the final drops) and I am running into an issue with matcher / create_matcher raidlogs.php. I was able to get matcher / create_matcher on the slime tube bucket using this code I borrowed:

Code:
matcher numbucket = create_matcher("There are ([0-9]+) chamoix in the bucket",visit_url("clan_slimetube.php?action=bucket"));
        if (!find(numbucket) || group(numbucket,1).to_int() == (100 * bundles))
        {
            if (retrieve_item(bundles,$item[big bundle of chamoix])){
                use(bundles,$item[big bundle of chamoix]);
            }else{
                print("Need some chamoix up in here! In the bucket, to be precise.","red");
        }   
        } else{
            print(group(numbucket,1).to_int()+" Chamoix up in here! In the bucket, to be precise.","green");
        }

And it works fine, returning the number of Chamoix I have as a numerical value (99 in the bucket).

When I try to use a similar code for determining turns spent in the slime tube:

Code:
//Code to open slimetube and setup bucket for first run
void main() {
    
    matcher slimedefeated = create_matcher("([0-9]+) turns spent in this dungeon:",visit_url("clan_raidlogs.php"));
            print(group(slimedefeated,1).to_int() + " defeated","green");
        
}

I get the following error:

No match attempted or previous match failed (tester2.ash, line 5)
at main (tester2.ash:5)


Using https://regexr.com/ I do see that their is a match for (([0-9]+) turns spent in this dungeon:) is being found as Group 1 for the raid log shows as the numerical value: 244

Code:
Log:
The Slime Tube:
244 turns spent in this dungeon:
Miscellaneous

dapanda (#2456712) defeated a Slime Tube monster x 242 (242 turns)
dapanda (#2456712) was defeated by a Slime Tube monster x 2 (2 turns)
Loot Distribution:

(none yet)

I feel like I am missing something really simple but I can't figure out what it is.
 

heeheehee

Developer
Staff member
You're close, but you need to explicitly invoke find() on your matcher.
Code:
    matcher slimedefeated = create_matcher("([0-9]+) turns spent in this dungeon:",visit_url("clan_raidlogs.php"));
    if (find(slimedefeated)) {
      print(group(slimedefeated,1).to_int() + " defeated","green");
    }

Note that you can also write `slimedefeated.find()`, `slimedefeated..group(1)`.

(This is described more generally in https://wiki.kolmafia.us/index.php/Regular_Expressions#Using_Regexes_in_KoLmafia)
 

dapanda

Member
Thanks! Your part helped and it was because I wasn't taking into account the <b> </b> formatting around the number. Once I updated it to this:

Code:
    matcher slimedefeated = create_matcher("<.+>([0-9]+)<.+> turns spent in this dungeon:",visit_url("clan_raidlogs.php"));
    if (find(slimedefeated)) {
      print(group(slimedefeated,1).to_int() + " defeated","green");
    } else {
      print("Nothing to defeat","green");
    }

It worked great. Thanks for the link and the help.
 
Last edited:
Top