Beispiel #1
0
    def invite(self, credentials, emails=None, uuids=None):
        """
		Group - Invite users to a group

		You can provide both emails and uuids, or just one. You must provide at least one.

		credentials: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'}
		emails: An array of dictionaries, each representing one email address to invite
			email: The email address of the user being invited.
			name(optional): The name of the user being invited.
			ex: [{'email': '*****@*****.**'}, {'email': '*****@*****.**', 'name': 'user2'}]
		uuids: An array of uuids to invite
			ex: ["user-id-of-existing-user", "user-id-of-another-existing-user"]

		TODO: This function doesn't work. 
		"""
        url = 'https://habitica.com/api/v3/groups/' + self.groupId + '/invite'
        if emails != None and uuids != None:
            payload = {'emails': emails, 'uuids': uuids}
        elif emails != None:
            payload = {'emails': emails}
        elif uuids != None:
            payload = {'uuids': uuids}
        else:
            return (postUrl(url, credentials))
        # print(payload)
        return (postUrl(url, credentials, payload))
Beispiel #2
0
	def disableClasses(self):
		"""
		Disable classes

		"""
		url = "https://habitica.com/api/v3/user/disable-classes"
		return(postUrl(url, self.credentials))
Beispiel #3
0
	def buyArmoire(self, key):
		"""
		Buy an armoire item

		"""
		url = "https://habitica.com/api/v3/user/buy-armoire"
		return(postUrl(url, self.credentials))
Beispiel #4
0
	def releaseMounts(self):
		"""
		Release mounts

		"""
		url = "https://habitica.com/api/v3/user/release-mounts"
		return(postUrl(url, self.credentials))
Beispiel #5
0
	def releasePetsAndMounts(self):
		"""
		Release pets and mounts and grants Triad Bingo

		"""
		url = "https://habitica.com/api/v3/user/release-both"
		return(postUrl(url, self.credentials))
Beispiel #6
0
	def resetUser(self):
		"""
		I really don't know what this one does, and I'm afraid to test it. The docs aren't helpful.

		"""
		url = "https://habitica.com/api/v4/user/reset"
		return(postUrl(url, self.credentials))
Beispiel #7
0
	def revive(self):
		"""
		Revive the user from death

		"""
		url = "https://habitica.com/api/v3/user/revive"
		return(postUrl(url, self.credentials))
Beispiel #8
0
	def orbOfRebirth(self):
		"""
		Use Orb of Rebirth on user

		"""
		url = "https://habitica.com/api/v3/user/rebirth"
		return(postUrl(url, self.credentials))
Beispiel #9
0
def createChallenge(creds,
                    groupId,
                    name,
                    shortName,
                    summary=" ",
                    description=" ",
                    prize=0):
    """
	Creates a challenge. Cannot create associated tasks with this route. See createChallengeTasks.

	Note: I'm not an admin, so I can't support creating official challenges.

	creds: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'}
	groupId: The id of the group to which the challenge belongs. Type: UUID
	name: String containing the full name of the challenge. Type: String
	shortName: A shortened name for the challenge, to be used as a tag. Type: String
	summary (optional): A short summary advertising the main purpose of the challenge; maximum 250 characters; if not supplied, challenge.name will be used
	description (optional): A detailed description of the challenge
	prize (optional): Number of gems offered as a prize to challenge winner. Default value: 0
	official (optional): Whether or not a challenge is an official Habitica challenge (requires admin). Default value: false
	"""
    url = "https://habitica.com/api/v3/challenges"
    payload = {
        'group': groupId,
        'name': name,
        'shortName': shortName,
        'summary': summary,
        'description': description,
        'prize': prize
    }
    return (postUrl(url, creds, payload))
Beispiel #10
0
	def sleep(self):
		"""
		Make the user start / stop sleeping (resting in the Inn)

		"""
		url = "https://habitica.com/api/v3/user/sleep"
		return(postUrl(url, self.credentials))
