Regex with custom api json


#1

PhantomBot Version: 2.4.2 (Revision: 5c75a7b2)
Control Panel Version 1.1
Java Version: 1.8.0_65-b17
OS Version: Linux

I am working with the customapi script provided and doing a search for a single variable among the data but would like to lowercase any of the terms being searched since all the data is stored in lowercase that it is searching for. The code I am using:

(customapijson Website.json?q=$1 enemy.(1).Name { HP:} enemy.(1).HP { PP:} enemy.(1).PP { Off:} enemy.(1).Offense { Def:} enemy.(1).Defense { Spd:} enemy.(1).Speed { Fr:} enemy.(1).Fire { Frz:} enemy.(1).Freeze { Fl:} enemy.(1).Flash { Prl:} enemy.(1).Paralysis { Slp/BS:} enemy.(1).Hypnosis/Brainshock { Item:} enemy.(1).Item)

Is there a way to have that variable go through regex? I tried to apply some (probably incorrectly) but ended up with :

[Error ] [customComands.js:667] Failed to get data from API: org.json.JSONException: JSONObject[“regex:\:$21\)”] not found.


#2

based on the code you provided, it sounds like the website sends the data back as json.

You should use customapijson instead. See:

It would help if you posted the response from the website and what you’re trying to pull from the response.


#3

I already am using the customapijson. Sorry I left out the json part in the sentence above.

Currently when a user goes !enemy coilsnake they get the appropriate response. !enemy coilsnakE does not return a match.

I would like it if someone tries to do !enemy CoilSnake (etc different variations) it will still pull the data when it works normally.

Code:
(customapijson http://www.crystalband.com/enemies.json?q=$1 enemy.(1).Name { HP:} enemy.(1).HP { PP:} enemy.(1).PP { Off:} enemy.(1).Offense { Def:} enemy.(1).Defense { Spd:} enemy.(1).Speed { Fr:} enemy.(1).Fire { Frz:} enemy.(1).Freeze { Fl:} enemy.(1).Flash { Prl:} enemy.(1).Paralysis { Slp/BS:} enemy.(1).Hypnosis/Brainshock { Item:} enemy.(1).Item)


#4

You may need to write a custom script to force the input string to lower case or ask the API provider to provide a case insensitive lookup.


#5

Ah ok. I was using functionality that was built into the customapijson script with phantombot and just the json data table which I also built. I was hoping I was going to be able to regex it.

Thanks!