maxapi-python 2.1.1__py3-none-any.whl → 2.1.2__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.
- {maxapi_python-2.1.1.dist-info → maxapi_python-2.1.2.dist-info}/METADATA +1 -1
- {maxapi_python-2.1.1.dist-info → maxapi_python-2.1.2.dist-info}/RECORD +10 -10
- {maxapi_python-2.1.1.dist-info → maxapi_python-2.1.2.dist-info}/WHEEL +1 -1
- pymax/__init__.py +1 -1
- pymax/api/bots/payloads.py +1 -1
- pymax/api/bots/service.py +3 -7
- pymax/app.py +10 -17
- pymax/types/domain/folder.py +0 -6
- pymax/types/domain/login.py +7 -19
- {maxapi_python-2.1.1.dist-info → maxapi_python-2.1.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
pymax/__init__.py,sha256=
|
|
2
|
-
pymax/app.py,sha256=
|
|
1
|
+
pymax/__init__.py,sha256=6Fe_FJ1NgKBmqSWmix3_fmVbhFWFiLekXEjyH7rDIds,1255
|
|
2
|
+
pymax/app.py,sha256=QzvHYsSGOu00f6GrN4a_AiLJkuFLb6RN81FRKk9togw,9814
|
|
3
3
|
pymax/base.py,sha256=Q6FR5K1nOaeVnYlzRgqC6_v7AWUiJJCkI4TuzCYbj-U,7255
|
|
4
4
|
pymax/client.py,sha256=KiDEiUL49IGxRtq4-Sr3IABa8Rh1TRPq41Gv5jH2m_Q,4013
|
|
5
5
|
pymax/client_web.py,sha256=iTwlsY75d_wg-vUGObTq7SVinp0L__2r8cvG49BtmUI,3041
|
|
@@ -18,8 +18,8 @@ pymax/api/auth/payloads.py,sha256=XxrVdNcz1uV6hUxDp9Dt_stENECi_eDlxuiqt44DHeo,30
|
|
|
18
18
|
pymax/api/auth/service.py,sha256=sjZcMyP6siH0dR19eYwkhhLU09bVJD4FCNeSra2Rjac,11639
|
|
19
19
|
pymax/api/auth/types.py,sha256=VrYR7rIZOrW45yKnQmC5MSe9kxgXmqPzh9VG_y1tSEs,200
|
|
20
20
|
pymax/api/bots/__init__.py,sha256=4P7rM-XeeDOElEktov1Vbfo8nzjJgmyA4_pQl4WvzRQ,33
|
|
21
|
-
pymax/api/bots/payloads.py,sha256
|
|
22
|
-
pymax/api/bots/service.py,sha256=
|
|
21
|
+
pymax/api/bots/payloads.py,sha256=aXriolCN_YvBvDZO_MPmD-fkrIVJIpVDXkOkOZVes_c,166
|
|
22
|
+
pymax/api/bots/service.py,sha256=ziqVlQUMFHjQydMDFyWcQMIATboQTvIdGtJhf-AK9tA,847
|
|
23
23
|
pymax/api/chats/__init__.py,sha256=UMp3uKdB3tZlnWckndgF3jaU-3-49OJE18z2d0OlmIU,155
|
|
24
24
|
pymax/api/chats/enums.py,sha256=FdByRiHYX9Xs7RyNabKqxGugNs9tJ3VBXwTb_43XGC8,627
|
|
25
25
|
pymax/api/chats/payloads.py,sha256=Y4S2x60i3txeA75GV_pGJ3ov7pLMp4GjGuhoqlRI2ow,2824
|
|
@@ -114,8 +114,8 @@ pymax/types/domain/chat.py,sha256=xpLutj9uCIQupAO1zu2eXzEEXL8DcQ4N6tkZQeQUsCM,18
|
|
|
114
114
|
pymax/types/domain/element.py,sha256=slMVlp5Fn1H1hFUinruuP7s2wawkSrS5c1eCeY31p-g,620
|
|
115
115
|
pymax/types/domain/enums.py,sha256=eGMWnlv0mYJ8K-0FsC_wp4Co2M6YWyKI1Lx90MJ6s4g,412
|
|
116
116
|
pymax/types/domain/error.py,sha256=WZoDAXf5vt8O4VYy7iEHLGBfH6hZQZ1fVkTz9rVCTN0,584
|
|
117
|
-
pymax/types/domain/folder.py,sha256=
|
|
118
|
-
pymax/types/domain/login.py,sha256=
|
|
117
|
+
pymax/types/domain/folder.py,sha256=Z9pXMzOTfxuhUfrJpLjl5LPnVXqqFsBVfKBQm4IbGWM,2225
|
|
118
|
+
pymax/types/domain/login.py,sha256=FBKpRhNPv6Zdjo6Wfl-lK8JpzpMx7zh84f1qrq6Z0og,1301
|
|
119
119
|
pymax/types/domain/member.py,sha256=8gUNn4fBS_S2ap45A40lRlrDXYFMoq0Kx-dh57hMWQc,490
|
|
120
120
|
pymax/types/domain/message.py,sha256=vb1Rmxnz145EP5_C1fpjvGLrenATN6HBivrst9M8OOc,14387
|
|
121
121
|
pymax/types/domain/name.py,sha256=qMIshIqgWkVuROxmiCRhwfJf8XtmhSBoEU6nXs_gEh0,523
|
|
@@ -141,7 +141,7 @@ pymax/types/events/__init__.py,sha256=fNLP_8zYRsew2k-1s8wXCJeSPm8QQ4gmiZ86B51SuC
|
|
|
141
141
|
pymax/types/events/file.py,sha256=XhpXn0Vt9OODkx1OkGb9jfQwc1uNgz1NTn_j9FZnQ8s,102
|
|
142
142
|
pymax/types/events/message.py,sha256=d4dlnpu3VCtZ4vFdRXaACvydAE9sbGGkk52E48K0U_U,1248
|
|
143
143
|
pymax/types/events/video.py,sha256=swBHYadmDS0SjLXGqVqRYsuMoVZ6MjD2aYR2fbM-AJc,104
|
|
144
|
-
maxapi_python-2.1.
|
|
145
|
-
maxapi_python-2.1.
|
|
146
|
-
maxapi_python-2.1.
|
|
147
|
-
maxapi_python-2.1.
|
|
144
|
+
maxapi_python-2.1.2.dist-info/METADATA,sha256=3jzi0v-s6AoiHhnIWurSxL6LLtBOcr3ZGDZGWcBshpU,7637
|
|
145
|
+
maxapi_python-2.1.2.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
146
|
+
maxapi_python-2.1.2.dist-info/licenses/LICENSE,sha256=hOR249ItqMdcly1A0amqEWRNRTq4Gv5NJtmQ3A5qK4E,1070
|
|
147
|
+
maxapi_python-2.1.2.dist-info/RECORD,,
|
pymax/__init__.py
CHANGED
pymax/api/bots/payloads.py
CHANGED
pymax/api/bots/service.py
CHANGED
|
@@ -23,13 +23,9 @@ class BotsService:
|
|
|
23
23
|
async def get_init_data(
|
|
24
24
|
self,
|
|
25
25
|
bot_id: int,
|
|
26
|
-
chat_id: int,
|
|
26
|
+
chat_id: int | None = None,
|
|
27
27
|
start_param: str | None = None,
|
|
28
28
|
) -> InitData:
|
|
29
|
-
frame = RequestInitDataPayload(
|
|
30
|
-
|
|
31
|
-
)
|
|
32
|
-
response = await self.app.invoke(
|
|
33
|
-
Opcode.WEB_APP_INIT_DATA, frame.to_payload()
|
|
34
|
-
)
|
|
29
|
+
frame = RequestInitDataPayload(bot_id=bot_id, chat_id=chat_id, start_param=start_param)
|
|
30
|
+
response = await self.app.invoke(Opcode.WEB_APP_INIT_DATA, frame.to_payload())
|
|
35
31
|
return require_payload_model(response, InitData)
|
pymax/app.py
CHANGED
|
@@ -33,9 +33,7 @@ class App(Generic[ClientT]):
|
|
|
33
33
|
self.dispatcher: Dispatcher[ClientT] = Dispatcher(self, root_router)
|
|
34
34
|
self.api = ApiFacade(self)
|
|
35
35
|
self.config = config
|
|
36
|
-
self.store = self.config.store or SessionStore(
|
|
37
|
-
config.work_dir, config.session_name
|
|
38
|
-
)
|
|
36
|
+
self.store = self.config.store or SessionStore(config.work_dir, config.session_name)
|
|
39
37
|
self.auth_flow = auth_flow
|
|
40
38
|
|
|
41
39
|
self.me: Profile | None = None
|
|
@@ -76,18 +74,14 @@ class App(Generic[ClientT]):
|
|
|
76
74
|
await self.connection.open()
|
|
77
75
|
|
|
78
76
|
handshake_device_id = (
|
|
79
|
-
session_data.device_id
|
|
80
|
-
if session_data
|
|
81
|
-
else self.config.device.device_id
|
|
77
|
+
session_data.device_id if session_data else self.config.device.device_id
|
|
82
78
|
)
|
|
83
79
|
logger.debug("running handshake")
|
|
84
80
|
await self.handshake(handshake_device_id)
|
|
85
81
|
except (ConnectionError, EOFError, OSError, TimeoutError) as e:
|
|
86
82
|
logger.exception("failed to connect or handshake")
|
|
87
83
|
await self.connection.close()
|
|
88
|
-
raise ConnectionError(
|
|
89
|
-
f"Failed to connect and handshake: {e}"
|
|
90
|
-
) from e
|
|
84
|
+
raise ConnectionError(f"Failed to connect and handshake: {e}") from e
|
|
91
85
|
|
|
92
86
|
self._ping_task = asyncio.create_task(self._ping_loop())
|
|
93
87
|
|
|
@@ -108,9 +102,7 @@ class App(Generic[ClientT]):
|
|
|
108
102
|
|
|
109
103
|
if not auth_result.token:
|
|
110
104
|
logger.error("authentication finished without token")
|
|
111
|
-
raise RuntimeError(
|
|
112
|
-
"Authentication failed: no token received"
|
|
113
|
-
)
|
|
105
|
+
raise RuntimeError("Authentication failed: no token received")
|
|
114
106
|
|
|
115
107
|
await self.store.save_session(
|
|
116
108
|
session_data := SessionInfo(
|
|
@@ -135,7 +127,7 @@ class App(Generic[ClientT]):
|
|
|
135
127
|
self.config.device.user_agent,
|
|
136
128
|
)
|
|
137
129
|
|
|
138
|
-
if response.token != self.session.token:
|
|
130
|
+
if response.token is not None and response.token != self.session.token:
|
|
139
131
|
await self.store.update_token(self.session.token, response.token)
|
|
140
132
|
self.session.token = response.token
|
|
141
133
|
|
|
@@ -189,7 +181,7 @@ class App(Generic[ClientT]):
|
|
|
189
181
|
opcode: int,
|
|
190
182
|
payload: dict[str, Any],
|
|
191
183
|
cmd: int = Command.REQUEST,
|
|
192
|
-
timeout: float | None =
|
|
184
|
+
timeout: float | None = None,
|
|
193
185
|
compress: bool = False,
|
|
194
186
|
) -> InboundFrame:
|
|
195
187
|
seq = self.connection.next_seq()
|
|
@@ -211,10 +203,11 @@ class App(Generic[ClientT]):
|
|
|
211
203
|
payload_keys,
|
|
212
204
|
)
|
|
213
205
|
logger.debug("Request data=%s", frame.model_dump())
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
sorted(response.payload.keys()) if response.payload else []
|
|
206
|
+
request_timeout = (
|
|
207
|
+
self.config.request_timeout if timeout is None else timeout
|
|
217
208
|
)
|
|
209
|
+
response = await self.connection.request(frame, timeout=request_timeout)
|
|
210
|
+
response_keys = sorted(response.payload.keys()) if response.payload else []
|
|
218
211
|
logger.debug(
|
|
219
212
|
"response opcode=%s cmd=%s seq=%s payload_keys=%s",
|
|
220
213
|
response.opcode,
|
pymax/types/domain/folder.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
from collections.abc import Iterator
|
|
2
1
|
from typing import Any
|
|
3
2
|
|
|
4
3
|
from pydantic import Field
|
|
5
|
-
from typing_extensions import override
|
|
6
4
|
|
|
7
5
|
from .base import CamelModel
|
|
8
6
|
|
|
@@ -68,7 +66,3 @@ class FolderList(CamelModel):
|
|
|
68
66
|
folders: list[Folder] = Field(default_factory=list)
|
|
69
67
|
all_filter_exclude_folders: list[Any] = Field(default_factory=list)
|
|
70
68
|
folder_sync: int = 0
|
|
71
|
-
|
|
72
|
-
@override
|
|
73
|
-
def __iter__(self) -> Iterator[Folder]: # pyright: ignore[reportIncompatibleMethodOverride]
|
|
74
|
-
yield from self.folders
|
pymax/types/domain/login.py
CHANGED
|
@@ -16,11 +16,9 @@ class LoginConfig(CamelModel):
|
|
|
16
16
|
class LoginResponse(CamelModel):
|
|
17
17
|
chats: list[Chat] = Field(default_factory=list)
|
|
18
18
|
profile: Profile
|
|
19
|
-
messages: dict[int, list[Message]] = Field(
|
|
20
|
-
default_factory=dict
|
|
21
|
-
) # chat_id -> [message]
|
|
19
|
+
messages: dict[int, list[Message]] = Field(default_factory=dict) # chat_id -> [message]
|
|
22
20
|
contacts: list[User | None] = Field(default_factory=list)
|
|
23
|
-
token: str
|
|
21
|
+
token: str | None = None
|
|
24
22
|
time: int | None = None
|
|
25
23
|
config: LoginConfig | None = None
|
|
26
24
|
|
|
@@ -29,19 +27,9 @@ class LoginResponse(CamelModel):
|
|
|
29
27
|
config_hash = self.config.hash if self.config is not None else None
|
|
30
28
|
|
|
31
29
|
return SyncState(
|
|
32
|
-
chats_sync=(
|
|
33
|
-
|
|
34
|
-
),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
),
|
|
38
|
-
drafts_sync=(
|
|
39
|
-
sync_time if sync_time is not None else current.drafts_sync
|
|
40
|
-
),
|
|
41
|
-
presence_sync=(
|
|
42
|
-
sync_time if sync_time is not None else current.presence_sync
|
|
43
|
-
),
|
|
44
|
-
config_hash=(
|
|
45
|
-
config_hash if config_hash is not None else current.config_hash
|
|
46
|
-
),
|
|
30
|
+
chats_sync=(sync_time if sync_time is not None else current.chats_sync),
|
|
31
|
+
contacts_sync=(sync_time if sync_time is not None else current.contacts_sync),
|
|
32
|
+
drafts_sync=(sync_time if sync_time is not None else current.drafts_sync),
|
|
33
|
+
presence_sync=(sync_time if sync_time is not None else current.presence_sync),
|
|
34
|
+
config_hash=(config_hash if config_hash is not None else current.config_hash),
|
|
47
35
|
)
|
|
File without changes
|