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