示例#1
0
def passiveHorn(token):
    url = "api/action/passiveturn"
    res = requests.post(host + url, data={"login_token": token})
    if 'error' not in res:
        logger.debug("Camp", "Passive horn initiated")
        return res.json()
    logger.error("Camp", "Passive horn data request failed.")
    return None
示例#2
0
def setTrap(token, ids):
    url = "api/action/arm/" + ','.join(ids)
    res = requests.post(host + url, data={"login_token": token})
    if 'error' not in res:
        logger.debug("Set Trap", "Traps changed")
        return res.json()
    logger.error("Set Trap", "Trap Setting failed.")
    return None
示例#3
0
def purchase(token, item_index, quantity):
    url = f'api/action/purchase/{item_index}/{quantity}'
    res = requests.post(host + url, data={"login_token": token})
    if 'error' not in res:
        logger.debug("Potion", f"Purchased {quantity} {item_index}")
        return res.json()
    logger.error("Potion", "Purchase failed.")
    return None
示例#4
0
def convertPotion(token, uh, product, qn, index):
    url = f'api/action/usepotion/{uh}/{product}/{qn}/{index}'
    res = requests.post(host + url, data={"login_token": token})
    if 'error' not in res:
        logger.debug("Potion", f"Converted {qn} {product}")
        return res.json()
    logger.error("Potion", "Potion conversion failed.")
    return None
示例#5
0
def activeHorn(token):
    url = "api/action/turn/me"
    res = requests.post(host + url, data={"login_token": token})
    if 'error' not in res:
        logger.debug("Camp", "Sounded horn.")
        return res.json()
    logger.error("Camp", "Active horn failed.")
    return None
示例#6
0
def environmentApiCall(environment, token, body={}, post_url=''):
    url = f"api/action/quest/{environment}{post_url}"
    res = requests.post(host + url, data={**body, **{"login_token": token}})

    if 'error' not in res:
        logger.debug(environment, "Action triggered successfully")
        return res.json()
    logger.error(environment, res['error'])
    return None
 def action(self, body):
     if self.environment == None:
         logger.error("Environment",
                      "Environment is missing from api call.")
     return environmentApiCall(self.environment, self.login_token, body)