maxapi-python 1.1.3__py3-none-any.whl → 1.1.4__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-1.1.3.dist-info → maxapi_python-1.1.4.dist-info}/METADATA +1 -1
- {maxapi_python-1.1.3.dist-info → maxapi_python-1.1.4.dist-info}/RECORD +10 -10
- pymax/filters.py +4 -0
- pymax/mixins/group.py +1 -1
- pymax/mixins/message.py +2 -10
- pymax/mixins/socket.py +1 -3
- pymax/mixins/websocket.py +1 -1
- pymax/types.py +15 -10
- {maxapi_python-1.1.3.dist-info → maxapi_python-1.1.4.dist-info}/WHEEL +0 -0
- {maxapi_python-1.1.3.dist-info → maxapi_python-1.1.4.dist-info}/licenses/LICENSE +0 -0
@@ -3,26 +3,26 @@ pymax/core.py,sha256=6fqnP-eAgbUTM6F0Kj09TPJ3IOgvkHz5EsjJTI18r5A,7813
|
|
3
3
|
pymax/crud.py,sha256=Mk-c87GItS91BlJu6INDbw1-ovXyoB2D9rXHK8voxpU,3207
|
4
4
|
pymax/exceptions.py,sha256=msS11MD7qZPm0qZ6O8fobTm-GTldm2IA3uQLTX6eDxc,919
|
5
5
|
pymax/files.py,sha256=Tpv-43gS7I4Pwlaimb8mZ2B-ZkF3aMsrLYT20NPaqhE,2656
|
6
|
-
pymax/filters.py,sha256=
|
6
|
+
pymax/filters.py,sha256=fxC3Bl5AqrB8BSdN-CtiLWucbHCRA2IODpsOy2NagGU,1471
|
7
7
|
pymax/interfaces.py,sha256=_D6iMQI74Gdtl6-HMoE1acRFRHeITgOZPVFpt5pvoow,2394
|
8
8
|
pymax/models.py,sha256=PsPGbOkERxesZZltjNrmqhOfRcO44Is2ThbEToREcB8,201
|
9
9
|
pymax/navigation.py,sha256=16c1_FZrw24uFlP6W5-F8OrEQE73bkQA3HSFqTdBtgo,5725
|
10
10
|
pymax/payloads.py,sha256=yeBRxiMq6ixUQjMBBFcBDtBpYzqqfaEII3Z1kJq8pe8,3907
|
11
11
|
pymax/static.py,sha256=wwSV1ue5s5buqWz6TvCzjzN2ZWI-wITposTRvcS151g,4738
|
12
|
-
pymax/types.py,sha256=
|
12
|
+
pymax/types.py,sha256=pC87lOfRmM33ed2LY_S2c2KJTMvWJfrkTqerTp-dluk,18179
|
13
13
|
pymax/utils.py,sha256=F2TdoWfSwDLeh2uIcMIE_GTdXd7hU7gWti2i5P727bA,1364
|
14
14
|
pymax/mixins/__init__.py,sha256=-PSMwTVioS-VTy-EGfV-epaKFLy58R4N2b-rX6wJf-M,649
|
15
15
|
pymax/mixins/auth.py,sha256=vTNSZ6AunvDIMPQAvgYozpIZaCWMYiMDiabCBI7Sm6c,3079
|
16
16
|
pymax/mixins/channel.py,sha256=Stnf63GPtlQnsMPVEC9P0oardEOz50I4DCXN5H5s1SM,823
|
17
|
-
pymax/mixins/group.py,sha256=
|
17
|
+
pymax/mixins/group.py,sha256=NFdq6VExTKR80tE9XzVBjuG_eRMKEdYSm2HZop5yPYE,7809
|
18
18
|
pymax/mixins/handler.py,sha256=I1iNPaEgpvFnphaxV6liLwVaBCJ8sN6-h7908-_tPFk,2104
|
19
|
-
pymax/mixins/message.py,sha256=
|
19
|
+
pymax/mixins/message.py,sha256=fPQ69N-9O03BEsbhBQzHn6HTcHH3tWjR6VJtn_F2kzc,10099
|
20
20
|
pymax/mixins/self.py,sha256=V0gbkY3jfX9fnd7v06n4_s7P3HTPcS1KNPqUzA0vNi8,1169
|
21
|
-
pymax/mixins/socket.py,sha256=
|
21
|
+
pymax/mixins/socket.py,sha256=UNMU1Fh9J3xDV76J2Mx8bVHXo0gcS81qocOw8MM0XXs,15643
|
22
22
|
pymax/mixins/telemetry.py,sha256=0sQl6kvFVxobLthNAPNS9LzMrwwzZFA1xmOnvfiHWos,3522
|
23
23
|
pymax/mixins/user.py,sha256=U-epgvLruTDHBCrLDE0N0iWeOypGE1_SU8cKD3TE90U,3045
|
24
|
-
pymax/mixins/websocket.py,sha256=
|
25
|
-
maxapi_python-1.1.
|
26
|
-
maxapi_python-1.1.
|
27
|
-
maxapi_python-1.1.
|
28
|
-
maxapi_python-1.1.
|
24
|
+
pymax/mixins/websocket.py,sha256=L958bXTYh6U89jnmd0VWIUVtmJweUVFOMqjEuH8jWGo,10079
|
25
|
+
maxapi_python-1.1.4.dist-info/METADATA,sha256=DziHH8WPX4Ed1xzJ8at5MEGp0kMcKORFGNlKW1bb_-0,5930
|
26
|
+
maxapi_python-1.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
27
|
+
maxapi_python-1.1.4.dist-info/licenses/LICENSE,sha256=oe-AGp86WMKawV4KmqF28Q0m-kGAhPfAOPrEUm4MnVw,1064
|
28
|
+
maxapi_python-1.1.4.dist-info/RECORD,,
|
pymax/filters.py
CHANGED
@@ -5,6 +5,7 @@ from .types import Message
|
|
5
5
|
class Filter:
|
6
6
|
def __init__(
|
7
7
|
self,
|
8
|
+
chat_id: int | None = None,
|
8
9
|
user_id: int | None = None,
|
9
10
|
text: list[str] | None = None,
|
10
11
|
status: MessageStatus | str | None = None,
|
@@ -12,6 +13,7 @@ class Filter:
|
|
12
13
|
text_contains: str | None = None,
|
13
14
|
reaction_info: bool | None = None,
|
14
15
|
) -> None:
|
16
|
+
self.chat_id = chat_id
|
15
17
|
self.user_id = user_id
|
16
18
|
self.text = text
|
17
19
|
self.status = status
|
@@ -20,6 +22,8 @@ class Filter:
|
|
20
22
|
self.text_contains = text_contains
|
21
23
|
|
22
24
|
def match(self, message: Message) -> bool:
|
25
|
+
if self.chat_id is not None and message.chat_id != self.chat_id:
|
26
|
+
return False
|
23
27
|
if self.user_id is not None and message.sender != self.user_id:
|
24
28
|
return False
|
25
29
|
if self.text is not None and any(
|
pymax/mixins/group.py
CHANGED
@@ -51,7 +51,7 @@ class GroupMixin(ClientProtocol):
|
|
51
51
|
return None
|
52
52
|
|
53
53
|
chat = Chat.from_dict(data["payload"]["chat"])
|
54
|
-
message = Message.from_dict(data["payload"]
|
54
|
+
message = Message.from_dict(data["payload"])
|
55
55
|
|
56
56
|
if chat:
|
57
57
|
cached_chat = await self._get_chat(chat.id)
|
pymax/mixins/message.py
CHANGED
@@ -143,11 +143,7 @@ class MessageMixin(ClientProtocol):
|
|
143
143
|
self.logger.error("Send message error: %s", error)
|
144
144
|
print(data)
|
145
145
|
return None
|
146
|
-
msg = (
|
147
|
-
Message.from_dict(data["payload"]["message"])
|
148
|
-
if data.get("payload")
|
149
|
-
else None
|
150
|
-
)
|
146
|
+
msg = Message.from_dict(data["payload"]) if data.get("payload") else None
|
151
147
|
self.logger.debug("send_message result: %r", msg)
|
152
148
|
return msg
|
153
149
|
except Exception:
|
@@ -174,11 +170,7 @@ class MessageMixin(ClientProtocol):
|
|
174
170
|
data = await self._send_and_wait(opcode=Opcode.MSG_EDIT, payload=payload)
|
175
171
|
if error := data.get("payload", {}).get("error"):
|
176
172
|
self.logger.error("Edit message error: %s", error)
|
177
|
-
msg = (
|
178
|
-
Message.from_dict(data["payload"]["message"])
|
179
|
-
if data.get("payload")
|
180
|
-
else None
|
181
|
-
)
|
173
|
+
msg = Message.from_dict(data["payload"]) if data.get("payload") else None
|
182
174
|
self.logger.debug("edit_message result: %r", msg)
|
183
175
|
return msg
|
184
176
|
except Exception:
|
pymax/mixins/socket.py
CHANGED
@@ -214,9 +214,7 @@ Socket connections may be unstable, SSL issues are possible.
|
|
214
214
|
for handler, filter in self._on_message_handlers:
|
215
215
|
payload = data_item.get("payload", {})
|
216
216
|
msg_dict = (
|
217
|
-
payload
|
218
|
-
if isinstance(payload, dict)
|
219
|
-
else None
|
217
|
+
payload if isinstance(payload, dict) else None
|
220
218
|
)
|
221
219
|
msg = (
|
222
220
|
Message.from_dict(msg_dict)
|
pymax/mixins/websocket.py
CHANGED
@@ -118,7 +118,7 @@ class WebSocketMixin(ClientProtocol):
|
|
118
118
|
try:
|
119
119
|
for handler, filter in self._on_message_handlers:
|
120
120
|
payload = data.get("payload", {})
|
121
|
-
msg = Message.from_dict(payload
|
121
|
+
msg = Message.from_dict(payload)
|
122
122
|
if msg:
|
123
123
|
if msg.status:
|
124
124
|
continue # TODO: заглушка! сделать отдельный хендлер
|
pymax/types.py
CHANGED
@@ -230,6 +230,7 @@ class Element:
|
|
230
230
|
class Message:
|
231
231
|
def __init__(
|
232
232
|
self,
|
233
|
+
chat_id: int | None,
|
233
234
|
sender: int | None,
|
234
235
|
elements: list[Element] | None,
|
235
236
|
reaction_info: dict[str, Any] | None,
|
@@ -241,6 +242,7 @@ class Message:
|
|
241
242
|
type: MessageType | str,
|
242
243
|
attaches: list[PhotoAttach | VideoAttach | FileAttach],
|
243
244
|
) -> None:
|
245
|
+
self.chat_id = chat_id
|
244
246
|
self.sender = sender
|
245
247
|
self.elements = elements
|
246
248
|
self.options = options
|
@@ -254,8 +256,9 @@ class Message:
|
|
254
256
|
|
255
257
|
@classmethod
|
256
258
|
def from_dict(cls, data: dict[Any, Any]) -> "Message":
|
259
|
+
message = data["message"] if data.get("message") else data
|
257
260
|
attaches = []
|
258
|
-
for a in
|
261
|
+
for a in message.get("attaches", []):
|
259
262
|
if a["_type"] == AttachType.PHOTO:
|
260
263
|
attaches.append(PhotoAttach.from_dict(a))
|
261
264
|
elif a["_type"] == AttachType.VIDEO:
|
@@ -263,16 +266,17 @@ class Message:
|
|
263
266
|
elif a["_type"] == AttachType.FILE:
|
264
267
|
attaches.append(FileAttach.from_dict(a))
|
265
268
|
return cls(
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
269
|
+
chat_id=data.get("chatId"),
|
270
|
+
sender=message.get("sender"),
|
271
|
+
elements=[Element.from_dict(e) for e in message.get("elements", [])],
|
272
|
+
options=message.get("options"),
|
273
|
+
id=message["id"],
|
274
|
+
time=message["time"],
|
275
|
+
text=message["text"],
|
276
|
+
type=message["type"],
|
273
277
|
attaches=attaches,
|
274
|
-
status=
|
275
|
-
reaction_info=
|
278
|
+
status=message.get("status"),
|
279
|
+
reaction_info=message.get("reactionInfo"),
|
276
280
|
)
|
277
281
|
|
278
282
|
@override
|
@@ -280,6 +284,7 @@ class Message:
|
|
280
284
|
return (
|
281
285
|
f"Message(id={self.id!r}, sender={self.sender!r}, text={self.text!r}, "
|
282
286
|
f"type={self.type!r}, status={self.status!r}, elements={self.elements!r})"
|
287
|
+
f"attaches={self.attaches!r}, chat_id={self.chat_id!r}, time={self.time!r}, options={self.options!r}, reactionInfo={self.reactionInfo!r})"
|
283
288
|
)
|
284
289
|
|
285
290
|
@override
|
File without changes
|
File without changes
|