Habiticalib 0.4.0rc0__py3-none-any.whl → 0.4.0rc2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- habiticalib/__init__.py +6 -0
- habiticalib/const.py +1 -1
- habiticalib/lib.py +89 -32
- habiticalib/typedefs.py +146 -3
- {habiticalib-0.4.0rc0.dist-info → habiticalib-0.4.0rc2.dist-info}/METADATA +1 -2
- habiticalib-0.4.0rc2.dist-info/RECORD +12 -0
- habiticalib-0.4.0rc0.dist-info/RECORD +0 -12
- {habiticalib-0.4.0rc0.dist-info → habiticalib-0.4.0rc2.dist-info}/WHEEL +0 -0
- {habiticalib-0.4.0rc0.dist-info → habiticalib-0.4.0rc2.dist-info}/licenses/LICENSE +0 -0
habiticalib/__init__.py
CHANGED
@@ -51,6 +51,7 @@ from .typedefs import (
|
|
51
51
|
GroupChatReceived,
|
52
52
|
GroupChatReceivedOptions,
|
53
53
|
GroupChatReceivedWebhook,
|
54
|
+
GroupData,
|
54
55
|
GroupTask,
|
55
56
|
HabiticaCastSkillResponse,
|
56
57
|
HabiticaClass,
|
@@ -59,7 +60,9 @@ from .typedefs import (
|
|
59
60
|
HabiticaDeleteWebhookResponse,
|
60
61
|
HabiticaErrorResponse,
|
61
62
|
HabiticaGroupMembersResponse,
|
63
|
+
HabiticaGroupsResponse,
|
62
64
|
HabiticaLoginResponse,
|
65
|
+
HabiticaMessageResponse,
|
63
66
|
HabiticaQuestResponse,
|
64
67
|
HabiticaResponse,
|
65
68
|
HabiticaScoreResponse,
|
@@ -204,6 +207,7 @@ __all__ = [
|
|
204
207
|
"GroupChatReceived",
|
205
208
|
"GroupChatReceivedOptions",
|
206
209
|
"GroupChatReceivedWebhook",
|
210
|
+
"GroupData",
|
207
211
|
"GroupTask",
|
208
212
|
"Habitica",
|
209
213
|
"HabiticaCastSkillResponse",
|
@@ -219,8 +223,10 @@ __all__ = [
|
|
219
223
|
"HabiticaException",
|
220
224
|
"HabiticaGroupMembersResponse",
|
221
225
|
"HabiticaGroupMembersResponse",
|
226
|
+
"HabiticaGroupsResponse",
|
222
227
|
"HabiticaLoginResponse",
|
223
228
|
"HabiticaLoginResponse",
|
229
|
+
"HabiticaMessageResponse",
|
224
230
|
"HabiticaQuestResponse",
|
225
231
|
"HabiticaQuestResponse",
|
226
232
|
"HabiticaResponse",
|
habiticalib/const.py
CHANGED
habiticalib/lib.py
CHANGED
@@ -7,10 +7,9 @@ from http import HTTPStatus
|
|
7
7
|
from io import BytesIO
|
8
8
|
import logging
|
9
9
|
from operator import add
|
10
|
-
from typing import IO, TYPE_CHECKING,
|
10
|
+
from typing import IO, TYPE_CHECKING, Self
|
11
11
|
|
12
12
|
from aiohttp import ClientError, ClientResponseError, ClientSession
|
13
|
-
from habitipy.aio import HabitipyAsync # type: ignore[import-untyped]
|
14
13
|
from PIL import Image
|
15
14
|
from yarl import URL
|
16
15
|
|
@@ -47,7 +46,9 @@ from .typedefs import (
|
|
47
46
|
HabiticaDeleteWebhookResponse,
|
48
47
|
HabiticaErrorResponse,
|
49
48
|
HabiticaGroupMembersResponse,
|
49
|
+
HabiticaGroupsResponse,
|
50
50
|
HabiticaLoginResponse,
|
51
|
+
HabiticaMessageResponse,
|
51
52
|
HabiticaQuestResponse,
|
52
53
|
HabiticaResponse,
|
53
54
|
HabiticaScoreResponse,
|
@@ -2051,36 +2052,6 @@ class Habitica:
|
|
2051
2052
|
|
2052
2053
|
return avatar
|
2053
2054
|
|
2054
|
-
async def habitipy(self) -> HabitipyAsync:
|
2055
|
-
"""Create a Habitipy instance."""
|
2056
|
-
|
2057
|
-
_session = self._session
|
2058
|
-
_headers = self._headers
|
2059
|
-
loop = asyncio.get_running_loop()
|
2060
|
-
|
2061
|
-
class HAHabitipyAsync(HabitipyAsync):
|
2062
|
-
"""Closure API class to hold session."""
|
2063
|
-
|
2064
|
-
def __call__(self, **kwargs) -> Any:
|
2065
|
-
"""Pass session to habitipy."""
|
2066
|
-
return super().__call__(_session, **kwargs)
|
2067
|
-
|
2068
|
-
def _make_headers(self) -> dict[str, str]:
|
2069
|
-
"""Inject headers."""
|
2070
|
-
headers = super()._make_headers()
|
2071
|
-
headers.update(_headers)
|
2072
|
-
return headers
|
2073
|
-
|
2074
|
-
return await loop.run_in_executor(
|
2075
|
-
None,
|
2076
|
-
HAHabitipyAsync,
|
2077
|
-
{
|
2078
|
-
"url": str(self.url),
|
2079
|
-
"login": self._headers.get("X-API-USER"),
|
2080
|
-
"password": self._headers.get("X-API-KEY"),
|
2081
|
-
}, # type: ignore[var-annotated]
|
2082
|
-
)
|
2083
|
-
|
2084
2055
|
async def create_webhook(
|
2085
2056
|
self,
|
2086
2057
|
webhook: TaskActivity
|
@@ -2183,3 +2154,89 @@ class Habitica:
|
|
2183
2154
|
return HabiticaWebhookResponse.from_json(
|
2184
2155
|
await self._request("put", url, json=webhook.to_dict(omit_none=True))
|
2185
2156
|
)
|
2157
|
+
|
2158
|
+
async def get_group(self, group_id: UUID | None = None) -> HabiticaGroupsResponse:
|
2159
|
+
"""
|
2160
|
+
Retrieve a user's group or party information.
|
2161
|
+
|
2162
|
+
Parameters
|
2163
|
+
----------
|
2164
|
+
group_id : UUID or None, optional
|
2165
|
+
The unique identifier of the group to retrieve. If not provided,
|
2166
|
+
the user's party information will be retrieved instead.
|
2167
|
+
|
2168
|
+
Returns
|
2169
|
+
-------
|
2170
|
+
HabiticaGroupsResponse
|
2171
|
+
An object representing the response containing the group or party details.
|
2172
|
+
"""
|
2173
|
+
|
2174
|
+
url = self.url / "api/v3/groups" / (str(group_id) if group_id else "party")
|
2175
|
+
|
2176
|
+
return HabiticaGroupsResponse.from_json(await self._request("get", url))
|
2177
|
+
|
2178
|
+
async def send_group_message(
|
2179
|
+
self, message: str, group_id: UUID | None = None
|
2180
|
+
) -> HabiticaMessageResponse:
|
2181
|
+
"""Send a message to a specific group.
|
2182
|
+
|
2183
|
+
Parameters
|
2184
|
+
----------
|
2185
|
+
message : str
|
2186
|
+
The content of the message to be sent.
|
2187
|
+
group_id : UUID
|
2188
|
+
The unique identifier of the group to send the message to.
|
2189
|
+
If not provided, the user's party will be used.
|
2190
|
+
|
2191
|
+
Returns
|
2192
|
+
-------
|
2193
|
+
HabiticaMessageResponse
|
2194
|
+
An object representing the response containing the sent message details.
|
2195
|
+
|
2196
|
+
Raises
|
2197
|
+
------
|
2198
|
+
NotAuthorizedError
|
2199
|
+
If the user is not authorized to send messages to the specified group
|
2200
|
+
because the chat privileges have been revoked.
|
2201
|
+
NotFoundError
|
2202
|
+
If the specified group could not be found.
|
2203
|
+
"""
|
2204
|
+
url = (
|
2205
|
+
self.url
|
2206
|
+
/ "api/v3/groups"
|
2207
|
+
/ (str(group_id) if group_id else "party")
|
2208
|
+
/ "chat"
|
2209
|
+
)
|
2210
|
+
return HabiticaMessageResponse.from_json(
|
2211
|
+
await self._request("post", url, json={"message": message})
|
2212
|
+
)
|
2213
|
+
|
2214
|
+
async def send_private_message(
|
2215
|
+
self, message: str, to_user_id: UUID
|
2216
|
+
) -> HabiticaMessageResponse:
|
2217
|
+
"""Send a private message to a specific user.
|
2218
|
+
|
2219
|
+
Parameters
|
2220
|
+
----------
|
2221
|
+
message : str
|
2222
|
+
The content of the private message to be sent.
|
2223
|
+
to_user_id : UUID
|
2224
|
+
The unique identifier of the user to send the message to.
|
2225
|
+
|
2226
|
+
Returns
|
2227
|
+
-------
|
2228
|
+
HabiticaMessageResponse
|
2229
|
+
An object representing the response containing the sent message details.
|
2230
|
+
|
2231
|
+
Raises
|
2232
|
+
------
|
2233
|
+
NotFoundError
|
2234
|
+
If the specified user could not be found.
|
2235
|
+
"""
|
2236
|
+
url = self.url / "api/v3/members/send-private-message"
|
2237
|
+
|
2238
|
+
return HabiticaMessageResponse.from_json(
|
2239
|
+
await self._request(
|
2240
|
+
"post", url, json={"message": message, "toUserId": str(to_user_id)}
|
2241
|
+
)
|
2242
|
+
)
|
habiticalib/typedefs.py
CHANGED
@@ -559,6 +559,9 @@ class QuestParty(BaseModel):
|
|
559
559
|
RSVPNeeded: bool | None = None
|
560
560
|
key: str | None = None
|
561
561
|
completed: str | None = None
|
562
|
+
active: bool | None = None
|
563
|
+
leader: UUID | None = None
|
564
|
+
members: dict[UUID, bool] = field(default_factory=dict)
|
562
565
|
|
563
566
|
|
564
567
|
@dataclass(kw_only=True)
|
@@ -1621,7 +1624,7 @@ class ItemListContent(BaseModel):
|
|
1621
1624
|
bundles: ItemListEntry
|
1622
1625
|
|
1623
1626
|
|
1624
|
-
@dataclass
|
1627
|
+
@dataclass(kw_only=True)
|
1625
1628
|
class GearEntry(BaseModel):
|
1626
1629
|
"""GearEntry content data."""
|
1627
1630
|
|
@@ -1767,7 +1770,7 @@ class PetEntry(BaseModel):
|
|
1767
1770
|
text: str | None = None
|
1768
1771
|
|
1769
1772
|
|
1770
|
-
@dataclass
|
1773
|
+
@dataclass(kw_only=True)
|
1771
1774
|
class InventoryItemEntry(BaseModel):
|
1772
1775
|
"""Inventory item content data."""
|
1773
1776
|
|
@@ -1779,6 +1782,36 @@ class InventoryItemEntry(BaseModel):
|
|
1779
1782
|
key: str | None = None
|
1780
1783
|
notes: str | None = None
|
1781
1784
|
canDrop: bool | None = None
|
1785
|
+
sellWarningNote: str | None = None
|
1786
|
+
|
1787
|
+
|
1788
|
+
@dataclass(kw_only=True)
|
1789
|
+
class Achievment(BaseModel):
|
1790
|
+
"""An achievment."""
|
1791
|
+
|
1792
|
+
icon: str
|
1793
|
+
titleKey: str
|
1794
|
+
textKey: str
|
1795
|
+
key: str
|
1796
|
+
text2Key: str | None = None
|
1797
|
+
notificationText: str | None = None
|
1798
|
+
singularTitleKey: str | None = None
|
1799
|
+
singularTextKey: str | None = None
|
1800
|
+
pluralTitleKey: str | None = None
|
1801
|
+
pluralTextKey: str | None = None
|
1802
|
+
modalTextKey: str | None = None
|
1803
|
+
|
1804
|
+
|
1805
|
+
@dataclass(kw_only=True)
|
1806
|
+
class Incentive(BaseModel):
|
1807
|
+
"""A login incentive."""
|
1808
|
+
|
1809
|
+
rewardKey: list[str] = field(default_factory=list)
|
1810
|
+
nextRewardAt: int = 500
|
1811
|
+
prevRewardKey: int = 0
|
1812
|
+
reward: list[QuestsContent | GearEntry | InventoryItemEntry | Achievment] = field(
|
1813
|
+
default_factory=list
|
1814
|
+
)
|
1782
1815
|
|
1783
1816
|
|
1784
1817
|
@dataclass
|
@@ -1836,7 +1869,7 @@ class ContentData(BaseModel):
|
|
1836
1869
|
# tasksByCategory
|
1837
1870
|
# userDefaultsMobile
|
1838
1871
|
# faq
|
1839
|
-
|
1872
|
+
loginIncentives: dict[str, Incentive]
|
1840
1873
|
|
1841
1874
|
|
1842
1875
|
@dataclass
|
@@ -1870,3 +1903,113 @@ class HabiticaCastSkillResponse(HabiticaResponse):
|
|
1870
1903
|
"""Representation of a cast skill response."""
|
1871
1904
|
|
1872
1905
|
data: UserTasks
|
1906
|
+
|
1907
|
+
|
1908
|
+
class GroupPrivacy(StrEnum):
|
1909
|
+
"""Group privacy."""
|
1910
|
+
|
1911
|
+
PRIVATE = "private"
|
1912
|
+
PUBLIC = "public"
|
1913
|
+
|
1914
|
+
|
1915
|
+
class GroupType(StrEnum):
|
1916
|
+
"""Group type."""
|
1917
|
+
|
1918
|
+
GUILD = "guild"
|
1919
|
+
PARTY = "party"
|
1920
|
+
|
1921
|
+
|
1922
|
+
@dataclass(kw_only=True)
|
1923
|
+
class LeaderOnly(BaseModel):
|
1924
|
+
"""Group leaderOnly data."""
|
1925
|
+
|
1926
|
+
challenges: bool
|
1927
|
+
getGems: bool
|
1928
|
+
|
1929
|
+
|
1930
|
+
@dataclass(kw_only=True)
|
1931
|
+
class GroupLeader(BaseModel):
|
1932
|
+
"""Group leader data."""
|
1933
|
+
|
1934
|
+
id: UUID
|
1935
|
+
auth: AuthUser
|
1936
|
+
profile: ProfileUser
|
1937
|
+
|
1938
|
+
|
1939
|
+
@dataclass(kw_only=True)
|
1940
|
+
class ChatMsgInfo(BaseModel):
|
1941
|
+
"""Chat message info."""
|
1942
|
+
|
1943
|
+
type: str | None = None
|
1944
|
+
user: str | None = None
|
1945
|
+
quest: str | None = None
|
1946
|
+
items: dict[str, int] | None = None
|
1947
|
+
|
1948
|
+
|
1949
|
+
@dataclass(kw_only=True)
|
1950
|
+
class ChatMsg(BaseModel):
|
1951
|
+
"""Chat message."""
|
1952
|
+
|
1953
|
+
id: UUID
|
1954
|
+
flagCount: int
|
1955
|
+
text: str
|
1956
|
+
unformattedText: str
|
1957
|
+
info: ChatMsgInfo
|
1958
|
+
timestamp: datetime = field(
|
1959
|
+
metadata=field_options(
|
1960
|
+
deserialize=serialize_datetime,
|
1961
|
+
)
|
1962
|
+
)
|
1963
|
+
likes: dict[UUID, bool]
|
1964
|
+
client: str | None = None
|
1965
|
+
uuid: UUID | str
|
1966
|
+
groupId: UUID | None = None
|
1967
|
+
user: str | None = None
|
1968
|
+
username: str | None = None
|
1969
|
+
userStyles: Avatar | None = None
|
1970
|
+
sent: bool | None = None
|
1971
|
+
ownerId: UUID | None = None
|
1972
|
+
uniqueMessageId: UUID | None = None
|
1973
|
+
|
1974
|
+
|
1975
|
+
@dataclass(kw_only=True)
|
1976
|
+
class GroupData(BaseModel):
|
1977
|
+
"""Groups data."""
|
1978
|
+
|
1979
|
+
id: UUID
|
1980
|
+
name: str
|
1981
|
+
summary: str = ""
|
1982
|
+
description: str = ""
|
1983
|
+
leader: GroupLeader
|
1984
|
+
type: GroupType
|
1985
|
+
privacy: GroupPrivacy
|
1986
|
+
chat: list[ChatMsg]
|
1987
|
+
leaderOnly: LeaderOnly
|
1988
|
+
memberCount: int = 1
|
1989
|
+
ChallengeCount: int = 0
|
1990
|
+
chatLimitCount: int | None = None
|
1991
|
+
balance: float
|
1992
|
+
logo: str | None = None
|
1993
|
+
leaderMessage: str | None = None
|
1994
|
+
quest: QuestParty
|
1995
|
+
|
1996
|
+
|
1997
|
+
@dataclass
|
1998
|
+
class HabiticaGroupsResponse(HabiticaResponse):
|
1999
|
+
"""Representation of a groups response."""
|
2000
|
+
|
2001
|
+
data: GroupData
|
2002
|
+
|
2003
|
+
|
2004
|
+
@dataclass(kw_only=True)
|
2005
|
+
class MessageData(BaseModel):
|
2006
|
+
"""Message data."""
|
2007
|
+
|
2008
|
+
message: ChatMsg
|
2009
|
+
|
2010
|
+
|
2011
|
+
@dataclass(kw_only=True)
|
2012
|
+
class HabiticaMessageResponse(HabiticaResponse):
|
2013
|
+
"""Representation of a group response."""
|
2014
|
+
|
2015
|
+
data: MessageData
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: Habiticalib
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.0rc2
|
4
4
|
Summary: Asynchronous Python client library for the Habitica API
|
5
5
|
Project-URL: Documentation, https://tr4nt0r.github.io/habiticalib/
|
6
6
|
Project-URL: Source, https://github.com/tr4nt0r/habiticalib
|
@@ -12,7 +12,6 @@ Classifier: Operating System :: OS Independent
|
|
12
12
|
Classifier: Programming Language :: Python :: 3 :: Only
|
13
13
|
Requires-Python: >=3.12
|
14
14
|
Requires-Dist: aiohttp~=3.9
|
15
|
-
Requires-Dist: habitipy~=0.3.3
|
16
15
|
Requires-Dist: mashumaro~=3.13
|
17
16
|
Requires-Dist: orjson~=3.10
|
18
17
|
Requires-Dist: pillow~=11.0
|
@@ -0,0 +1,12 @@
|
|
1
|
+
habiticalib/__init__.py,sha256=UxNKxNhjIi3v95VE3h-JWgitriNZytrGeX0GvKdevwU,7840
|
2
|
+
habiticalib/const.py,sha256=-u5ybeRWgP6hzR18_JNU-oxFY1Bkdg4baOupXKXlr0Q,2311
|
3
|
+
habiticalib/exceptions.py,sha256=i9hnCaMT5RbnTioFhwRYJkcC_bG9lMeUd2jJsWFVnVg,1342
|
4
|
+
habiticalib/ha.py,sha256=rSzrs7ixLJH3ZtOFlcuKV2t1ZndT0VpuPhDsGqorkOs,20757
|
5
|
+
habiticalib/helpers.py,sha256=lq2HBvqLsFo5_zckMnc7hzDsHLfyrcStpFUpet3ZuZY,4500
|
6
|
+
habiticalib/lib.py,sha256=DUMdqia-w4AAPdf8bAX2g9PXq0HgPocYy-E1-cFXV7g,78503
|
7
|
+
habiticalib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
+
habiticalib/typedefs.py,sha256=726lwaH_Zpk6YMVlFmlLsV0aicn-jrfQ7ESXHFeK5Nw,50900
|
9
|
+
habiticalib-0.4.0rc2.dist-info/METADATA,sha256=vY9qMfEXj8y5BWzTSVQmzZSMVvqDMQgCDVHO0hVpS58,4179
|
10
|
+
habiticalib-0.4.0rc2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
11
|
+
habiticalib-0.4.0rc2.dist-info/licenses/LICENSE,sha256=oIinIOSJ49l1iVIRI3XGXFWt6SF7a83kEFBAY8ORwNI,1084
|
12
|
+
habiticalib-0.4.0rc2.dist-info/RECORD,,
|
@@ -1,12 +0,0 @@
|
|
1
|
-
habiticalib/__init__.py,sha256=2IM9mDegpFIANIdatGTePbT4r1cilUtwNYs4Bups7So,7690
|
2
|
-
habiticalib/const.py,sha256=Yh3d46unPdB1n6EMENXrpV_komBj3b1eDWwc9pdEaws,2311
|
3
|
-
habiticalib/exceptions.py,sha256=i9hnCaMT5RbnTioFhwRYJkcC_bG9lMeUd2jJsWFVnVg,1342
|
4
|
-
habiticalib/ha.py,sha256=rSzrs7ixLJH3ZtOFlcuKV2t1ZndT0VpuPhDsGqorkOs,20757
|
5
|
-
habiticalib/helpers.py,sha256=lq2HBvqLsFo5_zckMnc7hzDsHLfyrcStpFUpet3ZuZY,4500
|
6
|
-
habiticalib/lib.py,sha256=9CqfAIGBx-MJB08UAB81kczB2kD1W1aPYHjDfAvBmFY,76729
|
7
|
-
habiticalib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
-
habiticalib/typedefs.py,sha256=pU7jfWAKMSvJO8QjTEgm_B0c6GONy1SZH2lTMUPPhrE,47834
|
9
|
-
habiticalib-0.4.0rc0.dist-info/METADATA,sha256=w920G81BFg4JxgAuIwi93JIC-jXZ3zhuwBNOwtu3GWg,4210
|
10
|
-
habiticalib-0.4.0rc0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
11
|
-
habiticalib-0.4.0rc0.dist-info/licenses/LICENSE,sha256=oIinIOSJ49l1iVIRI3XGXFWt6SF7a83kEFBAY8ORwNI,1084
|
12
|
-
habiticalib-0.4.0rc0.dist-info/RECORD,,
|
File without changes
|
File without changes
|