maxapi-python 2.3.0__py3-none-any.whl → 2.4.0__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.3.0.dist-info → maxapi_python-2.4.0.dist-info}/METADATA +4 -1
- {maxapi_python-2.3.0.dist-info → maxapi_python-2.4.0.dist-info}/RECORD +61 -53
- {maxapi_python-2.3.0.dist-info → maxapi_python-2.4.0.dist-info}/WHEEL +1 -1
- pymax/__init__.py +7 -2
- pymax/_data/apk_fingerprints.json +682 -0
- pymax/api/auth/enums.py +1 -0
- pymax/api/auth/payloads.py +28 -2
- pymax/api/auth/service.py +88 -3
- pymax/api/chats/__init__.py +1 -0
- pymax/api/chats/enums.py +15 -0
- pymax/api/chats/payloads.py +16 -1
- pymax/api/chats/service.py +36 -1
- pymax/api/messages/payloads.py +33 -5
- pymax/api/messages/service.py +95 -13
- pymax/api/self/__init__.py +2 -1
- pymax/api/self/enums.py +9 -0
- pymax/api/self/payloads.py +40 -1
- pymax/api/self/service.py +37 -0
- pymax/api/session/service.py +21 -8
- pymax/api/uploads/payloads.py +6 -0
- pymax/api/uploads/service.py +198 -21
- pymax/app.py +69 -15
- pymax/base.py +8 -0
- pymax/client_web.py +2 -2
- pymax/config.py +44 -7
- pymax/connection/connection.py +29 -18
- pymax/dispatch/enums.py +1 -0
- pymax/dispatch/mapping.py +3 -1
- pymax/dispatch/resolvers.py +7 -1
- pymax/files/__init__.py +4 -1
- pymax/files/video.py +58 -0
- pymax/files/voice.py +39 -0
- pymax/fingerprint/__init__.py +1 -0
- pymax/fingerprint/fingerprint.py +47 -0
- pymax/fingerprint/models.py +11 -0
- pymax/infra/auth.py +4 -0
- pymax/infra/bots.py +3 -3
- pymax/infra/chat.py +38 -0
- pymax/infra/message.py +65 -9
- pymax/infra/self.py +25 -1
- pymax/protocol/enums.py +13 -0
- pymax/protocol/tcp/compression.py +18 -0
- pymax/protocol/tcp/payload.py +41 -5
- pymax/protocol/tcp/protocol.py +5 -1
- pymax/transport/tcp.py +6 -1
- pymax/transport/websocket.py +6 -3
- pymax/types/domain/__init__.py +2 -1
- pymax/types/domain/attachments/__init__.py +2 -1
- pymax/types/domain/attachments/enums.py +17 -1
- pymax/types/domain/attachments/poll.py +111 -0
- pymax/types/domain/attachments/sticker.py +1 -1
- pymax/types/domain/attachments/video.py +29 -8
- pymax/types/domain/chat.py +9 -9
- pymax/types/domain/handshake.py +16 -0
- pymax/types/domain/login.py +30 -1
- pymax/types/domain/message.py +47 -19
- pymax/types/domain/user.py +5 -5
- pymax/types/events/__init__.py +1 -0
- pymax/types/events/reaction.py +2 -2
- pymax/types/events/voice.py +5 -0
- {maxapi_python-2.3.0.dist-info → maxapi_python-2.4.0.dist-info}/licenses/LICENSE +0 -0
pymax/types/domain/message.py
CHANGED
|
@@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Annotated, Any, TypeAlias
|
|
|
5
5
|
|
|
6
6
|
from pydantic import Field, PrivateAttr, model_validator
|
|
7
7
|
|
|
8
|
-
from pymax.files import File, Photo, Video
|
|
8
|
+
from pymax.files import File, Photo, Video, VideoNote, Voice
|
|
9
9
|
from pymax.types.domain import (
|
|
10
10
|
AudioAttachment,
|
|
11
11
|
CallAttachment,
|
|
@@ -14,6 +14,8 @@ from pymax.types.domain import (
|
|
|
14
14
|
FileAttachment,
|
|
15
15
|
InlineKeyboardAttachment,
|
|
16
16
|
PhotoAttachment,
|
|
17
|
+
Poll,
|
|
18
|
+
PollAttachment,
|
|
17
19
|
ShareAttachment,
|
|
18
20
|
StickerAttachment,
|
|
19
21
|
UnknownAttachment,
|
|
@@ -38,11 +40,12 @@ KnownAttachment: TypeAlias = Annotated[
|
|
|
38
40
|
| ControlAttachment
|
|
39
41
|
| InlineKeyboardAttachment
|
|
40
42
|
| ShareAttachment
|
|
41
|
-
| CallAttachment
|
|
43
|
+
| CallAttachment
|
|
44
|
+
| PollAttachment,
|
|
42
45
|
Field(discriminator="type"),
|
|
43
46
|
]
|
|
44
47
|
Attachment: TypeAlias = KnownAttachment | UnknownAttachment
|
|
45
|
-
SendAttachment: TypeAlias = Photo | File | Video
|
|
48
|
+
SendAttachment: TypeAlias = Photo | File | Video | Poll | Voice | VideoNote
|
|
46
49
|
SendAttachments: TypeAlias = Sequence[SendAttachment] | None
|
|
47
50
|
|
|
48
51
|
|
|
@@ -93,8 +96,9 @@ class Message(CamelModel):
|
|
|
93
96
|
|
|
94
97
|
Сообщения, полученные через клиент, обычно уже привязаны к сервису
|
|
95
98
|
сообщений. После этого можно вызывать удобные методы объекта:
|
|
96
|
-
:meth:`reply`, :meth:`answer`, :meth:`
|
|
97
|
-
:meth:`read`, :meth:`react`, :meth:`unreact` и
|
|
99
|
+
:meth:`reply`, :meth:`answer`, :meth:`forward`, :meth:`edit`, :meth:`pin`,
|
|
100
|
+
:meth:`delete`, :meth:`read`, :meth:`react`, :meth:`unreact` и
|
|
101
|
+
:meth:`get_reactions`.
|
|
98
102
|
|
|
99
103
|
Используйте ``Message`` в обработчиках ``on_message`` и при работе с
|
|
100
104
|
историей. Некоторые поля могут быть ``None``, потому что Max присылает
|
|
@@ -181,22 +185,21 @@ class Message(CamelModel):
|
|
|
181
185
|
|
|
182
186
|
async def reply(
|
|
183
187
|
self,
|
|
184
|
-
text: str,
|
|
188
|
+
text: str | None = None,
|
|
185
189
|
attachments: SendAttachments = None,
|
|
186
190
|
*,
|
|
187
191
|
notify: bool = True,
|
|
188
|
-
) -> Message
|
|
192
|
+
) -> Message:
|
|
189
193
|
"""Отправляет ответ на это сообщение в тот же чат.
|
|
190
194
|
|
|
191
195
|
:param text: Текст сообщения.
|
|
192
|
-
:type text: str
|
|
196
|
+
:type text: str | None
|
|
193
197
|
:param attachments: Файлы, фотографии или видео для отправки.
|
|
194
198
|
:type attachments: SendAttachments
|
|
195
199
|
:param notify: Отправить ли получателям push-уведомление.
|
|
196
200
|
:type notify: bool
|
|
197
|
-
:returns: Отправленное
|
|
198
|
-
|
|
199
|
-
:rtype: Message | None
|
|
201
|
+
:returns: Отправленное сообщение.
|
|
202
|
+
:rtype: Message
|
|
200
203
|
:raises RuntimeError: Если сообщение не привязано к сервису или не
|
|
201
204
|
содержит ``chat_id``.
|
|
202
205
|
"""
|
|
@@ -212,25 +215,24 @@ class Message(CamelModel):
|
|
|
212
215
|
|
|
213
216
|
async def answer(
|
|
214
217
|
self,
|
|
215
|
-
text: str,
|
|
218
|
+
text: str | None = None,
|
|
216
219
|
reply_to: int | None = None,
|
|
217
220
|
attachments: SendAttachments = None,
|
|
218
221
|
*,
|
|
219
222
|
notify: bool = True,
|
|
220
|
-
) -> Message
|
|
223
|
+
) -> Message:
|
|
221
224
|
"""Отправляет сообщение в тот же чат.
|
|
222
225
|
|
|
223
226
|
:param text: Текст сообщения.
|
|
224
|
-
:type text: str
|
|
227
|
+
:type text: str | None
|
|
225
228
|
:param reply_to: ID сообщения для ответа.
|
|
226
229
|
:type reply_to: int | None
|
|
227
230
|
:param attachments: Файлы, фотографии или видео для отправки.
|
|
228
231
|
:type attachments: SendAttachments
|
|
229
232
|
:param notify: Отправить ли получателям push-уведомление.
|
|
230
233
|
:type notify: bool
|
|
231
|
-
:returns: Отправленное
|
|
232
|
-
|
|
233
|
-
:rtype: Message | None
|
|
234
|
+
:returns: Отправленное сообщение.
|
|
235
|
+
:rtype: Message
|
|
234
236
|
:raises RuntimeError: Если сообщение не привязано к сервису или не
|
|
235
237
|
содержит ``chat_id``.
|
|
236
238
|
"""
|
|
@@ -244,6 +246,32 @@ class Message(CamelModel):
|
|
|
244
246
|
notify=notify,
|
|
245
247
|
)
|
|
246
248
|
|
|
249
|
+
async def forward(
|
|
250
|
+
self,
|
|
251
|
+
chat_id: int,
|
|
252
|
+
*,
|
|
253
|
+
notify: bool = True,
|
|
254
|
+
) -> Message:
|
|
255
|
+
"""Пересылает это сообщение в другой чат.
|
|
256
|
+
|
|
257
|
+
:param chat_id: ID целевого чата.
|
|
258
|
+
:type chat_id: int
|
|
259
|
+
:param notify: Отправить ли получателям push-уведомление.
|
|
260
|
+
:type notify: bool
|
|
261
|
+
:returns: Пересланное сообщение.
|
|
262
|
+
:rtype: Message
|
|
263
|
+
:raises RuntimeError: Если сообщение не привязано к сервису или не
|
|
264
|
+
содержит ``chat_id``.
|
|
265
|
+
"""
|
|
266
|
+
actions, source_chat_id = self._bound()
|
|
267
|
+
|
|
268
|
+
return await actions.forward_message(
|
|
269
|
+
chat_id=chat_id,
|
|
270
|
+
message_id=self.id,
|
|
271
|
+
source_chat_id=source_chat_id,
|
|
272
|
+
notify=notify,
|
|
273
|
+
)
|
|
274
|
+
|
|
247
275
|
async def pin(self, notify_pin: bool = True) -> bool:
|
|
248
276
|
"""Закрепляет это сообщение в чате.
|
|
249
277
|
|
|
@@ -264,13 +292,13 @@ class Message(CamelModel):
|
|
|
264
292
|
|
|
265
293
|
async def edit(
|
|
266
294
|
self,
|
|
267
|
-
text: str,
|
|
295
|
+
text: str | None = None,
|
|
268
296
|
attachments: SendAttachments = None,
|
|
269
297
|
) -> Message:
|
|
270
298
|
"""Редактирует текст и вложения этого сообщения.
|
|
271
299
|
|
|
272
300
|
:param text: Новый текст сообщения с поддержкой markdown.
|
|
273
|
-
:type text: str
|
|
301
|
+
:type text: str | None
|
|
274
302
|
:param attachments: Новые файлы, фотографии или видео для сообщения.
|
|
275
303
|
:type attachments: SendAttachments
|
|
276
304
|
:returns: Отредактированное сообщение.
|
pymax/types/domain/user.py
CHANGED
|
@@ -49,11 +49,11 @@ class User(CamelModel):
|
|
|
49
49
|
:ivar description: Описание профиля.
|
|
50
50
|
:vartype description: str | None
|
|
51
51
|
:ivar gender: Пол пользователя.
|
|
52
|
-
:vartype gender: str | None
|
|
52
|
+
:vartype gender: str | int | None
|
|
53
53
|
:ivar link: Ссылка на профиль.
|
|
54
54
|
:vartype link: str | None
|
|
55
55
|
:ivar web_app: Данные связанного web-приложения, если есть.
|
|
56
|
-
:vartype web_app: dict[str, Any] | None
|
|
56
|
+
:vartype web_app: dict[str, Any] | str | None
|
|
57
57
|
:ivar menu_button: Данные кнопки меню профиля, если есть.
|
|
58
58
|
:vartype menu_button: dict[str, Any] | None
|
|
59
59
|
"""
|
|
@@ -71,9 +71,9 @@ class User(CamelModel):
|
|
|
71
71
|
phone: int | None = None
|
|
72
72
|
status: str | None = None
|
|
73
73
|
description: str | None = None
|
|
74
|
-
gender: str | None = None
|
|
75
|
-
link: str | None = None
|
|
76
|
-
web_app: dict[str, Any] | None = None
|
|
74
|
+
gender: str | int | None = None
|
|
75
|
+
link: str | int | None = None
|
|
76
|
+
web_app: dict[str, Any] | str | None = None
|
|
77
77
|
menu_button: dict[str, Any] | None = None
|
|
78
78
|
|
|
79
79
|
_actions: UserService | None = PrivateAttr(default=None)
|
pymax/types/events/__init__.py
CHANGED
pymax/types/events/reaction.py
CHANGED
|
File without changes
|