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/payloads.py
DELETED
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
from typing import Any, Literal
|
|
2
|
-
|
|
3
|
-
from pydantic import AliasChoices, BaseModel, Field
|
|
4
|
-
|
|
5
|
-
from pymax.static.constant import (
|
|
6
|
-
DEFAULT_APP_VERSION,
|
|
7
|
-
DEFAULT_BUILD_NUMBER,
|
|
8
|
-
DEFAULT_CLIENT_SESSION_ID,
|
|
9
|
-
DEFAULT_DEVICE_LOCALE,
|
|
10
|
-
DEFAULT_DEVICE_NAME,
|
|
11
|
-
DEFAULT_DEVICE_TYPE,
|
|
12
|
-
DEFAULT_LOCALE,
|
|
13
|
-
DEFAULT_OS_VERSION,
|
|
14
|
-
DEFAULT_SCREEN,
|
|
15
|
-
DEFAULT_TIMEZONE,
|
|
16
|
-
DEFAULT_USER_AGENT,
|
|
17
|
-
)
|
|
18
|
-
from pymax.static.enum import AttachType, AuthType, ContactAction, ReadAction
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def to_camel(string: str) -> str:
|
|
22
|
-
parts = string.split("_")
|
|
23
|
-
return parts[0] + "".join(word.capitalize() for word in parts[1:])
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class CamelModel(BaseModel):
|
|
27
|
-
model_config = {
|
|
28
|
-
"alias_generator": to_camel,
|
|
29
|
-
"populate_by_name": True,
|
|
30
|
-
"arbitrary_types_allowed": True,
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class BaseWebSocketMessage(BaseModel):
|
|
35
|
-
ver: Literal[10, 11] = 11
|
|
36
|
-
cmd: int
|
|
37
|
-
seq: int
|
|
38
|
-
opcode: int
|
|
39
|
-
payload: dict[str, Any]
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
class UserAgentPayload(CamelModel):
|
|
43
|
-
device_type: str = Field(default=DEFAULT_DEVICE_TYPE)
|
|
44
|
-
locale: str = Field(default=DEFAULT_LOCALE)
|
|
45
|
-
device_locale: str = Field(default=DEFAULT_DEVICE_LOCALE)
|
|
46
|
-
os_version: str = Field(default=DEFAULT_OS_VERSION)
|
|
47
|
-
device_name: str = Field(default=DEFAULT_DEVICE_NAME)
|
|
48
|
-
header_user_agent: str = Field(default=DEFAULT_USER_AGENT)
|
|
49
|
-
app_version: str = Field(default=DEFAULT_APP_VERSION)
|
|
50
|
-
screen: str = Field(default=DEFAULT_SCREEN)
|
|
51
|
-
timezone: str = Field(default=DEFAULT_TIMEZONE)
|
|
52
|
-
client_session_id: int = Field(default=DEFAULT_CLIENT_SESSION_ID)
|
|
53
|
-
build_number: int = Field(default=DEFAULT_BUILD_NUMBER)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
class RequestCodePayload(CamelModel):
|
|
57
|
-
phone: str
|
|
58
|
-
type: AuthType = AuthType.START_AUTH
|
|
59
|
-
language: str = "ru"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
class SendCodePayload(CamelModel):
|
|
63
|
-
token: str
|
|
64
|
-
verify_code: str
|
|
65
|
-
auth_token_type: AuthType = AuthType.CHECK_CODE
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
class SyncPayload(CamelModel):
|
|
69
|
-
interactive: bool = True
|
|
70
|
-
token: str
|
|
71
|
-
chats_sync: int = 0
|
|
72
|
-
contacts_sync: int = 0
|
|
73
|
-
presence_sync: int = 0
|
|
74
|
-
drafts_sync: int = 0
|
|
75
|
-
chats_count: int = 40
|
|
76
|
-
user_agent: UserAgentPayload = Field(
|
|
77
|
-
default_factory=lambda: UserAgentPayload(
|
|
78
|
-
device_type=DEFAULT_DEVICE_TYPE,
|
|
79
|
-
locale=DEFAULT_LOCALE,
|
|
80
|
-
device_locale=DEFAULT_DEVICE_LOCALE,
|
|
81
|
-
os_version=DEFAULT_OS_VERSION,
|
|
82
|
-
device_name=DEFAULT_DEVICE_NAME,
|
|
83
|
-
header_user_agent=DEFAULT_USER_AGENT,
|
|
84
|
-
app_version=DEFAULT_APP_VERSION,
|
|
85
|
-
screen=DEFAULT_SCREEN,
|
|
86
|
-
timezone=DEFAULT_TIMEZONE,
|
|
87
|
-
client_session_id=DEFAULT_CLIENT_SESSION_ID,
|
|
88
|
-
build_number=DEFAULT_BUILD_NUMBER,
|
|
89
|
-
),
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
class ReplyLink(CamelModel):
|
|
94
|
-
type: str = "REPLY"
|
|
95
|
-
message_id: str
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
class UploadPayload(CamelModel):
|
|
99
|
-
count: int = 1
|
|
100
|
-
profile: bool = False
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
class AttachPhotoPayload(CamelModel):
|
|
104
|
-
type: AttachType = Field(default=AttachType.PHOTO, alias="_type")
|
|
105
|
-
photo_token: str
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
class VideoAttachPayload(CamelModel):
|
|
109
|
-
type: AttachType = Field(default=AttachType.VIDEO, alias="_type")
|
|
110
|
-
video_id: int
|
|
111
|
-
token: str
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
class AttachFilePayload(CamelModel):
|
|
115
|
-
type: AttachType = Field(default=AttachType.FILE, alias="_type")
|
|
116
|
-
file_id: int
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
class MessageElement(CamelModel):
|
|
120
|
-
type: str
|
|
121
|
-
from_: int = Field(..., alias="from")
|
|
122
|
-
length: int
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
class SendMessagePayloadMessage(CamelModel):
|
|
126
|
-
text: str
|
|
127
|
-
cid: int
|
|
128
|
-
elements: list[MessageElement]
|
|
129
|
-
attaches: list[AttachPhotoPayload | AttachFilePayload | VideoAttachPayload]
|
|
130
|
-
link: ReplyLink | None = None
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
class SendMessagePayload(CamelModel):
|
|
134
|
-
chat_id: int
|
|
135
|
-
message: SendMessagePayloadMessage
|
|
136
|
-
notify: bool = False
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
class EditMessagePayload(CamelModel):
|
|
140
|
-
chat_id: int
|
|
141
|
-
message_id: int
|
|
142
|
-
text: str
|
|
143
|
-
elements: list[MessageElement]
|
|
144
|
-
attaches: list[AttachPhotoPayload | AttachFilePayload | VideoAttachPayload]
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
class DeleteMessagePayload(CamelModel):
|
|
148
|
-
chat_id: int
|
|
149
|
-
message_ids: list[int]
|
|
150
|
-
for_me: bool = False
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
class FetchContactsPayload(CamelModel):
|
|
154
|
-
contact_ids: list[int]
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
class FetchHistoryPayload(CamelModel):
|
|
158
|
-
chat_id: int
|
|
159
|
-
from_time: int = Field(
|
|
160
|
-
validation_alias=AliasChoices("from_time", "from"),
|
|
161
|
-
serialization_alias="from",
|
|
162
|
-
)
|
|
163
|
-
forward: int
|
|
164
|
-
backward: int = 200
|
|
165
|
-
get_messages: bool = True
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
class ChangeProfilePayload(CamelModel):
|
|
169
|
-
first_name: str
|
|
170
|
-
last_name: str | None = None
|
|
171
|
-
description: str | None = None
|
|
172
|
-
photo_token: str | None = None
|
|
173
|
-
avatar_type: str = "USER_AVATAR" # TODO: вынести гада в энам
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
class ResolveLinkPayload(CamelModel):
|
|
177
|
-
link: str
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
class PinMessagePayload(CamelModel):
|
|
181
|
-
chat_id: int
|
|
182
|
-
notify_pin: bool
|
|
183
|
-
pin_message_id: int
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
class CreateGroupAttach(CamelModel):
|
|
187
|
-
type: Literal["CONTROL"] = Field("CONTROL", alias="_type")
|
|
188
|
-
event: str = "new"
|
|
189
|
-
chat_type: str = "CHAT"
|
|
190
|
-
title: str
|
|
191
|
-
user_ids: list[int]
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
class CreateGroupMessage(CamelModel):
|
|
195
|
-
cid: int
|
|
196
|
-
attaches: list[CreateGroupAttach]
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
class CreateGroupPayload(CamelModel):
|
|
200
|
-
message: CreateGroupMessage
|
|
201
|
-
notify: bool = True
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
class InviteUsersPayload(CamelModel):
|
|
205
|
-
chat_id: int
|
|
206
|
-
user_ids: list[int]
|
|
207
|
-
show_history: bool
|
|
208
|
-
operation: str = "add"
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
class RemoveUsersPayload(CamelModel):
|
|
212
|
-
chat_id: int
|
|
213
|
-
user_ids: list[int]
|
|
214
|
-
operation: str = "remove"
|
|
215
|
-
clean_msg_period: int
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
class ChangeGroupSettingsOptions(BaseModel):
|
|
219
|
-
ONLY_OWNER_CAN_CHANGE_ICON_TITLE: bool | None
|
|
220
|
-
ALL_CAN_PIN_MESSAGE: bool | None
|
|
221
|
-
ONLY_ADMIN_CAN_ADD_MEMBER: bool | None
|
|
222
|
-
ONLY_ADMIN_CAN_CALL: bool | None
|
|
223
|
-
MEMBERS_CAN_SEE_PRIVATE_LINK: bool | None
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
class ChangeGroupSettingsPayload(CamelModel):
|
|
227
|
-
chat_id: int
|
|
228
|
-
options: ChangeGroupSettingsOptions
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
class ChangeGroupProfilePayload(CamelModel):
|
|
232
|
-
chat_id: int
|
|
233
|
-
theme: str | None
|
|
234
|
-
description: str | None
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
class GetGroupMembersPayload(CamelModel):
|
|
238
|
-
type: Literal["MEMBER"] = "MEMBER"
|
|
239
|
-
marker: int | None = None
|
|
240
|
-
chat_id: int
|
|
241
|
-
count: int
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
class SearchGroupMembersPayload(CamelModel):
|
|
245
|
-
type: Literal["MEMBER"] = "MEMBER"
|
|
246
|
-
query: str
|
|
247
|
-
chat_id: int
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
class NavigationEventParams(BaseModel):
|
|
251
|
-
action_id: int
|
|
252
|
-
screen_to: int
|
|
253
|
-
screen_from: int | None = None
|
|
254
|
-
source_id: int
|
|
255
|
-
session_id: int
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
class NavigationEventPayload(CamelModel):
|
|
259
|
-
event: str
|
|
260
|
-
time: int
|
|
261
|
-
type: str = "NAV"
|
|
262
|
-
user_id: int
|
|
263
|
-
params: NavigationEventParams
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
class NavigationPayload(CamelModel):
|
|
267
|
-
events: list[NavigationEventPayload]
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
class GetVideoPayload(CamelModel):
|
|
271
|
-
chat_id: int
|
|
272
|
-
message_id: int | str
|
|
273
|
-
video_id: int
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
class GetFilePayload(CamelModel):
|
|
277
|
-
chat_id: int
|
|
278
|
-
message_id: str | int
|
|
279
|
-
file_id: int
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
class SearchByPhonePayload(CamelModel):
|
|
283
|
-
phone: str
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
class JoinChatPayload(CamelModel):
|
|
287
|
-
link: str
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
class ReactionInfoPayload(CamelModel):
|
|
291
|
-
reaction_type: str = "EMOJI"
|
|
292
|
-
id: str
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
class AddReactionPayload(CamelModel):
|
|
296
|
-
chat_id: int
|
|
297
|
-
message_id: str
|
|
298
|
-
reaction: ReactionInfoPayload
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
class GetReactionsPayload(CamelModel):
|
|
302
|
-
chat_id: int
|
|
303
|
-
message_ids: list[str]
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
class RemoveReactionPayload(CamelModel):
|
|
307
|
-
chat_id: int
|
|
308
|
-
message_id: str
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
class ReworkInviteLinkPayload(CamelModel):
|
|
312
|
-
revoke_private_link: bool = True
|
|
313
|
-
chat_id: int
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
class ContactActionPayload(CamelModel):
|
|
317
|
-
contact_id: int
|
|
318
|
-
action: ContactAction
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
class RegisterPayload(CamelModel):
|
|
322
|
-
last_name: str | None = None
|
|
323
|
-
first_name: str
|
|
324
|
-
token: str
|
|
325
|
-
token_type: AuthType = AuthType.REGISTER
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
class CreateFolderPayload(CamelModel):
|
|
329
|
-
id: str
|
|
330
|
-
title: str
|
|
331
|
-
include: list[int]
|
|
332
|
-
filters: list[Any] = []
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
class GetChatInfoPayload(CamelModel):
|
|
336
|
-
chat_ids: list[int]
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
class GetFolderPayload(CamelModel):
|
|
340
|
-
folder_sync: int = 0
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
class UpdateFolderPayload(CamelModel):
|
|
344
|
-
id: str
|
|
345
|
-
title: str
|
|
346
|
-
include: list[int]
|
|
347
|
-
filters: list[Any] = []
|
|
348
|
-
options: list[Any] = []
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
class DeleteFolderPayload(CamelModel):
|
|
352
|
-
folder_ids: list[str]
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
class LeaveChatPayload(CamelModel):
|
|
356
|
-
chat_id: int
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
class FetchChatsPayload(CamelModel):
|
|
360
|
-
marker: int
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
class ReadMessagesPayload(CamelModel):
|
|
364
|
-
type: ReadAction
|
|
365
|
-
chat_id: int
|
|
366
|
-
message_id: str
|
|
367
|
-
mark: int
|
pymax/protocols.py
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
from abc import ABC, abstractmethod
|
|
3
|
-
from collections.abc import Awaitable, Callable
|
|
4
|
-
from logging import Logger
|
|
5
|
-
from typing import TYPE_CHECKING, Any, Literal
|
|
6
|
-
|
|
7
|
-
from pymax.payloads import UserAgentPayload
|
|
8
|
-
from pymax.static.constant import DEFAULT_TIMEOUT
|
|
9
|
-
from pymax.static.enum import Opcode
|
|
10
|
-
from pymax.types import (
|
|
11
|
-
Channel,
|
|
12
|
-
Chat,
|
|
13
|
-
Dialog,
|
|
14
|
-
Me,
|
|
15
|
-
Message,
|
|
16
|
-
ReactionInfo,
|
|
17
|
-
User,
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
if TYPE_CHECKING:
|
|
21
|
-
import socket
|
|
22
|
-
import ssl
|
|
23
|
-
from pathlib import Path
|
|
24
|
-
from uuid import UUID
|
|
25
|
-
|
|
26
|
-
import websockets
|
|
27
|
-
|
|
28
|
-
from pymax.crud import Database
|
|
29
|
-
from pymax.filters import BaseFilter
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class ClientProtocol(ABC):
|
|
33
|
-
def __init__(self, logger: Logger) -> None:
|
|
34
|
-
super().__init__()
|
|
35
|
-
self.logger = logger
|
|
36
|
-
self._users: dict[int, User] = {}
|
|
37
|
-
self.chats: list[Chat] = []
|
|
38
|
-
self._database: Database
|
|
39
|
-
self._device_id: UUID
|
|
40
|
-
self.uri: str
|
|
41
|
-
self.is_connected: bool = False
|
|
42
|
-
self.phone: str
|
|
43
|
-
self.dialogs: list[Dialog] = []
|
|
44
|
-
self.channels: list[Channel] = []
|
|
45
|
-
self.contacts: list[User] = []
|
|
46
|
-
self.me: Me | None = None
|
|
47
|
-
self.host: str
|
|
48
|
-
self.port: int
|
|
49
|
-
self.proxy: str | Literal[True] | None
|
|
50
|
-
self.registration: bool
|
|
51
|
-
self.first_name: str
|
|
52
|
-
self.last_name: str | None
|
|
53
|
-
self._token: str | None
|
|
54
|
-
self._work_dir: str
|
|
55
|
-
self.reconnect: bool
|
|
56
|
-
self.headers: UserAgentPayload
|
|
57
|
-
self._database_path: Path
|
|
58
|
-
self._ws: websockets.ClientConnection | None = None
|
|
59
|
-
self._seq: int = 0
|
|
60
|
-
self._pending: dict[int, asyncio.Future[dict[str, Any]]] = {}
|
|
61
|
-
self._recv_task: asyncio.Task[Any] | None = None
|
|
62
|
-
self._incoming: asyncio.Queue[dict[str, Any]] | None = None
|
|
63
|
-
self._file_upload_waiters: dict[
|
|
64
|
-
int,
|
|
65
|
-
asyncio.Future[dict[str, Any]],
|
|
66
|
-
] = {}
|
|
67
|
-
self.user_agent = UserAgentPayload()
|
|
68
|
-
self._outgoing: asyncio.Queue[dict[str, Any]] | None = None
|
|
69
|
-
self._outgoing_task: asyncio.Task[Any] | None = None
|
|
70
|
-
self._error_count: int = 0
|
|
71
|
-
self._circuit_breaker: bool = False
|
|
72
|
-
self._last_error_time: float = 0.0
|
|
73
|
-
self._session_id: int
|
|
74
|
-
self._action_id: int = 0
|
|
75
|
-
self._current_screen: str = "chats_list_tab"
|
|
76
|
-
self._on_message_handlers: list[
|
|
77
|
-
tuple[Callable[[Message], Any], BaseFilter[Message] | None]
|
|
78
|
-
] = []
|
|
79
|
-
self._on_message_edit_handlers: list[
|
|
80
|
-
tuple[Callable[[Message], Any], BaseFilter[Message] | None]
|
|
81
|
-
] = []
|
|
82
|
-
self._on_message_delete_handlers: list[
|
|
83
|
-
tuple[Callable[[Message], Any], BaseFilter[Message] | None]
|
|
84
|
-
] = []
|
|
85
|
-
self._on_reaction_change_handlers: list[Callable[[str, int, ReactionInfo], Any]] = []
|
|
86
|
-
self._on_chat_update_handlers: list[Callable[[Chat], Any | Awaitable[Any]]] = []
|
|
87
|
-
self._on_raw_receive_handlers: list[Callable[[dict[str, Any]], Any | Awaitable[Any]]] = []
|
|
88
|
-
self._scheduled_tasks: list[tuple[Callable[[], Any | Awaitable[Any]], float]] = []
|
|
89
|
-
self._on_start_handler: Callable[[], Any | Awaitable[Any]] | None = None
|
|
90
|
-
self._background_tasks: set[asyncio.Task[Any]] = set()
|
|
91
|
-
self._ssl_context: ssl.SSLContext
|
|
92
|
-
self._socket: socket.socket | None = None
|
|
93
|
-
|
|
94
|
-
@abstractmethod
|
|
95
|
-
async def _send_and_wait(
|
|
96
|
-
self,
|
|
97
|
-
opcode: Opcode,
|
|
98
|
-
payload: dict[str, Any],
|
|
99
|
-
cmd: int = 0,
|
|
100
|
-
timeout: float = DEFAULT_TIMEOUT,
|
|
101
|
-
) -> dict[str, Any]:
|
|
102
|
-
pass
|
|
103
|
-
|
|
104
|
-
@abstractmethod
|
|
105
|
-
async def _get_chat(self, chat_id: int) -> Chat | None:
|
|
106
|
-
pass
|
|
107
|
-
|
|
108
|
-
@abstractmethod
|
|
109
|
-
async def _queue_message(
|
|
110
|
-
self,
|
|
111
|
-
opcode: int,
|
|
112
|
-
payload: dict[str, Any],
|
|
113
|
-
cmd: int = 0,
|
|
114
|
-
timeout: float = DEFAULT_TIMEOUT,
|
|
115
|
-
max_retries: int = 3,
|
|
116
|
-
) -> Message | None:
|
|
117
|
-
pass
|
|
118
|
-
|
|
119
|
-
@abstractmethod
|
|
120
|
-
def _create_safe_task(
|
|
121
|
-
self, coro: Awaitable[Any], name: str | None = None
|
|
122
|
-
) -> asyncio.Task[Any]:
|
|
123
|
-
pass
|
pymax/static/constant.py
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
from random import choice, randint
|
|
2
|
-
from re import Pattern, compile
|
|
3
|
-
from typing import Final
|
|
4
|
-
|
|
5
|
-
import ua_generator
|
|
6
|
-
from websockets.typing import Origin
|
|
7
|
-
|
|
8
|
-
from pymax.utils import MixinsUtils
|
|
9
|
-
|
|
10
|
-
DEVICE_NAMES: Final[list[str]] = [
|
|
11
|
-
"Chrome",
|
|
12
|
-
"Firefox",
|
|
13
|
-
"Edge",
|
|
14
|
-
"Safari",
|
|
15
|
-
"Opera",
|
|
16
|
-
"Vivaldi",
|
|
17
|
-
"Brave",
|
|
18
|
-
"Chromium",
|
|
19
|
-
# os
|
|
20
|
-
"Windows 10",
|
|
21
|
-
"Windows 11",
|
|
22
|
-
"macOS Big Sur",
|
|
23
|
-
"macOS Monterey",
|
|
24
|
-
"macOS Ventura",
|
|
25
|
-
"Ubuntu 20.04",
|
|
26
|
-
"Ubuntu 22.04",
|
|
27
|
-
"Fedora 35",
|
|
28
|
-
"Fedora 36",
|
|
29
|
-
"Debian 11",
|
|
30
|
-
]
|
|
31
|
-
SCREEN_SIZES: Final[list[str]] = [
|
|
32
|
-
"1920x1080 1.0x",
|
|
33
|
-
"1366x768 1.0x",
|
|
34
|
-
"1440x900 1.0x",
|
|
35
|
-
"1536x864 1.0x",
|
|
36
|
-
"1280x720 1.0x",
|
|
37
|
-
"1600x900 1.0x",
|
|
38
|
-
"1680x1050 1.0x",
|
|
39
|
-
"2560x1440 1.0x",
|
|
40
|
-
"3840x2160 1.0x",
|
|
41
|
-
]
|
|
42
|
-
OS_VERSIONS: Final[list[str]] = [
|
|
43
|
-
"Windows 10",
|
|
44
|
-
"Windows 11",
|
|
45
|
-
"macOS Big Sur",
|
|
46
|
-
"macOS Monterey",
|
|
47
|
-
"macOS Ventura",
|
|
48
|
-
"Ubuntu 20.04",
|
|
49
|
-
"Ubuntu 22.04",
|
|
50
|
-
"Fedora 35",
|
|
51
|
-
"Fedora 36",
|
|
52
|
-
"Debian 11",
|
|
53
|
-
]
|
|
54
|
-
TIMEZONES: Final[list[str]] = [
|
|
55
|
-
"Europe/Moscow",
|
|
56
|
-
"Europe/Kaliningrad",
|
|
57
|
-
"Europe/Samara",
|
|
58
|
-
"Asia/Yekaterinburg",
|
|
59
|
-
"Asia/Omsk",
|
|
60
|
-
"Asia/Krasnoyarsk",
|
|
61
|
-
"Asia/Irkutsk",
|
|
62
|
-
"Asia/Yakutsk",
|
|
63
|
-
"Asia/Vladivostok",
|
|
64
|
-
"Asia/Kamchatka",
|
|
65
|
-
]
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
PHONE_REGEX: Final[Pattern[str]] = compile(r"^\+?\d{10,15}$")
|
|
69
|
-
WEBSOCKET_URI: Final[str] = "wss://ws-api.oneme.ru/websocket"
|
|
70
|
-
SESSION_STORAGE_DB = "session.db"
|
|
71
|
-
WEBSOCKET_ORIGIN: Final[Origin] = Origin("https://web.max.ru")
|
|
72
|
-
HOST: Final[str] = "api.oneme.ru"
|
|
73
|
-
PORT: Final[int] = 443
|
|
74
|
-
DEFAULT_TIMEOUT: Final[float] = 20.0
|
|
75
|
-
DEFAULT_DEVICE_TYPE: Final[str] = "DESKTOP"
|
|
76
|
-
DEFAULT_LOCALE: Final[str] = "ru"
|
|
77
|
-
DEFAULT_DEVICE_LOCALE: Final[str] = "ru"
|
|
78
|
-
DEFAULT_DEVICE_NAME: Final[str] = choice(DEVICE_NAMES)
|
|
79
|
-
DEFAULT_APP_VERSION: Final[str] = "25.12.14"
|
|
80
|
-
DEFAULT_SCREEN: Final[str] = "1080x1920 1.0x"
|
|
81
|
-
DEFAULT_OS_VERSION: Final[str] = choice(OS_VERSIONS)
|
|
82
|
-
DEFAULT_USER_AGENT: Final[str] = ua_generator.generate().text
|
|
83
|
-
DEFAULT_BUILD_NUMBER: Final[int] = 0x97CB
|
|
84
|
-
DEFAULT_CLIENT_SESSION_ID: Final[int] = randint(1, 15)
|
|
85
|
-
DEFAULT_TIMEZONE: Final[str] = choice(TIMEZONES)
|
|
86
|
-
DEFAULT_CHAT_MEMBERS_LIMIT: Final[int] = 50
|
|
87
|
-
DEFAULT_MARKER_VALUE: Final[int] = 0
|
|
88
|
-
DEFAULT_PING_INTERVAL: Final[float] = 30.0
|
|
89
|
-
RECV_LOOP_BACKOFF_DELAY: Final[float] = 0.5
|