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.
Files changed (61) hide show
  1. {maxapi_python-2.3.0.dist-info → maxapi_python-2.4.0.dist-info}/METADATA +4 -1
  2. {maxapi_python-2.3.0.dist-info → maxapi_python-2.4.0.dist-info}/RECORD +61 -53
  3. {maxapi_python-2.3.0.dist-info → maxapi_python-2.4.0.dist-info}/WHEEL +1 -1
  4. pymax/__init__.py +7 -2
  5. pymax/_data/apk_fingerprints.json +682 -0
  6. pymax/api/auth/enums.py +1 -0
  7. pymax/api/auth/payloads.py +28 -2
  8. pymax/api/auth/service.py +88 -3
  9. pymax/api/chats/__init__.py +1 -0
  10. pymax/api/chats/enums.py +15 -0
  11. pymax/api/chats/payloads.py +16 -1
  12. pymax/api/chats/service.py +36 -1
  13. pymax/api/messages/payloads.py +33 -5
  14. pymax/api/messages/service.py +95 -13
  15. pymax/api/self/__init__.py +2 -1
  16. pymax/api/self/enums.py +9 -0
  17. pymax/api/self/payloads.py +40 -1
  18. pymax/api/self/service.py +37 -0
  19. pymax/api/session/service.py +21 -8
  20. pymax/api/uploads/payloads.py +6 -0
  21. pymax/api/uploads/service.py +198 -21
  22. pymax/app.py +69 -15
  23. pymax/base.py +8 -0
  24. pymax/client_web.py +2 -2
  25. pymax/config.py +44 -7
  26. pymax/connection/connection.py +29 -18
  27. pymax/dispatch/enums.py +1 -0
  28. pymax/dispatch/mapping.py +3 -1
  29. pymax/dispatch/resolvers.py +7 -1
  30. pymax/files/__init__.py +4 -1
  31. pymax/files/video.py +58 -0
  32. pymax/files/voice.py +39 -0
  33. pymax/fingerprint/__init__.py +1 -0
  34. pymax/fingerprint/fingerprint.py +47 -0
  35. pymax/fingerprint/models.py +11 -0
  36. pymax/infra/auth.py +4 -0
  37. pymax/infra/bots.py +3 -3
  38. pymax/infra/chat.py +38 -0
  39. pymax/infra/message.py +65 -9
  40. pymax/infra/self.py +25 -1
  41. pymax/protocol/enums.py +13 -0
  42. pymax/protocol/tcp/compression.py +18 -0
  43. pymax/protocol/tcp/payload.py +41 -5
  44. pymax/protocol/tcp/protocol.py +5 -1
  45. pymax/transport/tcp.py +6 -1
  46. pymax/transport/websocket.py +6 -3
  47. pymax/types/domain/__init__.py +2 -1
  48. pymax/types/domain/attachments/__init__.py +2 -1
  49. pymax/types/domain/attachments/enums.py +17 -1
  50. pymax/types/domain/attachments/poll.py +111 -0
  51. pymax/types/domain/attachments/sticker.py +1 -1
  52. pymax/types/domain/attachments/video.py +29 -8
  53. pymax/types/domain/chat.py +9 -9
  54. pymax/types/domain/handshake.py +16 -0
  55. pymax/types/domain/login.py +30 -1
  56. pymax/types/domain/message.py +47 -19
  57. pymax/types/domain/user.py +5 -5
  58. pymax/types/events/__init__.py +1 -0
  59. pymax/types/events/reaction.py +2 -2
  60. pymax/types/events/voice.py +5 -0
  61. {maxapi_python-2.3.0.dist-info → maxapi_python-2.4.0.dist-info}/licenses/LICENSE +0 -0
@@ -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:`edit`, :meth:`pin`, :meth:`delete`,
97
- :meth:`read`, :meth:`react`, :meth:`unreact` и :meth:`get_reactions`.
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 | None:
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: Отправленное сообщение или ``None``, если сервер не вернул
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 | None:
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: Отправленное сообщение или ``None``, если сервер не вернул
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: Отредактированное сообщение.
@@ -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)
@@ -5,3 +5,4 @@ from .presence import PresenceEvent
5
5
  from .reaction import ReactionUpdateEvent
6
6
  from .typing import TypingEvent
7
7
  from .video import VideoUploadSignal
8
+ from .voice import AudioUploadSignal
@@ -17,5 +17,5 @@ class ReactionUpdateEvent(CamelModel):
17
17
 
18
18
  message_id: str
19
19
  chat_id: int
20
- counters: list[ReactionCounter]
21
- total_count: int
20
+ counters: list[ReactionCounter] | None = None
21
+ total_count: int = 0
@@ -0,0 +1,5 @@
1
+ from pymax.types.domain.base import CamelModel
2
+
3
+
4
+ class AudioUploadSignal(CamelModel):
5
+ audio_id: int