maxapi-python 1.2.4__py3-none-any.whl → 2.0.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 (168) hide show
  1. maxapi_python-2.0.0.dist-info/METADATA +217 -0
  2. maxapi_python-2.0.0.dist-info/RECORD +140 -0
  3. {maxapi_python-1.2.4.dist-info → maxapi_python-2.0.0.dist-info}/WHEEL +1 -1
  4. pymax/__init__.py +50 -105
  5. pymax/api/__init__.py +17 -0
  6. pymax/api/auth/__init__.py +1 -0
  7. pymax/api/auth/enums.py +17 -0
  8. pymax/api/auth/payloads.py +129 -0
  9. pymax/api/auth/service.py +313 -0
  10. pymax/api/auth/types.py +13 -0
  11. pymax/api/chats/__init__.py +8 -0
  12. pymax/api/chats/enums.py +27 -0
  13. pymax/api/chats/payloads.py +103 -0
  14. pymax/api/chats/service.py +277 -0
  15. pymax/api/facade.py +32 -0
  16. pymax/api/messages/__init__.py +1 -0
  17. pymax/api/messages/enums.py +17 -0
  18. pymax/api/messages/payloads.py +92 -0
  19. pymax/api/messages/service.py +337 -0
  20. pymax/api/models.py +13 -0
  21. pymax/api/response.py +123 -0
  22. pymax/api/self/__init__.py +2 -0
  23. pymax/api/self/enums.py +11 -0
  24. pymax/api/self/payloads.py +41 -0
  25. pymax/api/self/service.py +142 -0
  26. pymax/api/session/__init__.py +1 -0
  27. pymax/api/session/enums.py +10 -0
  28. pymax/api/session/payloads.py +76 -0
  29. pymax/api/session/service.py +72 -0
  30. pymax/api/uploads/__init__.py +1 -0
  31. pymax/api/uploads/models.py +49 -0
  32. pymax/api/uploads/payloads.py +25 -0
  33. pymax/api/uploads/service.py +458 -0
  34. pymax/api/users/__init__.py +2 -0
  35. pymax/api/users/enums.py +12 -0
  36. pymax/api/users/payloads.py +16 -0
  37. pymax/api/users/service.py +124 -0
  38. pymax/app.py +273 -0
  39. pymax/auth/__init__.py +25 -0
  40. pymax/auth/base.py +37 -0
  41. pymax/auth/email.py +0 -0
  42. pymax/auth/models.py +5 -0
  43. pymax/auth/providers.py +127 -0
  44. pymax/auth/qr.py +135 -0
  45. pymax/auth/service.py +25 -0
  46. pymax/auth/sms.py +122 -0
  47. pymax/base.py +204 -0
  48. pymax/client.py +106 -0
  49. pymax/client_web.py +83 -0
  50. pymax/config.py +215 -0
  51. pymax/connection/__init__.py +1 -0
  52. pymax/connection/connection.py +205 -0
  53. pymax/connection/pending.py +46 -0
  54. pymax/connection/readers/__init__.py +2 -0
  55. pymax/connection/readers/base.py +6 -0
  56. pymax/connection/readers/tcp.py +29 -0
  57. pymax/connection/readers/ws.py +14 -0
  58. pymax/dispatch/__init__.py +10 -0
  59. pymax/dispatch/dispatcher.py +222 -0
  60. pymax/dispatch/enums.py +12 -0
  61. pymax/dispatch/mapping.py +73 -0
  62. pymax/dispatch/resolvers.py +52 -0
  63. pymax/dispatch/router.py +216 -0
  64. pymax/exceptions.py +22 -89
  65. pymax/files/__init__.py +9 -0
  66. pymax/files/base.py +82 -0
  67. pymax/files/file.py +76 -0
  68. pymax/files/photo.py +108 -0
  69. pymax/files/static.py +10 -0
  70. pymax/files/video.py +74 -0
  71. pymax/formatting/__init__.py +0 -0
  72. pymax/formatting/markdown.py +217 -0
  73. pymax/infra/__init__.py +1 -0
  74. pymax/infra/auth.py +55 -0
  75. pymax/infra/base.py +15 -0
  76. pymax/infra/chat.py +240 -0
  77. pymax/infra/message.py +252 -0
  78. pymax/infra/protocol.py +9 -0
  79. pymax/infra/self.py +139 -0
  80. pymax/infra/user.py +107 -0
  81. pymax/logging.py +129 -0
  82. pymax/protocol/__init__.py +11 -0
  83. pymax/protocol/base.py +13 -0
  84. pymax/{static/enum.py → protocol/enums.py} +36 -79
  85. pymax/protocol/models.py +33 -0
  86. pymax/protocol/tcp/__init__.py +1 -0
  87. pymax/protocol/tcp/compression.py +97 -0
  88. pymax/protocol/tcp/framing.py +68 -0
  89. pymax/protocol/tcp/payload.py +127 -0
  90. pymax/protocol/tcp/protocol.py +68 -0
  91. pymax/protocol/ws/__init__.py +1 -0
  92. pymax/protocol/ws/protocol.py +27 -0
  93. pymax/py.typed +0 -0
  94. pymax/routers.py +8 -0
  95. pymax/session/__init__.py +3 -0
  96. pymax/session/models.py +11 -0
  97. pymax/session/protocol.py +14 -0
  98. pymax/session/store.py +232 -0
  99. pymax/telemetry/__init__.py +3 -0
  100. pymax/telemetry/navigation.py +181 -0
  101. pymax/telemetry/payloads.py +142 -0
  102. pymax/telemetry/service.py +225 -0
  103. pymax/transport/__init__.py +0 -0
  104. pymax/transport/base.py +14 -0
  105. pymax/transport/tcp.py +93 -0
  106. pymax/transport/websocket.py +50 -0
  107. pymax/types/__init__.py +2 -0
  108. pymax/types/domain/__init__.py +11 -0
  109. pymax/types/domain/attachments/__init__.py +11 -0
  110. pymax/types/domain/attachments/audio.py +35 -0
  111. pymax/types/domain/attachments/call.py +26 -0
  112. pymax/types/domain/attachments/contact.py +32 -0
  113. pymax/types/domain/attachments/control.py +20 -0
  114. pymax/types/domain/attachments/enums.py +27 -0
  115. pymax/types/domain/attachments/file.py +56 -0
  116. pymax/types/domain/attachments/keyboards/__init__.py +1 -0
  117. pymax/types/domain/attachments/keyboards/inline.py +19 -0
  118. pymax/types/domain/attachments/photo.py +45 -0
  119. pymax/types/domain/attachments/share.py +29 -0
  120. pymax/types/domain/attachments/sticker.py +50 -0
  121. pymax/types/domain/attachments/video.py +90 -0
  122. pymax/types/domain/auth.py +161 -0
  123. pymax/types/domain/base.py +17 -0
  124. pymax/types/domain/chat.py +426 -0
  125. pymax/types/domain/element.py +24 -0
  126. pymax/types/domain/enums.py +24 -0
  127. pymax/types/domain/error.py +20 -0
  128. pymax/types/domain/folder.py +74 -0
  129. pymax/types/domain/login.py +35 -0
  130. pymax/types/domain/message.py +378 -0
  131. pymax/types/domain/name.py +20 -0
  132. pymax/types/domain/profile.py +15 -0
  133. pymax/types/domain/session.py +52 -0
  134. pymax/types/domain/sync.py +80 -0
  135. pymax/types/domain/user.py +117 -0
  136. pymax/types/events/__init__.py +3 -0
  137. pymax/types/events/file.py +5 -0
  138. pymax/types/events/message.py +37 -0
  139. pymax/types/events/video.py +5 -0
  140. maxapi_python-1.2.4.dist-info/METADATA +0 -205
  141. maxapi_python-1.2.4.dist-info/RECORD +0 -33
  142. pymax/core.py +0 -390
  143. pymax/crud.py +0 -96
  144. pymax/files.py +0 -138
  145. pymax/filters.py +0 -164
  146. pymax/formatter.py +0 -31
  147. pymax/formatting.py +0 -74
  148. pymax/interfaces.py +0 -552
  149. pymax/mixins/__init__.py +0 -40
  150. pymax/mixins/auth.py +0 -368
  151. pymax/mixins/channel.py +0 -130
  152. pymax/mixins/group.py +0 -458
  153. pymax/mixins/handler.py +0 -285
  154. pymax/mixins/message.py +0 -879
  155. pymax/mixins/scheduler.py +0 -28
  156. pymax/mixins/self.py +0 -259
  157. pymax/mixins/socket.py +0 -297
  158. pymax/mixins/telemetry.py +0 -112
  159. pymax/mixins/user.py +0 -219
  160. pymax/mixins/websocket.py +0 -142
  161. pymax/models.py +0 -8
  162. pymax/navigation.py +0 -187
  163. pymax/payloads.py +0 -367
  164. pymax/protocols.py +0 -123
  165. pymax/static/constant.py +0 -89
  166. pymax/types.py +0 -1220
  167. pymax/utils.py +0 -90
  168. {maxapi_python-1.2.4.dist-info → maxapi_python-2.0.0.dist-info}/licenses/LICENSE +0 -0
