maxapi-python 0.1.2__py3-none-any.whl → 1.0.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.2.dist-info → maxapi_python-1.0.1.dist-info}/METADATA +3 -1
- maxapi_python-1.0.1.dist-info/RECORD +27 -0
- {maxapi_python-0.1.2.dist-info → maxapi_python-1.0.1.dist-info}/licenses/LICENSE +21 -21
- pymax/__init__.py +55 -55
- pymax/core.py +170 -156
- pymax/crud.py +99 -99
- pymax/exceptions.py +29 -20
- pymax/files.py +86 -85
- pymax/filters.py +38 -38
- pymax/interfaces.py +73 -67
- pymax/mixins/__init__.py +20 -18
- pymax/mixins/auth.py +81 -81
- pymax/mixins/channel.py +25 -25
- pymax/mixins/group.py +220 -220
- pymax/mixins/handler.py +60 -60
- pymax/mixins/message.py +293 -293
- pymax/mixins/self.py +38 -38
- pymax/mixins/telemetry.py +114 -0
- pymax/mixins/user.py +82 -82
- pymax/mixins/websocket.py +262 -242
- pymax/models.py +8 -8
- pymax/navigation.py +185 -0
- pymax/payloads.py +195 -175
- pymax/static.py +210 -210
- pymax/types.py +434 -432
- pymax/utils.py +38 -38
- maxapi_python-0.1.2.dist-info/RECORD +0 -25
- {maxapi_python-0.1.2.dist-info → maxapi_python-1.0.1.dist-info}/WHEEL +0 -0
pymax/types.py
CHANGED
@@ -1,432 +1,434 @@
|
|
1
|
-
from typing import Any
|
2
|
-
|
3
|
-
from
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
self
|
18
|
-
|
19
|
-
self.
|
20
|
-
self.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
self.
|
53
|
-
self.
|
54
|
-
self.
|
55
|
-
self.
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
self
|
82
|
-
|
83
|
-
self.
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
self.
|
117
|
-
self.
|
118
|
-
self.
|
119
|
-
self.
|
120
|
-
self.
|
121
|
-
self.
|
122
|
-
self.
|
123
|
-
self.
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
self.
|
175
|
-
self.
|
176
|
-
self.
|
177
|
-
self.
|
178
|
-
self.
|
179
|
-
self.
|
180
|
-
self.
|
181
|
-
self.
|
182
|
-
self.
|
183
|
-
self.
|
184
|
-
self.
|
185
|
-
self.
|
186
|
-
self.
|
187
|
-
self.
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
self.
|
255
|
-
self.
|
256
|
-
self.
|
257
|
-
self.
|
258
|
-
self.
|
259
|
-
self.
|
260
|
-
self.
|
261
|
-
self.
|
262
|
-
self.
|
263
|
-
self.
|
264
|
-
self.
|
265
|
-
self.
|
266
|
-
self.
|
267
|
-
self.
|
268
|
-
self.
|
269
|
-
self.
|
270
|
-
self.
|
271
|
-
self.
|
272
|
-
self.
|
273
|
-
self.
|
274
|
-
self.
|
275
|
-
self.
|
276
|
-
self.
|
277
|
-
self.
|
278
|
-
self.
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
self.
|
360
|
-
self.
|
361
|
-
self.
|
362
|
-
self.
|
363
|
-
self.
|
364
|
-
self.
|
365
|
-
self.
|
366
|
-
self.
|
367
|
-
self.
|
368
|
-
self.
|
369
|
-
self.
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
self.
|
410
|
-
self.
|
411
|
-
self.
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
1
|
+
from typing import Any
|
2
|
+
|
3
|
+
from typing_extensions import override
|
4
|
+
|
5
|
+
from .static import (
|
6
|
+
AccessType,
|
7
|
+
AttachType,
|
8
|
+
ChatType,
|
9
|
+
ElementType,
|
10
|
+
MessageStatus,
|
11
|
+
MessageType,
|
12
|
+
)
|
13
|
+
|
14
|
+
|
15
|
+
class Names:
|
16
|
+
def __init__(
|
17
|
+
self, name: str, first_name: str, last_name: str | None, type: str
|
18
|
+
) -> None:
|
19
|
+
self.name = name
|
20
|
+
self.first_name = first_name
|
21
|
+
self.last_name = last_name
|
22
|
+
self.type = type
|
23
|
+
|
24
|
+
@classmethod
|
25
|
+
def from_dict(cls, data: dict[str, Any]) -> "Names":
|
26
|
+
return cls(
|
27
|
+
name=data["name"],
|
28
|
+
first_name=data["firstName"],
|
29
|
+
last_name=data.get("lastName"),
|
30
|
+
type=data["type"],
|
31
|
+
)
|
32
|
+
|
33
|
+
@override
|
34
|
+
def __repr__(self) -> str:
|
35
|
+
return f"Names(name={self.name!r}, first_name={self.first_name!r}, last_name={self.last_name!r}, type={self.type!r})"
|
36
|
+
|
37
|
+
@override
|
38
|
+
def __str__(self) -> str:
|
39
|
+
return self.name
|
40
|
+
|
41
|
+
|
42
|
+
class Me:
|
43
|
+
def __init__(
|
44
|
+
self,
|
45
|
+
id: int,
|
46
|
+
account_status: int,
|
47
|
+
phone: str,
|
48
|
+
names: list[Names],
|
49
|
+
update_time: int,
|
50
|
+
options: list[str] | None = None,
|
51
|
+
) -> None:
|
52
|
+
self.id = id
|
53
|
+
self.account_status = account_status
|
54
|
+
self.phone = phone
|
55
|
+
self.update_time = update_time
|
56
|
+
self.options = options
|
57
|
+
self.names = names
|
58
|
+
|
59
|
+
@classmethod
|
60
|
+
def from_dict(cls, data: dict[str, Any]) -> "Me":
|
61
|
+
return cls(
|
62
|
+
id=data["id"],
|
63
|
+
account_status=data["accountStatus"],
|
64
|
+
phone=data["phone"],
|
65
|
+
names=[Names.from_dict(n) for n in data["names"]],
|
66
|
+
update_time=data["updateTime"],
|
67
|
+
options=data.get("options"),
|
68
|
+
)
|
69
|
+
|
70
|
+
@override
|
71
|
+
def __repr__(self) -> str:
|
72
|
+
return f"Me(id={self.id!r}, account_status={self.account_status!r}, phone={self.phone!r}, names={self.names!r}, update_time={self.update_time!r}, options={self.options!r})"
|
73
|
+
|
74
|
+
@override
|
75
|
+
def __str__(self) -> str:
|
76
|
+
return f"Me {self.id}: {', '.join(str(n) for n in self.names)}"
|
77
|
+
|
78
|
+
|
79
|
+
class Element:
|
80
|
+
def __init__(
|
81
|
+
self, type: ElementType | str, length: int, from_: int | None = None
|
82
|
+
) -> None:
|
83
|
+
self.type = type
|
84
|
+
self.length = length
|
85
|
+
self.from_ = from_
|
86
|
+
|
87
|
+
@classmethod
|
88
|
+
def from_dict(cls, data: dict[Any, Any]) -> "Element":
|
89
|
+
return cls(type=data["type"], length=data["length"], from_=data.get("from"))
|
90
|
+
|
91
|
+
@override
|
92
|
+
def __repr__(self) -> str:
|
93
|
+
return (
|
94
|
+
f"Element(type={self.type!r}, length={self.length!r}, from_={self.from_!r})"
|
95
|
+
)
|
96
|
+
|
97
|
+
@override
|
98
|
+
def __str__(self) -> str:
|
99
|
+
return f"{self.type}({self.length})"
|
100
|
+
|
101
|
+
|
102
|
+
class Message:
|
103
|
+
def __init__(
|
104
|
+
self,
|
105
|
+
sender: int | None,
|
106
|
+
elements: list[Element] | None,
|
107
|
+
reaction_info: dict[str, Any] | None,
|
108
|
+
options: int | None,
|
109
|
+
id: int,
|
110
|
+
time: int,
|
111
|
+
text: str,
|
112
|
+
status: MessageStatus | str | None,
|
113
|
+
type: MessageType | str,
|
114
|
+
attaches: list[Any],
|
115
|
+
) -> None:
|
116
|
+
self.sender = sender
|
117
|
+
self.elements = elements
|
118
|
+
self.options = options
|
119
|
+
self.id = id
|
120
|
+
self.time = time
|
121
|
+
self.text = text
|
122
|
+
self.type = type
|
123
|
+
self.attaches = attaches
|
124
|
+
self.status = status
|
125
|
+
self.reactionInfo = reaction_info
|
126
|
+
|
127
|
+
@classmethod
|
128
|
+
def from_dict(cls, data: dict[Any, Any]) -> "Message":
|
129
|
+
return cls(
|
130
|
+
sender=data.get("sender"),
|
131
|
+
elements=[Element.from_dict(e) for e in data.get("elements", [])],
|
132
|
+
options=data.get("options"),
|
133
|
+
id=data["id"],
|
134
|
+
time=data["time"],
|
135
|
+
text=data["text"],
|
136
|
+
type=data["type"],
|
137
|
+
attaches=data.get("attaches", []),
|
138
|
+
status=data.get("status"),
|
139
|
+
reaction_info=data.get("reactionInfo"),
|
140
|
+
)
|
141
|
+
|
142
|
+
@override
|
143
|
+
def __repr__(self) -> str:
|
144
|
+
return (
|
145
|
+
f"Message(id={self.id!r}, sender={self.sender!r}, text={self.text!r}, "
|
146
|
+
f"type={self.type!r}, status={self.status!r}, elements={self.elements!r})"
|
147
|
+
)
|
148
|
+
|
149
|
+
@override
|
150
|
+
def __str__(self) -> str:
|
151
|
+
return f"Message {self.id} from {self.sender}: {self.text}"
|
152
|
+
|
153
|
+
|
154
|
+
class Dialog:
|
155
|
+
def __init__(
|
156
|
+
self,
|
157
|
+
cid: int | None,
|
158
|
+
owner: int,
|
159
|
+
has_bots: bool | None,
|
160
|
+
join_time: int,
|
161
|
+
created: int,
|
162
|
+
last_message: Message | None,
|
163
|
+
type: ChatType | str,
|
164
|
+
last_fire_delayed_error_time: int,
|
165
|
+
last_delayed_update_time: int,
|
166
|
+
prev_message_id: str | None,
|
167
|
+
options: dict[str, bool],
|
168
|
+
modified: int,
|
169
|
+
last_event_time: int,
|
170
|
+
id: int,
|
171
|
+
status: str,
|
172
|
+
participants: dict[str, int],
|
173
|
+
) -> None:
|
174
|
+
self.cid = cid
|
175
|
+
self.owner = owner
|
176
|
+
self.has_bots = has_bots
|
177
|
+
self.join_time = join_time
|
178
|
+
self.created = created
|
179
|
+
self.last_message = last_message
|
180
|
+
self.type = type
|
181
|
+
self.last_fire_delayed_error_time = last_fire_delayed_error_time
|
182
|
+
self.last_delayed_update_time = last_delayed_update_time
|
183
|
+
self.prev_message_id = prev_message_id
|
184
|
+
self.options = options
|
185
|
+
self.modified = modified
|
186
|
+
self.last_event_time = last_event_time
|
187
|
+
self.id = id
|
188
|
+
self.status = status
|
189
|
+
self.participants = participants
|
190
|
+
|
191
|
+
@classmethod
|
192
|
+
def from_dict(cls, data: dict[Any, Any]) -> "Dialog":
|
193
|
+
return cls(
|
194
|
+
cid=data.get("cid"),
|
195
|
+
owner=data["owner"],
|
196
|
+
has_bots=data.get("hasBots"),
|
197
|
+
join_time=data["joinTime"],
|
198
|
+
created=data["created"],
|
199
|
+
last_message=Message.from_dict(data["lastMessage"])
|
200
|
+
if data.get("lastMessage")
|
201
|
+
else None,
|
202
|
+
type=ChatType(data["type"]),
|
203
|
+
last_fire_delayed_error_time=data["lastFireDelayedErrorTime"],
|
204
|
+
last_delayed_update_time=data["lastDelayedUpdateTime"],
|
205
|
+
prev_message_id=data.get("prevMessageId"),
|
206
|
+
options=data.get("options", {}),
|
207
|
+
modified=data["modified"],
|
208
|
+
last_event_time=data["lastEventTime"],
|
209
|
+
id=data["id"],
|
210
|
+
status=data["status"],
|
211
|
+
participants=data["participants"],
|
212
|
+
)
|
213
|
+
|
214
|
+
@override
|
215
|
+
def __repr__(self) -> str:
|
216
|
+
return f"Dialog(id={self.id!r}, owner={self.owner!r}, type={self.type!r}, last_message={self.last_message!r})"
|
217
|
+
|
218
|
+
@override
|
219
|
+
def __str__(self) -> str:
|
220
|
+
return f"Dialog {self.id} ({self.type})"
|
221
|
+
|
222
|
+
|
223
|
+
class Chat:
|
224
|
+
def __init__(
|
225
|
+
self,
|
226
|
+
participants_count: int,
|
227
|
+
access: AccessType | str,
|
228
|
+
invited_by: int | None,
|
229
|
+
link: str | None,
|
230
|
+
chat_type: ChatType | str,
|
231
|
+
title: str | None,
|
232
|
+
last_fire_delayed_error_time: int,
|
233
|
+
last_delayed_update_time: int,
|
234
|
+
options: dict[str, bool],
|
235
|
+
base_raw_icon_url: str | None,
|
236
|
+
base_icon_url: str | None,
|
237
|
+
description: str | None,
|
238
|
+
modified: int,
|
239
|
+
id_: int,
|
240
|
+
admin_participants: dict[int, dict[Any, Any]],
|
241
|
+
participants: dict[int, int],
|
242
|
+
owner: int,
|
243
|
+
join_time: int,
|
244
|
+
created: int,
|
245
|
+
last_message: Message | None,
|
246
|
+
prev_message_id: str | None,
|
247
|
+
last_event_time: int,
|
248
|
+
messages_count: int,
|
249
|
+
admins: list[int],
|
250
|
+
restrictions: int | None,
|
251
|
+
status: str,
|
252
|
+
cid: int,
|
253
|
+
) -> None:
|
254
|
+
self.participants_count = participants_count
|
255
|
+
self.access = access
|
256
|
+
self.invited_by = invited_by
|
257
|
+
self.link = link
|
258
|
+
self.type = chat_type
|
259
|
+
self.title = title
|
260
|
+
self.last_fire_delayed_error_time = last_fire_delayed_error_time
|
261
|
+
self.last_delayed_update_time = last_delayed_update_time
|
262
|
+
self.options = options
|
263
|
+
self.base_raw_icon_url = base_raw_icon_url
|
264
|
+
self.base_icon_url = base_icon_url
|
265
|
+
self.description = description
|
266
|
+
self.modified = modified
|
267
|
+
self.id = id_
|
268
|
+
self.admin_participants = admin_participants
|
269
|
+
self.participants = participants
|
270
|
+
self.owner = owner
|
271
|
+
self.join_time = join_time
|
272
|
+
self.created = created
|
273
|
+
self.last_message = last_message
|
274
|
+
self.prev_message_id = prev_message_id
|
275
|
+
self.last_event_time = last_event_time
|
276
|
+
self.messages_count = messages_count
|
277
|
+
self.admins = admins
|
278
|
+
self.restrictions = restrictions
|
279
|
+
self.status = status
|
280
|
+
self.cid = cid
|
281
|
+
|
282
|
+
@classmethod
|
283
|
+
def from_dict(cls, data: dict[Any, Any]) -> "Chat":
|
284
|
+
raw_admins = data.get("adminParticipants", {}) or {}
|
285
|
+
admin_participants: dict[int, dict[Any, Any]] = {
|
286
|
+
int(k): v for k, v in raw_admins.items()
|
287
|
+
}
|
288
|
+
raw_participants = data.get("participants", {}) or {}
|
289
|
+
participants: dict[int, int] = {int(k): v for k, v in raw_participants.items()}
|
290
|
+
last_msg = (
|
291
|
+
Message.from_dict(data["lastMessage"]) if data.get("lastMessage") else None
|
292
|
+
)
|
293
|
+
return cls(
|
294
|
+
participants_count=data.get("participantsCount", 0),
|
295
|
+
access=AccessType(data.get("access", AccessType.PUBLIC.value)),
|
296
|
+
invited_by=data.get("invitedBy"),
|
297
|
+
link=data.get("link"),
|
298
|
+
base_raw_icon_url=data.get("baseRawIconUrl"),
|
299
|
+
base_icon_url=data.get("baseIconUrl"),
|
300
|
+
description=data.get("description"),
|
301
|
+
chat_type=ChatType(data.get("type", ChatType.CHAT.value)),
|
302
|
+
title=data.get("title"),
|
303
|
+
last_fire_delayed_error_time=data.get("lastFireDelayedErrorTime", 0),
|
304
|
+
last_delayed_update_time=data.get("lastDelayedUpdateTime", 0),
|
305
|
+
options=data.get("options", {}),
|
306
|
+
modified=data.get("modified", 0),
|
307
|
+
id_=data.get("id", 0),
|
308
|
+
admin_participants=admin_participants,
|
309
|
+
participants=participants,
|
310
|
+
owner=data.get("owner", 0),
|
311
|
+
join_time=data.get("joinTime", 0),
|
312
|
+
created=data.get("created", 0),
|
313
|
+
last_message=last_msg,
|
314
|
+
prev_message_id=data.get("prevMessageId"),
|
315
|
+
last_event_time=data.get("lastEventTime", 0),
|
316
|
+
messages_count=data.get("messagesCount", 0),
|
317
|
+
admins=data.get("admins", []),
|
318
|
+
restrictions=data.get("restrictions"),
|
319
|
+
status=data.get("status", ""),
|
320
|
+
cid=data.get("cid", 0),
|
321
|
+
)
|
322
|
+
|
323
|
+
@override
|
324
|
+
def __repr__(self) -> str:
|
325
|
+
return f"Chat(id={self.id!r}, title={self.title!r}, type={self.type!r})"
|
326
|
+
|
327
|
+
@override
|
328
|
+
def __str__(self) -> str:
|
329
|
+
return f"{self.title} ({self.type})"
|
330
|
+
|
331
|
+
|
332
|
+
class Channel(Chat):
|
333
|
+
@override
|
334
|
+
def __repr__(self) -> str:
|
335
|
+
return f"Channel(id={self.id!r}, title={self.title!r})"
|
336
|
+
|
337
|
+
@override
|
338
|
+
def __str__(self) -> str:
|
339
|
+
return f"Channel: {self.title}"
|
340
|
+
|
341
|
+
|
342
|
+
class User:
|
343
|
+
def __init__(
|
344
|
+
self,
|
345
|
+
account_status: int,
|
346
|
+
update_time: int,
|
347
|
+
id: int,
|
348
|
+
names: list[Names],
|
349
|
+
options: list[str] | None = None,
|
350
|
+
base_url: str | None = None,
|
351
|
+
base_raw_url: str | None = None,
|
352
|
+
photo_id: int | None = None,
|
353
|
+
description: str | None = None,
|
354
|
+
gender: int | None = None,
|
355
|
+
link: str | None = None,
|
356
|
+
web_app: str | None = None,
|
357
|
+
menu_button: dict[str, Any] | None = None,
|
358
|
+
) -> None:
|
359
|
+
self.account_status = account_status
|
360
|
+
self.update_time = update_time
|
361
|
+
self.id = id
|
362
|
+
self.names = names
|
363
|
+
self.options = options or []
|
364
|
+
self.base_url = base_url
|
365
|
+
self.base_raw_url = base_raw_url
|
366
|
+
self.photo_id = photo_id
|
367
|
+
self.description = description
|
368
|
+
self.gender = gender
|
369
|
+
self.link = link
|
370
|
+
self.web_app = web_app
|
371
|
+
self.menu_button = menu_button
|
372
|
+
|
373
|
+
@classmethod
|
374
|
+
def from_dict(cls, data: dict[str, Any]) -> "User":
|
375
|
+
return cls(
|
376
|
+
account_status=data["accountStatus"],
|
377
|
+
update_time=data["updateTime"],
|
378
|
+
id=data["id"],
|
379
|
+
names=[Names.from_dict(n) for n in data.get("names", [])],
|
380
|
+
options=data.get("options"),
|
381
|
+
base_url=data.get("baseUrl"),
|
382
|
+
base_raw_url=data.get("baseRawUrl"),
|
383
|
+
photo_id=data.get("photoId"),
|
384
|
+
description=data.get("description"),
|
385
|
+
gender=data.get("gender"),
|
386
|
+
link=data.get("link"),
|
387
|
+
web_app=data.get("webApp"),
|
388
|
+
menu_button=data.get("menuButton"),
|
389
|
+
)
|
390
|
+
|
391
|
+
@override
|
392
|
+
def __repr__(self) -> str:
|
393
|
+
return f"User(id={self.id!r}, names={self.names!r}, status={self.account_status!r})"
|
394
|
+
|
395
|
+
@override
|
396
|
+
def __str__(self) -> str:
|
397
|
+
return f"User {self.id}: {', '.join(str(n) for n in self.names)}"
|
398
|
+
|
399
|
+
|
400
|
+
class Attach:
|
401
|
+
def __init__(
|
402
|
+
self,
|
403
|
+
_type: AttachType,
|
404
|
+
video_id: int | None = None,
|
405
|
+
photo_token: str | None = None,
|
406
|
+
file_id: int | None = None,
|
407
|
+
token: str | None = None,
|
408
|
+
) -> None:
|
409
|
+
self.type = _type
|
410
|
+
self.video_id = video_id
|
411
|
+
self.photo_token = photo_token
|
412
|
+
self.file_id = file_id
|
413
|
+
self.token = token
|
414
|
+
|
415
|
+
@classmethod
|
416
|
+
def from_dict(cls, data: dict[str, Any]) -> "Attach":
|
417
|
+
return cls(
|
418
|
+
_type=AttachType(data["type"]),
|
419
|
+
video_id=data.get("videoId"),
|
420
|
+
photo_token=data.get("photoToken"),
|
421
|
+
file_id=data.get("fileId"),
|
422
|
+
token=data.get("token"),
|
423
|
+
)
|
424
|
+
|
425
|
+
@override
|
426
|
+
def __repr__(self) -> str:
|
427
|
+
return (
|
428
|
+
f"Attach(type={self.type!r}, video_id={self.video_id!r}, "
|
429
|
+
f"photo_token={self.photo_token!r}, file_id={self.file_id!r}, token={self.token!r})"
|
430
|
+
)
|
431
|
+
|
432
|
+
@override
|
433
|
+
def __str__(self) -> str:
|
434
|
+
return f"Attach: {self.type}"
|