Beispiel #11
0
	def markPMsRead(self):
		"""
		Marks Private Messages as read

		"""
		url = "https://habitica.com/api/v3/user/mark-pms-read"
		return(postUrl(url, self.credentials))
Beispiel #12
0
	def block(self, uuid):
		"""
		User - Block / unblock a user from sending you a PM

		uuid: The user id of the user to block / unblock
		"""
		url = "https://habitica.com/api/v3/user/block/" + str(uuid)
		return(postUrl(url, self.credentials))
Beispiel #13
0
def clearCompletedTodos(creds):
    """
	Task - Delete user's completed todos

	creds: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'}
	"""
    url = "https://habitica.com/api/v3/tasks/clearCompletedTodos"
    return (postUrl(url, creds))
Beispiel #14
0
def createGroupPlan(credentials):
    """
	Create a Group and then redirect to the correct payment

	credentials: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'}
	"""
    url = 'https://habitica.com/api/v3/groups/create-plan'
    return (postUrl(url, credentials))
Beispiel #15
0
        def selectChallengeWinner(self, winnerId):
            """
			Select winner for a challenge

			winnerId: The _id of the winning user. Type: UUID
			"""
            url = "https://habitica.com/api/v3/challenges/" + self.id + "/selectWinner/" + winnerId
            return (postUrl(url, self.credentials))
Beispiel #16
0
	def readCard(self, cardType):
		"""
		Read a card

		cardType: Type of card to read (e.g. - birthday, greeting, nye, thankyou, valentine)
		"""
		url = "https://habitica.com/api/v3/user/read-card/" + cardType
		return(postUrl(url, self.credentials))
Beispiel #17
0
	def cron(self):
		"""
		Runs cron.

		creds: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'}
		"""
		url = "https://habitica.com/api/v3/cron"
		return(postUrl(url, self.credentials))
Beispiel #18
0
	def buyItem(self, path):
		"""
		Unlock item or set of items by purchase

		path: Full path to unlock. See "content" API call for list of items.
		"""
		url = "https://habitica.com/api/v3/user/unlock?path=" + path
		return(postUrl(url, self.credentials))
Beispiel #19
0
def forceStartQuest(creds, groupId='party'):
    """
	Force a quest to start. Must be a group leader or quest leader.

	creds: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'}
	groupId: The group _id (or 'party'). Type: UUID
	"""
    url = 'https://habitica.com/api/v3/groups/' + groupId + '/quests/force-start'
    return (postUrl(url, creds))
Beispiel #20
0
def leaveChallenge(creds, challengeId):
    """
	Leave a challenge

	creds: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'}
	challengeId: The challenge _id. Type: UUID
	"""
    url = "https://habitica.com/api/v3/challenges/" + challengeId + "/leave"
    return (postUrl(url, creds))
Beispiel #21
0
def addManager(credentials, groupId):
    """
	Add a manager to a group

	credentials: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'}
	groupId: The group _id ('party' for the user party and 'habitrpg' for tavern are accepted)
	"""
    url = 'https://habitica.com/api/v3/groups/' + groupId + '/add-manager'
    return (postUrl(url, credentials))
Beispiel #22
0
def rejectInvite(credentials, groupId):
    """
	Group - Reject a group invitation

	credentials: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'}
	groupId: The group _id ('party' for the user party and 'habitrpg' for tavern are accepted)
	"""
    url = 'https://habitica.com/api/v3/groups/' + groupId + '/reject-invite'
    return (postUrl(url, credentials))
Beispiel #23
0
    def removeManager(self, credentials):
        """
		Group - Remove a manager from a group

		credentials: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'}
		groupId: The group _id ('party' for the user party and 'habitrpg' for tavern are accepted)
		"""
        url = 'https://habitica.com/api/v3/groups/' + self.groupId + '/remove-manager'
        return (postUrl(url, credentials))
