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.
- maxapi_python-2.0.0.dist-info/METADATA +217 -0
- maxapi_python-2.0.0.dist-info/RECORD +140 -0
- {maxapi_python-1.2.4.dist-info → maxapi_python-2.0.0.dist-info}/WHEEL +1 -1
- pymax/__init__.py +50 -105
- pymax/api/__init__.py +17 -0
- pymax/api/auth/__init__.py +1 -0
- pymax/api/auth/enums.py +17 -0
- pymax/api/auth/payloads.py +129 -0
- pymax/api/auth/service.py +313 -0
- pymax/api/auth/types.py +13 -0
- pymax/api/chats/__init__.py +8 -0
- pymax/api/chats/enums.py +27 -0
- pymax/api/chats/payloads.py +103 -0
- pymax/api/chats/service.py +277 -0
- pymax/api/facade.py +32 -0
- pymax/api/messages/__init__.py +1 -0
- pymax/api/messages/enums.py +17 -0
- pymax/api/messages/payloads.py +92 -0
- pymax/api/messages/service.py +337 -0
- pymax/api/models.py +13 -0
- pymax/api/response.py +123 -0
- pymax/api/self/__init__.py +2 -0
- pymax/api/self/enums.py +11 -0
- pymax/api/self/payloads.py +41 -0
- pymax/api/self/service.py +142 -0
- pymax/api/session/__init__.py +1 -0
- pymax/api/session/enums.py +10 -0
- pymax/api/session/payloads.py +76 -0
- pymax/api/session/service.py +72 -0
- pymax/api/uploads/__init__.py +1 -0
- pymax/api/uploads/models.py +49 -0
- pymax/api/uploads/payloads.py +25 -0
- pymax/api/uploads/service.py +458 -0
- pymax/api/users/__init__.py +2 -0
- pymax/api/users/enums.py +12 -0
- pymax/api/users/payloads.py +16 -0
- pymax/api/users/service.py +124 -0
- pymax/app.py +273 -0
- pymax/auth/__init__.py +25 -0
- pymax/auth/base.py +37 -0
- pymax/auth/email.py +0 -0
- pymax/auth/models.py +5 -0
- pymax/auth/providers.py +127 -0
- pymax/auth/qr.py +135 -0
- pymax/auth/service.py +25 -0
- pymax/auth/sms.py +122 -0
- pymax/base.py +204 -0
- pymax/client.py +106 -0
- pymax/client_web.py +83 -0
- pymax/config.py +215 -0
- pymax/connection/__init__.py +1 -0
- pymax/connection/connection.py +205 -0
- pymax/connection/pending.py +46 -0
- pymax/connection/readers/__init__.py +2 -0
- pymax/connection/readers/base.py +6 -0
- pymax/connection/readers/tcp.py +29 -0
- pymax/connection/readers/ws.py +14 -0
- pymax/dispatch/__init__.py +10 -0
- pymax/dispatch/dispatcher.py +222 -0
- pymax/dispatch/enums.py +12 -0
- pymax/dispatch/mapping.py +73 -0
- pymax/dispatch/resolvers.py +52 -0
- pymax/dispatch/router.py +216 -0
- pymax/exceptions.py +22 -89
- pymax/files/__init__.py +9 -0
- pymax/files/base.py +82 -0
- pymax/files/file.py +76 -0
- pymax/files/photo.py +108 -0
- pymax/files/static.py +10 -0
- pymax/files/video.py +74 -0
- pymax/formatting/__init__.py +0 -0
- pymax/formatting/markdown.py +217 -0
- pymax/infra/__init__.py +1 -0
- pymax/infra/auth.py +55 -0
- pymax/infra/base.py +15 -0
- pymax/infra/chat.py +240 -0
- pymax/infra/message.py +252 -0
- pymax/infra/protocol.py +9 -0
- pymax/infra/self.py +139 -0
- pymax/infra/user.py +107 -0
- pymax/logging.py +129 -0
- pymax/protocol/__init__.py +11 -0
- pymax/protocol/base.py +13 -0
- pymax/{static/enum.py → protocol/enums.py} +36 -79
- pymax/protocol/models.py +33 -0
- pymax/protocol/tcp/__init__.py +1 -0
- pymax/protocol/tcp/compression.py +97 -0
- pymax/protocol/tcp/framing.py +68 -0
- pymax/protocol/tcp/payload.py +127 -0
- pymax/protocol/tcp/protocol.py +68 -0
- pymax/protocol/ws/__init__.py +1 -0
- pymax/protocol/ws/protocol.py +27 -0
- pymax/py.typed +0 -0
- pymax/routers.py +8 -0
- pymax/session/__init__.py +3 -0
- pymax/session/models.py +11 -0
- pymax/session/protocol.py +14 -0
- pymax/session/store.py +232 -0
- pymax/telemetry/__init__.py +3 -0
- pymax/telemetry/navigation.py +181 -0
- pymax/telemetry/payloads.py +142 -0
- pymax/telemetry/service.py +225 -0
- pymax/transport/__init__.py +0 -0
- pymax/transport/base.py +14 -0
- pymax/transport/tcp.py +93 -0
- pymax/transport/websocket.py +50 -0
- pymax/types/__init__.py +2 -0
- pymax/types/domain/__init__.py +11 -0
- pymax/types/domain/attachments/__init__.py +11 -0
- pymax/types/domain/attachments/audio.py +35 -0
- pymax/types/domain/attachments/call.py +26 -0
- pymax/types/domain/attachments/contact.py +32 -0
- pymax/types/domain/attachments/control.py +20 -0
- pymax/types/domain/attachments/enums.py +27 -0
- pymax/types/domain/attachments/file.py +56 -0
- pymax/types/domain/attachments/keyboards/__init__.py +1 -0
- pymax/types/domain/attachments/keyboards/inline.py +19 -0
- pymax/types/domain/attachments/photo.py +45 -0
- pymax/types/domain/attachments/share.py +29 -0
- pymax/types/domain/attachments/sticker.py +50 -0
- pymax/types/domain/attachments/video.py +90 -0
- pymax/types/domain/auth.py +161 -0
- pymax/types/domain/base.py +17 -0
- pymax/types/domain/chat.py +426 -0
- pymax/types/domain/element.py +24 -0
- pymax/types/domain/enums.py +24 -0
- pymax/types/domain/error.py +20 -0
- pymax/types/domain/folder.py +74 -0
- pymax/types/domain/login.py +35 -0
- pymax/types/domain/message.py +378 -0
- pymax/types/domain/name.py +20 -0
- pymax/types/domain/profile.py +15 -0
- pymax/types/domain/session.py +52 -0
- pymax/types/domain/sync.py +80 -0
- pymax/types/domain/user.py +117 -0
- pymax/types/events/__init__.py +3 -0
- pymax/types/events/file.py +5 -0
- pymax/types/events/message.py +37 -0
- pymax/types/events/video.py +5 -0
- maxapi_python-1.2.4.dist-info/METADATA +0 -205
- maxapi_python-1.2.4.dist-info/RECORD +0 -33
- pymax/core.py +0 -390
- pymax/crud.py +0 -96
- pymax/files.py +0 -138
- pymax/filters.py +0 -164
- pymax/formatter.py +0 -31
- pymax/formatting.py +0 -74
- pymax/interfaces.py +0 -552
- pymax/mixins/__init__.py +0 -40
- pymax/mixins/auth.py +0 -368
- pymax/mixins/channel.py +0 -130
- pymax/mixins/group.py +0 -458
- pymax/mixins/handler.py +0 -285
- pymax/mixins/message.py +0 -879
- pymax/mixins/scheduler.py +0 -28
- pymax/mixins/self.py +0 -259
- pymax/mixins/socket.py +0 -297
- pymax/mixins/telemetry.py +0 -112
- pymax/mixins/user.py +0 -219
- pymax/mixins/websocket.py +0 -142
- pymax/models.py +0 -8
- pymax/navigation.py +0 -187
- pymax/payloads.py +0 -367
- pymax/protocols.py +0 -123
- pymax/static/constant.py +0 -89
- pymax/types.py +0 -1220
- pymax/utils.py +0 -90
- {maxapi_python-1.2.4.dist-info → maxapi_python-2.0.0.dist-info}/licenses/LICENSE +0 -0
pymax/utils.py
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import re
|
|
2
|
-
import time
|
|
3
|
-
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
4
|
-
from typing import Any, NoReturn
|
|
5
|
-
|
|
6
|
-
import requests
|
|
7
|
-
|
|
8
|
-
from pymax.exceptions import Error, RateLimitError
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class MixinsUtils:
|
|
12
|
-
@staticmethod
|
|
13
|
-
def handle_error(data: dict[str, Any]) -> NoReturn:
|
|
14
|
-
error = data.get("payload", {}).get("error")
|
|
15
|
-
localized_message = data.get("payload", {}).get("localizedMessage")
|
|
16
|
-
title = data.get("payload", {}).get("title")
|
|
17
|
-
message = data.get("payload", {}).get("message")
|
|
18
|
-
|
|
19
|
-
if error == "too.many.requests": # TODO: вынести в статик
|
|
20
|
-
raise RateLimitError(
|
|
21
|
-
error=error,
|
|
22
|
-
message=message,
|
|
23
|
-
title=title,
|
|
24
|
-
localized_message=localized_message,
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
raise Error(
|
|
28
|
-
error=error,
|
|
29
|
-
message=message,
|
|
30
|
-
title=title,
|
|
31
|
-
localized_message=localized_message,
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
@staticmethod
|
|
35
|
-
def _fetch_and_extract(url: str, session: requests.Session) -> str | None:
|
|
36
|
-
try:
|
|
37
|
-
js_code = session.get(url, timeout=10).text
|
|
38
|
-
except requests.RequestException:
|
|
39
|
-
return None
|
|
40
|
-
return MixinsUtils._extract_version(js_code)
|
|
41
|
-
|
|
42
|
-
@staticmethod
|
|
43
|
-
def _extract_version(js_code: str) -> str | None:
|
|
44
|
-
ws_anchor = "wss://ws-api.oneme.ru/websocket"
|
|
45
|
-
pos = js_code.find(ws_anchor)
|
|
46
|
-
if pos == -1:
|
|
47
|
-
return None
|
|
48
|
-
|
|
49
|
-
snippet = js_code[pos : pos + 2000]
|
|
50
|
-
|
|
51
|
-
match = re.search(r'[:=]\s*"(\d{1,2}\.\d{1,2}\.\d{1,2})"', snippet)
|
|
52
|
-
if match:
|
|
53
|
-
version = match.group(1)
|
|
54
|
-
return version
|
|
55
|
-
|
|
56
|
-
return None
|
|
57
|
-
|
|
58
|
-
@staticmethod
|
|
59
|
-
def get_current_web_version() -> str | None:
|
|
60
|
-
try:
|
|
61
|
-
html = requests.get("https://web.max.ru/", timeout=10).text
|
|
62
|
-
except requests.RequestException:
|
|
63
|
-
return None
|
|
64
|
-
|
|
65
|
-
main_chunk_import = html.split("import(")[2].split(")")[0].strip("\"'")
|
|
66
|
-
main_chunk_url = f"https://web.max.ru{main_chunk_import}"
|
|
67
|
-
try:
|
|
68
|
-
main_chunk_code = requests.get(main_chunk_url, timeout=10).text
|
|
69
|
-
except requests.exceptions.RequestException as e:
|
|
70
|
-
return None
|
|
71
|
-
|
|
72
|
-
arr = main_chunk_code.split("\n")[0].split("[")[1].split("]")[0].split(",")
|
|
73
|
-
urls = []
|
|
74
|
-
for i in arr:
|
|
75
|
-
if "/chunks/" in i:
|
|
76
|
-
url = "https://web.max.ru/_app/immutable" + i[3 : len(i) - 1]
|
|
77
|
-
urls.append(url)
|
|
78
|
-
|
|
79
|
-
session = requests.Session()
|
|
80
|
-
session.headers["User-Agent"] = "Mozilla/5.0"
|
|
81
|
-
if urls:
|
|
82
|
-
with ThreadPoolExecutor(max_workers=8) as pool:
|
|
83
|
-
futures = [
|
|
84
|
-
pool.submit(MixinsUtils._fetch_and_extract, url, session) for url in urls
|
|
85
|
-
]
|
|
86
|
-
for f in as_completed(futures):
|
|
87
|
-
ver = f.result()
|
|
88
|
-
if ver:
|
|
89
|
-
return ver
|
|
90
|
-
return None
|
|
File without changes
|