maxapi-python 0.1.0__py3-none-any.whl → 0.1.1__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-0.1.1.dist-info/METADATA +147 -0
- maxapi_python-0.1.1.dist-info/RECORD +4 -0
- {maxapi_python-0.1.0.dist-info → maxapi_python-0.1.1.dist-info}/WHEEL +1 -2
- maxapi_python-0.1.0.dist-info/METADATA +0 -110
- maxapi_python-0.1.0.dist-info/RECORD +0 -12
- maxapi_python-0.1.0.dist-info/top_level.txt +0 -1
- pymax/__init__.py +0 -55
- pymax/core.py +0 -600
- pymax/crud.py +0 -99
- pymax/exceptions.py +0 -20
- pymax/models.py +0 -8
- pymax/static.py +0 -86
- pymax/types.py +0 -327
- {maxapi_python-0.1.0.dist-info → maxapi_python-0.1.1.dist-info}/licenses/LICENSE +0 -0
pymax/exceptions.py
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
class InvalidPhoneError(Exception):
|
2
|
-
"""
|
3
|
-
Исключение, вызываемое при неверном формате номера телефона.
|
4
|
-
|
5
|
-
Args:
|
6
|
-
phone (str): Некорректный номер телефона.
|
7
|
-
"""
|
8
|
-
|
9
|
-
def __init__(self, phone: str) -> None:
|
10
|
-
super().__init__(f"Invalid phone number format: {phone}")
|
11
|
-
|
12
|
-
|
13
|
-
class WebSocketNotConnectedError(Exception):
|
14
|
-
"""
|
15
|
-
Исключение, вызываемое при попытке обращения к WebSocket,
|
16
|
-
если соединение не установлено.
|
17
|
-
"""
|
18
|
-
|
19
|
-
def __init__(self) -> None:
|
20
|
-
super().__init__("WebSocket is not connected")
|
pymax/models.py
DELETED
pymax/static.py
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
from enum import Enum, IntEnum
|
2
|
-
|
3
|
-
|
4
|
-
class Opcode(IntEnum):
|
5
|
-
PING = 1
|
6
|
-
STATS = 5
|
7
|
-
HANDSHAKE = 6
|
8
|
-
PROFILE = 16
|
9
|
-
REQUEST_CODE = 17
|
10
|
-
SEND_CODE = 18
|
11
|
-
SYNC = 19
|
12
|
-
UNKNOWN_26 = 26
|
13
|
-
SYNC_STICKERS_EMOJIS = 27
|
14
|
-
GET_EMOJIS_BY_ID = 28
|
15
|
-
GET_CONTACTS_INFO = 32
|
16
|
-
GET_LAST_SEEN = 35
|
17
|
-
GET_CHATS_DATA = 48
|
18
|
-
FETCH_HISTORY = 49
|
19
|
-
|
20
|
-
GET_HISTORY = 79
|
21
|
-
|
22
|
-
SEND_MESSAGE = 64
|
23
|
-
EDIT_MESSAGE = 67
|
24
|
-
DELETE_MESSAGE = 68
|
25
|
-
|
26
|
-
NEW_MESSAGE = 128
|
27
|
-
|
28
|
-
|
29
|
-
class ChatType(str, Enum):
|
30
|
-
DIALOG = "DIALOG"
|
31
|
-
CHAT = "CHAT"
|
32
|
-
CHANNEL = "CHANNEL"
|
33
|
-
|
34
|
-
|
35
|
-
class MessageType(str, Enum):
|
36
|
-
TEXT = "TEXT"
|
37
|
-
SYSTEM = "SYSTEM"
|
38
|
-
SERVICE = "SERVICE"
|
39
|
-
|
40
|
-
|
41
|
-
class MessageStatus(str, Enum):
|
42
|
-
SENT = "SENT"
|
43
|
-
DELIVERED = "DELIVERED"
|
44
|
-
READ = "READ"
|
45
|
-
ERROR = "ERROR"
|
46
|
-
|
47
|
-
|
48
|
-
class ElementType(str, Enum):
|
49
|
-
TEXT = "text"
|
50
|
-
MENTION = "mention"
|
51
|
-
LINK = "link"
|
52
|
-
EMOJI = "emoji"
|
53
|
-
|
54
|
-
|
55
|
-
class AuthType(str, Enum):
|
56
|
-
START_AUTH = "START_AUTH"
|
57
|
-
CHECK_CODE = "CHECK_CODE"
|
58
|
-
|
59
|
-
|
60
|
-
class AccessType(str, Enum):
|
61
|
-
PUBLIC = "PUBLIC"
|
62
|
-
PRIVATE = "PRIVATE"
|
63
|
-
SECRET = "SECRET"
|
64
|
-
|
65
|
-
|
66
|
-
class DeviceType(str, Enum):
|
67
|
-
WEB = "WEB"
|
68
|
-
ANDROID = "ANDROID"
|
69
|
-
IOS = "IOS"
|
70
|
-
|
71
|
-
|
72
|
-
class Constants(Enum):
|
73
|
-
PHONE_REGEX = r"^\+?\d{10,15}$"
|
74
|
-
WEBSOCKET_URI = "wss://ws-api.oneme.ru/websocket"
|
75
|
-
DEFAULT_TIMEOUT = 10.0
|
76
|
-
DEFAULT_USER_AGENT = {
|
77
|
-
"deviceType": "WEB",
|
78
|
-
"locale": "ru",
|
79
|
-
"deviceLocale": "ru",
|
80
|
-
"osVersion": "Linux",
|
81
|
-
"deviceName": "Chrome",
|
82
|
-
"headerUserAgent": "Mozilla/5.0 ...",
|
83
|
-
"appVersion": "25.8.5",
|
84
|
-
"screen": "1080x1920 1.0x",
|
85
|
-
"timezone": "Europe/Moscow",
|
86
|
-
}
|
pymax/types.py
DELETED
@@ -1,327 +0,0 @@
|
|
1
|
-
from typing import Any
|
2
|
-
|
3
|
-
from .static import AccessType, ChatType, ElementType, MessageStatus, MessageType
|
4
|
-
|
5
|
-
|
6
|
-
class Element:
|
7
|
-
def __init__(self, type: ElementType | str, length: int, from_: int | None = None) -> None:
|
8
|
-
self.type = type
|
9
|
-
self.length = length
|
10
|
-
self.from_ = from_
|
11
|
-
|
12
|
-
@classmethod
|
13
|
-
def from_dict(cls, data: dict[Any, Any]) -> "Element":
|
14
|
-
return cls(type=data["type"], length=data["length"], from_=data.get("from"))
|
15
|
-
|
16
|
-
def __repr__(self) -> str:
|
17
|
-
return f"Element(type={self.type!r}, length={self.length!r}, from_={self.from_!r})"
|
18
|
-
|
19
|
-
def __str__(self) -> str:
|
20
|
-
return f"{self.type}({self.length})"
|
21
|
-
|
22
|
-
|
23
|
-
class Message:
|
24
|
-
def __init__(
|
25
|
-
self,
|
26
|
-
sender: int | None,
|
27
|
-
elements: list[Element] | None,
|
28
|
-
reaction_info: dict[str, Any] | None,
|
29
|
-
options: int | None,
|
30
|
-
id: int,
|
31
|
-
time: int,
|
32
|
-
text: str,
|
33
|
-
status: MessageStatus | str | None,
|
34
|
-
type: MessageType | str,
|
35
|
-
attaches: list[Any],
|
36
|
-
) -> None:
|
37
|
-
self.sender = sender
|
38
|
-
self.elements = elements
|
39
|
-
self.options = options
|
40
|
-
self.id = id
|
41
|
-
self.time = time
|
42
|
-
self.text = text
|
43
|
-
self.type = type
|
44
|
-
self.attaches = attaches
|
45
|
-
self.status = status
|
46
|
-
self.reactionInfo = reaction_info
|
47
|
-
|
48
|
-
@classmethod
|
49
|
-
def from_dict(cls, data: dict[Any, Any]) -> "Message":
|
50
|
-
return cls(
|
51
|
-
sender=data.get("sender"),
|
52
|
-
elements=[Element.from_dict(e) for e in data.get("elements", [])],
|
53
|
-
options=data.get("options"),
|
54
|
-
id=data["id"],
|
55
|
-
time=data["time"],
|
56
|
-
text=data["text"],
|
57
|
-
type=data["type"],
|
58
|
-
attaches=data.get("attaches", []),
|
59
|
-
status=data.get("status"),
|
60
|
-
reaction_info=data.get("reactionInfo"),
|
61
|
-
)
|
62
|
-
|
63
|
-
def __repr__(self) -> str:
|
64
|
-
return (
|
65
|
-
f"Message(id={self.id!r}, sender={self.sender!r}, text={self.text!r}, "
|
66
|
-
f"type={self.type!r}, status={self.status!r}, elements={self.elements!r})"
|
67
|
-
)
|
68
|
-
|
69
|
-
def __str__(self) -> str:
|
70
|
-
return f"Message {self.id} from {self.sender}: {self.text}"
|
71
|
-
|
72
|
-
|
73
|
-
class Dialog:
|
74
|
-
def __init__(
|
75
|
-
self,
|
76
|
-
cid: int | None,
|
77
|
-
owner: int,
|
78
|
-
has_bots: bool | None,
|
79
|
-
join_time: int,
|
80
|
-
created: int,
|
81
|
-
last_message: Message | None,
|
82
|
-
type: ChatType | str,
|
83
|
-
last_fire_delayed_error_time: int,
|
84
|
-
last_delayed_update_time: int,
|
85
|
-
prev_message_id: str | None,
|
86
|
-
options: dict[str, bool],
|
87
|
-
modified: int,
|
88
|
-
last_event_time: int,
|
89
|
-
id: int,
|
90
|
-
status: str,
|
91
|
-
participants: dict[str, int],
|
92
|
-
) -> None:
|
93
|
-
self.cid = cid
|
94
|
-
self.owner = owner
|
95
|
-
self.has_bots = has_bots
|
96
|
-
self.join_time = join_time
|
97
|
-
self.created = created
|
98
|
-
self.last_message = last_message
|
99
|
-
self.type = type
|
100
|
-
self.last_fire_delayed_error_time = last_fire_delayed_error_time
|
101
|
-
self.last_delayed_update_time = last_delayed_update_time
|
102
|
-
self.prev_message_id = prev_message_id
|
103
|
-
self.options = options
|
104
|
-
self.modified = modified
|
105
|
-
self.last_event_time = last_event_time
|
106
|
-
self.id = id
|
107
|
-
self.status = status
|
108
|
-
self.participants = participants
|
109
|
-
|
110
|
-
@classmethod
|
111
|
-
def from_dict(cls, data: dict[Any, Any]) -> "Dialog":
|
112
|
-
return cls(
|
113
|
-
cid=data.get("cid"),
|
114
|
-
owner=data["owner"],
|
115
|
-
has_bots=data.get("hasBots"),
|
116
|
-
join_time=data["joinTime"],
|
117
|
-
created=data["created"],
|
118
|
-
last_message=Message.from_dict(data["lastMessage"])
|
119
|
-
if data.get("lastMessage")
|
120
|
-
else None,
|
121
|
-
type=ChatType(data["type"]),
|
122
|
-
last_fire_delayed_error_time=data["lastFireDelayedErrorTime"],
|
123
|
-
last_delayed_update_time=data["lastDelayedUpdateTime"],
|
124
|
-
prev_message_id=data.get("prevMessageId"),
|
125
|
-
options=data.get("options", {}),
|
126
|
-
modified=data["modified"],
|
127
|
-
last_event_time=data["lastEventTime"],
|
128
|
-
id=data["id"],
|
129
|
-
status=data["status"],
|
130
|
-
participants=data["participants"],
|
131
|
-
)
|
132
|
-
|
133
|
-
def __repr__(self) -> str:
|
134
|
-
return f"Dialog(id={self.id!r}, owner={self.owner!r}, type={self.type!r}, last_message={self.last_message!r})"
|
135
|
-
|
136
|
-
def __str__(self) -> str:
|
137
|
-
return f"Dialog {self.id} ({self.type})"
|
138
|
-
|
139
|
-
|
140
|
-
class Chat:
|
141
|
-
def __init__(
|
142
|
-
self,
|
143
|
-
participants_count: int,
|
144
|
-
access: AccessType | str,
|
145
|
-
invited_by: int | None,
|
146
|
-
link: str | None,
|
147
|
-
chat_type: ChatType | str,
|
148
|
-
title: str | None,
|
149
|
-
last_fire_delayed_error_time: int,
|
150
|
-
last_delayed_update_time: int,
|
151
|
-
options: dict[str, bool],
|
152
|
-
base_raw_icon_url: str | None,
|
153
|
-
base_icon_url: str | None,
|
154
|
-
description: str | None,
|
155
|
-
modified: int,
|
156
|
-
id_: int,
|
157
|
-
admin_participants: dict[int, dict[Any, Any]],
|
158
|
-
participants: dict[int, int],
|
159
|
-
owner: int,
|
160
|
-
join_time: int,
|
161
|
-
created: int,
|
162
|
-
last_message: Message | None,
|
163
|
-
prev_message_id: str | None,
|
164
|
-
last_event_time: int,
|
165
|
-
messages_count: int,
|
166
|
-
admins: list[int],
|
167
|
-
restrictions: int | None,
|
168
|
-
status: str,
|
169
|
-
cid: int,
|
170
|
-
) -> None:
|
171
|
-
self.participants_count = participants_count
|
172
|
-
self.access = access
|
173
|
-
self.invited_by = invited_by
|
174
|
-
self.link = link
|
175
|
-
self.type = chat_type
|
176
|
-
self.title = title
|
177
|
-
self.last_fire_delayed_error_time = last_fire_delayed_error_time
|
178
|
-
self.last_delayed_update_time = last_delayed_update_time
|
179
|
-
self.options = options
|
180
|
-
self.base_raw_icon_url = base_raw_icon_url
|
181
|
-
self.base_icon_url = base_icon_url
|
182
|
-
self.description = description
|
183
|
-
self.modified = modified
|
184
|
-
self.id = id_
|
185
|
-
self.admin_participants = admin_participants
|
186
|
-
self.participants = participants
|
187
|
-
self.owner = owner
|
188
|
-
self.join_time = join_time
|
189
|
-
self.created = created
|
190
|
-
self.last_message = last_message
|
191
|
-
self.prev_message_id = prev_message_id
|
192
|
-
self.last_event_time = last_event_time
|
193
|
-
self.messages_count = messages_count
|
194
|
-
self.admins = admins
|
195
|
-
self.restrictions = restrictions
|
196
|
-
self.status = status
|
197
|
-
self.cid = cid
|
198
|
-
|
199
|
-
@classmethod
|
200
|
-
def from_dict(cls, data: dict[Any, Any]) -> "Chat":
|
201
|
-
raw_admins = data.get("adminParticipants", {}) or {}
|
202
|
-
admin_participants: dict[int, dict[Any, Any]] = {int(k): v for k, v in raw_admins.items()}
|
203
|
-
raw_participants = data.get("participants", {}) or {}
|
204
|
-
participants: dict[int, int] = {int(k): v for k, v in raw_participants.items()}
|
205
|
-
last_msg = Message.from_dict(data["lastMessage"]) if data.get("lastMessage") else None
|
206
|
-
return cls(
|
207
|
-
participants_count=data.get("participantsCount", 0),
|
208
|
-
access=AccessType(data.get("access", AccessType.PUBLIC.value)),
|
209
|
-
invited_by=data.get("invitedBy"),
|
210
|
-
link=data.get("link"),
|
211
|
-
base_raw_icon_url=data.get("baseRawIconUrl"),
|
212
|
-
base_icon_url=data.get("baseIconUrl"),
|
213
|
-
description=data.get("description"),
|
214
|
-
chat_type=ChatType(data.get("type", ChatType.CHAT.value)),
|
215
|
-
title=data.get("title"),
|
216
|
-
last_fire_delayed_error_time=data.get("lastFireDelayedErrorTime", 0),
|
217
|
-
last_delayed_update_time=data.get("lastDelayedUpdateTime", 0),
|
218
|
-
options=data.get("options", {}),
|
219
|
-
modified=data.get("modified", 0),
|
220
|
-
id_=data.get("id", 0),
|
221
|
-
admin_participants=admin_participants,
|
222
|
-
participants=participants,
|
223
|
-
owner=data.get("owner", 0),
|
224
|
-
join_time=data.get("joinTime", 0),
|
225
|
-
created=data.get("created", 0),
|
226
|
-
last_message=last_msg,
|
227
|
-
prev_message_id=data.get("prevMessageId"),
|
228
|
-
last_event_time=data.get("lastEventTime", 0),
|
229
|
-
messages_count=data.get("messagesCount", 0),
|
230
|
-
admins=data.get("admins", []),
|
231
|
-
restrictions=data.get("restrictions"),
|
232
|
-
status=data.get("status", ""),
|
233
|
-
cid=data.get("cid", 0),
|
234
|
-
)
|
235
|
-
|
236
|
-
def __repr__(self) -> str:
|
237
|
-
return f"Chat(id={self.id!r}, title={self.title!r}, type={self.type!r})"
|
238
|
-
|
239
|
-
def __str__(self) -> str:
|
240
|
-
return f"{self.title} ({self.type})"
|
241
|
-
|
242
|
-
|
243
|
-
class Channel(Chat):
|
244
|
-
def __repr__(self) -> str:
|
245
|
-
return f"Channel(id={self.id!r}, title={self.title!r})"
|
246
|
-
|
247
|
-
def __str__(self) -> str:
|
248
|
-
return f"Channel: {self.title}"
|
249
|
-
|
250
|
-
|
251
|
-
class Names:
|
252
|
-
def __init__(self, name: str, first_name: str, last_name: str | None, type: str) -> None:
|
253
|
-
self.name = name
|
254
|
-
self.first_name = first_name
|
255
|
-
self.last_name = last_name
|
256
|
-
self.type = type
|
257
|
-
|
258
|
-
@classmethod
|
259
|
-
def from_dict(cls, data: dict[str, Any]) -> "Names":
|
260
|
-
return cls(
|
261
|
-
name=data["name"],
|
262
|
-
first_name=data["firstName"],
|
263
|
-
last_name=data.get("lastName"),
|
264
|
-
type=data["type"],
|
265
|
-
)
|
266
|
-
|
267
|
-
def __repr__(self) -> str:
|
268
|
-
return f"Names(name={self.name!r}, first_name={self.first_name!r}, last_name={self.last_name!r}, type={self.type!r})"
|
269
|
-
|
270
|
-
def __str__(self) -> str:
|
271
|
-
return self.name
|
272
|
-
|
273
|
-
|
274
|
-
class User:
|
275
|
-
def __init__(
|
276
|
-
self,
|
277
|
-
account_status: int,
|
278
|
-
update_time: int,
|
279
|
-
id: int,
|
280
|
-
names: list[Names],
|
281
|
-
options: list[str] | None = None,
|
282
|
-
base_url: str | None = None,
|
283
|
-
base_raw_url: str | None = None,
|
284
|
-
photo_id: int | None = None,
|
285
|
-
description: str | None = None,
|
286
|
-
gender: int | None = None,
|
287
|
-
link: str | None = None,
|
288
|
-
web_app: str | None = None,
|
289
|
-
menu_button: dict[str, Any] | None = None,
|
290
|
-
) -> None:
|
291
|
-
self.account_status = account_status
|
292
|
-
self.update_time = update_time
|
293
|
-
self.id = id
|
294
|
-
self.names = names
|
295
|
-
self.options = options or []
|
296
|
-
self.base_url = base_url
|
297
|
-
self.base_raw_url = base_raw_url
|
298
|
-
self.photo_id = photo_id
|
299
|
-
self.description = description
|
300
|
-
self.gender = gender
|
301
|
-
self.link = link
|
302
|
-
self.web_app = web_app
|
303
|
-
self.menu_button = menu_button
|
304
|
-
|
305
|
-
@classmethod
|
306
|
-
def from_dict(cls, data: dict[str, Any]) -> "User":
|
307
|
-
return cls(
|
308
|
-
account_status=data["accountStatus"],
|
309
|
-
update_time=data["updateTime"],
|
310
|
-
id=data["id"],
|
311
|
-
names=[Names.from_dict(n) for n in data.get("names", [])],
|
312
|
-
options=data.get("options"),
|
313
|
-
base_url=data.get("baseUrl"),
|
314
|
-
base_raw_url=data.get("baseRawUrl"),
|
315
|
-
photo_id=data.get("photoId"),
|
316
|
-
description=data.get("description"),
|
317
|
-
gender=data.get("gender"),
|
318
|
-
link=data.get("link"),
|
319
|
-
web_app=data.get("webApp"),
|
320
|
-
menu_button=data.get("menuButton"),
|
321
|
-
)
|
322
|
-
|
323
|
-
def __repr__(self) -> str:
|
324
|
-
return f"User(id={self.id!r}, names={self.names!r}, status={self.account_status!r})"
|
325
|
-
|
326
|
-
def __str__(self) -> str:
|
327
|
-
return f"User {self.id}: {', '.join(str(n) for n in self.names)}"
|
File without changes
|