Beispiel #24
0
    def cast(self, spellId, targetId='none'):
        """
		Cast a skill (spell) on a target

		spellId: the skill to cast. Takes a string of characters.
		targetId: Query parameter, necessary if the spell is cast on a party member or task.
			Not used if the spell is cast on the user or the user's current party.
			Takes a string containing a UUID.
		spellId to name mapping:
		Mage
			fireball: "Burst of Flames" (target: task ID)
			mpheal: "Ethereal Surge" (target: none)
			earth: "Earthquake" (target: none)
			frost: "Chilling Frost" (target: none)
		Warrior
			smash: "Brutal Smash" (target: taskId)
			defensiveStance: "Defensive Stance" (target: none)
			valorousPresence: "Valorous Presence" (target: none)
			intimidate: "Intimidating Gaze" (target: none)
		Rogue
			pickPocket: "Pickpocket" (target: taskId)
			backStab: "Backstab" (target: taskId)
			toolsOfTrade: "Tools of the Trade" (target: none)
			stealth: "Stealth" (target: none)
		Healer
			heal: "Healing Light" (target: none)
			protectAura: "Protective Aura" (target: none)
			brightness: "Searing Brightness" (target: none)
			healAll: "Blessing" (target: none)
		"""
        if targetId == 'none':
            url = 'https://habitica.com/api/v3/user/class/cast/' + spellId
        else:
            url = 'https://habitica.com/api/v3/user/class/cast/' + spellId + '?targetId=' + targetId

        response = postUrl(url, self.credentials)
        if response['success'] == True:
            costDict = {
                'fireball': 15,
                'mpheal': 30,
                'earth': 35,
                'frost': 40,
                'smash': 10,
                'defensiveStance': 25,
                'valorousPresence': 20,
                'intimidate': 15,
                'pickPocket': 10,
                'backStab': 15,
                'toolsOfTrade': 25,
                'stealth': 45,
                'heal': 15,
                'protectAura': 30,
                'brightness': 15,
                'healAll': 25
            }
            self.mp = self.mp - costDict[spellId]
        return (response)
Beispiel #25
0
	def reroll(self):
		"""
		Reroll a user using the Fortify Potion

		Note: User must either have enough gems or be >= lv 100

		"""
		url = "https://habitica.com/api/v3/user/reroll"
		return(postUrl(url, self.credentials))
Beispiel #26
0
def markMessagesRead(creds, groupId='party'):
    """
	Chat - Mark all messages as read for a group	
  
	creds: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'}
	groupId: The group _id (or 'party'). Type: UUID
	"""
    url = 'https://habitica.com/api/v3/groups/' + groupId + '/chat/seen'
    return (postUrl(url, creds))
Beispiel #27
0
	def allocateAttributePoint(self, stat=None):
		"""
		User - Allocate a single attribute point

		stat: String	Default ='str' Allowed values: "str", "con", "int", "per"
		"""
		url = "https://habitica.com/api/v3/user/allocate"
		payload = {'stat': stat}
		return(postUrl(url, self.credentials, payload))
Beispiel #28
0
def rejectQuest(creds, groupId='party'):
    """
	Reject a quest

	creds: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'}
	groupId: The group _id (or 'party'). Type: UUID
	"""
    url = 'https://habitica.com/api/v3/groups/' + groupId + '/quests/reject'
    return (postUrl(url, creds))
Beispiel #29
0
def selectChallengeWinner(creds, challengeId, winnerId):
    """
	Select winner for a challenge

	creds: a dictionary of user credentials formatted as: {'x-api-user': '******', 'x-api-key': 'your_api_key'}
	challengeId: The challenge _id. Type: UUID
	winnerId: The _id of the winning user. Type: UUID
	"""
    url = "https://habitica.com/api/v3/challenges/" + challengeId + "/selectWinner/" + winnerId
    return (postUrl(url, creds))
Beispiel #30
0
	def setDayStart(self, dayStart = 0):
		"""
		Set preferences.dayStart for user

		dayStart: The hour number 0-23 for day to begin. If body is not included, will default to 0.
			Default value: 0
		"""
		url = "https://habitica.com/api/v3/user/custom-day-start"
		payload = {"dayStart": dayStart}
		return(postUrl(url, self.credentials, payload))