Пример #1
0
def targetId():
    r = requests.get(
        "https://habitica.com/api/v3/tasks/user?type=dailys", headers=auth_headers)
    rateLimit(r)

    tasks = {}
    for task in r.json()["data"]:
        tasks["{_id}".format(**task)] = float("{value}".format(**task))

    return max(tasks, key=tasks.get)
Пример #2
0
# API details: https://habitica.com/#/options/settings/api
# API docs: https://habitica.com/apidoc/

import requests
import configparser
from utils import rateLimit

config = configparser.RawConfigParser()
config.read("config.ini")

HABITICA_USER = config.get("AUTH", "HABITICA_USER")
HABITICA_TOKEN = config.get("AUTH", "HABITICA_TOKEN")
auth_headers = {"x-api-user": HABITICA_USER, "x-api-key": HABITICA_TOKEN}

returnMessage = "+1 Gem"

while returnMessage == "+1 Gem":
    r = requests.post("https://habitica.com/api/v3/user/purchase/gems/gem", headers=auth_headers)
    returnMessage = r.json()['message']
    print(returnMessage)
    rateLimit(r)
Пример #3
0
                r = requests.post("https://habitica.com/api/v3/user/hatch/" +
                                  egg + "/" + hatchingPotion,
                                  headers=auth_headers)
                if r.status_code == 200:
                    print(hatchingPotion + " " + egg + " hatched!")
                    eggsInventory[egg] -= 1
                    hatchingPotionsInventory[hatchingPotion] -= 1
                    petsInventory[pet] = "5"
                    if egg in petTypeList:
                        petTypeList[egg] += 1
                    else:
                        petTypeList[egg] = 1
                if r.status_code >= 400:
                    print("Failed to hatch " + hatchingPotion + " " + egg +
                          ": " + r.json()["message"])
                rateLimit(r.headers)

            # FEED PETS
            if petTypeList[egg] >= 10:
                for food in foodInventory:
                    if pet not in mountsInventory and foodInventory.get(
                            food) > 0 and 0 < petsInventory.get(pet) < 50:
                        if hatchingPotion in foodPreferenceList:
                            feed = foodPreferenceList.get(hatchingPotion)
                            foodList = food.split("_")
                            if len(foodList
                                   ) > 1 and foodList[1] == hatchingPotion:
                                feed = food
                        else:
                            feed = max(foodInventory, key=foodInventory.get)
                        r = requests.post(
Пример #4
0
def getParty():
    r = requests.get(
        "https://habitica.com/api/v3/groups/party", headers=auth_headers)
    rateLimit(r)
    return r
Пример #5
0
def getUP():
    r = requests.get(
        "https://habitica.com/api/v3/user", headers=auth_headers)
    rateLimit(r)
    return r
Пример #6
0
def emptyArmoire():
    r = requests.get("https://habitica.com/api/v3/user", headers=auth_headers)
    return r.json()["data"]["flags"]["armoireEmpty"]
    rateLimit(r)