pymax/mixins/handler.py DELETED
@@ -1,285 +0,0 @@
1
- from collections.abc import Awaitable, Callable
2
- from typing import Any
3
-
4
- from pymax.filters import BaseFilter
5
- from pymax.protocols import ClientProtocol
6
- from pymax.types import Chat, Message, ReactionInfo
7
-
8
-
9
- class HandlerMixin(ClientProtocol):
10
- def on_message(
11
- self, filter: BaseFilter[Message] | None = None
12
- ) -> Callable[
13
- [Callable[[Any], Any | Awaitable[Any]]],
14
- Callable[[Any], Any | Awaitable[Any]],
15
- ]:
16
- """
17
- Декоратор для регистрации обработчика входящих сообщений.
18
-
19
- Позволяет установить функцию-обработчик для всех входящих сообщений
20
- или только для сообщений, соответствующих заданному фильтру.
21
-
22
- :param filter: Фильтр для обработки сообщений. По умолчанию None.
23
- :type filter: BaseFilter[Message] | None
24
- :return: Декоратор для функции-обработчика.
25
- :rtype: Callable
26
-
27
- Example::
28
-
29
- @client.on_message(Filter.text("hello"))
30
- async def handle_hello(message: Message):
31
- await client.send_message(
32
- chat_id=message.chat_id,
33
- text="Hello!"
34
- )
35
- """
36
-
37
- def decorator(
38
- handler: Callable[[Any], Any | Awaitable[Any]],
39
- ) -> Callable[[Any], Any | Awaitable[Any]]:
40
- self._on_message_handlers.append((handler, filter))
41
- self.logger.debug(f"on_message handler set: {handler}, filter: {filter}")
42
- return handler
43
-
44
- return decorator
45
-
46
- def on_message_edit(
47
- self, filter: BaseFilter[Message] | None = None
48
- ) -> Callable[
49
- [Callable[[Any], Any | Awaitable[Any]]],
50
- Callable[[Any], Any | Awaitable[Any]],
51
- ]:
52
- """
53
- Декоратор для установки обработчика отредактированных сообщений.
54
-
55
- :param filter: Фильтр для обработки сообщений. По умолчанию None.
56
- :type filter: BaseFilter[Message] | None
57
- :return: Декоратор для функции-обработчика.
58
- :rtype: Callable
59
- """
60
-
61
- def decorator(
62
- handler: Callable[[Any], Any | Awaitable[Any]],
63
- ) -> Callable[[Any], Any | Awaitable[Any]]:
64
- self._on_message_edit_handlers.append((handler, filter))
65
- self.logger.debug(f"on_message_edit handler set: {handler}, filter: {filter}")
66
- return handler
67
-
68
- return decorator
69
-
70
- def on_message_delete(
71
- self, filter: BaseFilter[Message] | None = None
72
- ) -> Callable[
73
- [Callable[[Any], Any | Awaitable[Any]]],
74
- Callable[[Any], Any | Awaitable[Any]],
75
- ]:
76
- """
77
- Декоратор для установки обработчика удаленных сообщений.
78
-
79
- :param filter: Фильтр для обработки сообщений. По умолчанию None.
80
- :type filter: BaseFilter[Message] | None
81
- :return: Декоратор для функции-обработчика.
82
- :rtype: Callable
83
- """
84
-
85
- def decorator(
86
- handler: Callable[[Any], Any | Awaitable[Any]],
87
- ) -> Callable[[Any], Any | Awaitable[Any]]:
88
- self._on_message_delete_handlers.append((handler, filter))
89
- self.logger.debug(f"on_message_delete handler set: {handler}, filter: {filter}")
90
- return handler
91
-
92
- return decorator
93
-
94
- def on_reaction_change(
95
- self,
96
- handler: Callable[[str, int, ReactionInfo], Any | Awaitable[Any]],
97
- ) -> Callable[[str, int, ReactionInfo], Any | Awaitable[Any]]:
98
- """
99
- Устанавливает обработчик изменения реакций на сообщения.
100
-
101
- :param handler: Функция или coroutine с аргументами (message_id: str, chat_id: int, reaction_info: ReactionInfo).
102
- :type handler: Callable[[str, int, ReactionInfo], Any | Awaitable[Any]]
103
- :return: Установленный обработчик.
104
- :rtype: Callable[[str, int, ReactionInfo], Any | Awaitable[Any]]
105
- """
106
- self._on_reaction_change_handlers.append(handler)
107
- self.logger.debug("on_reaction_change handler set: %r", handler)
108
- return handler
109
-
110
- def on_chat_update(
111
- self, handler: Callable[[Chat], Any | Awaitable[Any]]
112
- ) -> Callable[[Chat], Any | Awaitable[Any]]:
113
- """
114
- Устанавливает обработчик обновления информации о чате.
115
-
116
- :param handler: Функция или coroutine с аргументом (chat: Chat).
117
- :type handler: Callable[[Chat], Any | Awaitable[Any]]
118
- :return: Установленный обработчик.
119
- :rtype: Callable[[Chat], Any | Awaitable[Any]]
120
- """
121
- self._on_chat_update_handlers.append(handler)
122
- self.logger.debug("on_chat_update handler set: %r", handler)
123
- return handler
124
-
125
- def on_raw_receive(
126
- self, handler: Callable[[dict[str, Any]], Any | Awaitable[Any]]
127
- ) -> Callable[[dict[str, Any]], Any | Awaitable[Any]]:
128
- """
129
- Устанавливает обработчик для получения необработанных данных от сервера.
130
-
131
- :param handler: Функция или coroutine с аргументом (data: dict).
132
- :type handler: Callable[[dict[str, Any]], Any | Awaitable[Any]]
133
- :return: Установленный обработчик.
134
- :rtype: Callable[[dict[str, Any]], Any | Awaitable[Any]]
135
- """
136
- self._on_raw_receive_handlers.append(handler)
137
- self.logger.debug("on_raw_receive handler set: %r", handler)
138
- return handler
139
-
140
- def on_start(
141
- self, handler: Callable[[], Any | Awaitable[Any]]
142
- ) -> Callable[[], Any | Awaitable[Any]]:
143
- """
144
- Устанавливает обработчик, вызываемый при старте клиента.
145
-
146
- :param handler: Функция или coroutine без аргументов.
147
- :type handler: Callable[[], Any | Awaitable[Any]]
148
- :return: Установленный обработчик.
149
- :rtype: Callable[[], Any | Awaitable[Any]]
150
- """
151
- self._on_start_handler = handler
152
- self.logger.debug("on_start handler set: %r", handler)
153
- return handler
154
-
155
- def task(self, seconds: float, minutes: float = 0, hours: float = 0):
156
- """
157
- Декоратор для планирования периодической задачи.
158
-
159
- :param seconds: Интервал выполнения в секундах.
160
- :type seconds: float
161
- :param minutes: Интервал выполнения в минутах. По умолчанию 0.
162
- :type minutes: float
163
- :param hours: Интервал выполнения в часах. По умолчанию 0.
164
- :type hours: float
165
- :return: Декоратор для функции-обработчика.
166
- :rtype: Callable[[], Any | Awaitable[Any]]
167
-
168
- Example::
169
-
170
- @client.task(seconds=10)
171
- async def task():
172
- await client.send_message(chat_id=123, text="Hello!")
173
- """
174
-
175
- def decorator(
176
- handler: Callable[[], Any | Awaitable[Any]],
177
- ) -> Callable[[], Any | Awaitable[Any]]:
178
- self._scheduled_tasks.append((handler, seconds + minutes * 60 + hours * 3600))
179
- self.logger.debug(
180
- f"task scheduled: {handler}, interval: {seconds + minutes * 60 + hours * 3600}s"
181
- )
182
- return handler
183
-
184
- return decorator
185
-
186
- def add_message_handler(
187
- self,
188
- handler: Callable[[Message], Any | Awaitable[Any]],
189
- filter: BaseFilter[Message] | None = None,
190
- ) -> Callable[[Message], Any | Awaitable[Any]]:
191
- """
192
- Добавляет обработчик входящих сообщений.
193
-
194
- :param handler: Обработчик.
195
- :type handler: Callable[[Message], Any | Awaitable[Any]]
196
- :param filter: Фильтр. По умолчанию None.
197
- :type filter: BaseFilter[Message] | None
198
- :return: Обработчик.
199
- :rtype: Callable[[Message], Any | Awaitable[Any]]
200
- """
201
- self.logger.debug("add_message_handler (alias) used")
202
- self._on_message_handlers.append((handler, filter))
203
- return handler
204
-
205
- def add_on_start_handler(
206
- self, handler: Callable[[], Any | Awaitable[Any]]
207
- ) -> Callable[[], Any | Awaitable[Any]]:
208
- """
209
- Добавляет обработчик, вызываемый при старте клиента.
210
-
211
- :param handler: Функция или coroutine без аргументов.
212
- :type handler: Callable[[], Any | Awaitable[Any]]
213
- :return: Установленный обработчик.
214
- :rtype: Callable[[], Any | Awaitable[Any]]
215
- """
216
- self.logger.debug("add_on_start_handler (alias) used")
217
- self._on_start_handler = handler
218
- return handler
219
-
220
- def add_reaction_change_handler(
221
- self,
222
- handler: Callable[[str, int, ReactionInfo], Any | Awaitable[Any]],
223
- ) -> Callable[[str, int, ReactionInfo], Any | Awaitable[Any]]:
224
- """
225
- Добавляет обработчик изменения реакций на сообщения.
226
-
227
- :param handler: Функция или coroutine с аргументами (message_id: str, chat_id: int, reaction_info: ReactionInfo).
228
- :type handler: Callable[[str, int, ReactionInfo], Any | Awaitable[Any]]
229
- :return: Установленный обработчик.
230
- :rtype: Callable[[str, int, ReactionInfo], Any | Awaitable[Any]]
231
- """
232
- self.logger.debug("add_reaction_change_handler (alias) used")
233
- self._on_reaction_change_handlers.append(
234
- handler,
235
- )
236
- return handler
237
-
238
- def add_chat_update_handler(
239
- self, handler: Callable[[Chat], Any | Awaitable[Any]]
240
- ) -> Callable[[Chat], Any | Awaitable[Any]]:
241
- """
242
- Добавляет обработчик обновления информации о чате.
243
-
244
- :param handler: Функция или coroutine с аргументом (chat: Chat).
245
- :type handler: Callable[[Chat], Any | Awaitable[Any]]
246
- :return: Установленный обработчик.
247
- :rtype: Callable[[Chat], Any | Awaitable[Any]]
248
- """
249
- self.logger.debug("add_chat_update_handler (alias) used")
250
- self._on_chat_update_handlers.append(handler)
251
- return handler
252
-
253
- def add_raw_receive_handler(
254
- self, handler: Callable[[dict[str, Any]], Any | Awaitable[Any]]
255
- ) -> Callable[[dict[str, Any]], Any | Awaitable[Any]]:
256
- """
257
- Добавляет обработчик для получения необработанных данных от сервера.
258
-
259
- :param handler: Функция или coroutine с аргументом (data: dict).
260
- :type handler: Callable[[dict[str, Any]], Any | Awaitable[Any]]
261
- :return: Установленный обработчик.
262
- :rtype: Callable[[dict[str, Any]], Any | Awaitable[Any]]
263
- """
264
- self.logger.debug("add_raw_receive_handler (alias) used")
265
- self._on_raw_receive_handlers.append(handler)
266
- return handler
267
-
268
- def add_scheduled_task(
269
- self,
270
- handler: Callable[[], Any | Awaitable[Any]],
271
- interval: float,
272
- ) -> Callable[[], Any | Awaitable[Any]]:
273
- """
274
- Добавляет периодическую задачу.
275
-
276
- :param handler: Функция или coroutine без аргументов.
277
- :type handler: Callable[[], Any | Awaitable[Any]]
278
- :param interval: Интервал выполнения в секундах.
279
- :type interval: float
280
- :return: Установленный обработчик.
281
- :rtype: Callable[[], Any | Awaitable[Any]]
282
- """
283
- self.logger.debug("add_scheduled_task (alias) used")
284
- self._scheduled_tasks.append((handler, interval))
285
- return handler