RubigramClient 1.3.9__py3-none-any.whl → 1.4.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.

Potentially problematic release.


This version of RubigramClient might be problematic. Click here for more details.

rubigram/types.py CHANGED
@@ -1,408 +1,237 @@
1
- from dataclasses import dataclass
2
- from typing import Any, Dict, List, Literal, Optional
1
+ from dataclasses import dataclass, fields, is_dataclass
2
+ from typing import Any, Type, Union, TypeVar, Literal, Optional, get_origin, get_args
3
3
  import rubigram
4
4
 
5
5
 
6
+ T = TypeVar("T", bound="Dict")
7
+
8
+ @dataclass
9
+ class Dict:
10
+ def to_dict(self) -> dict[str, Any]:
11
+ data = {}
12
+ for field in fields(self):
13
+ value = getattr(self, field.name)
14
+ if is_dataclass(value):
15
+ data[field.name] = value.to_dict()
16
+ elif isinstance(value, list):
17
+ data[field.name] = [i.to_dict() if is_dataclass(i) else i for i in value]
18
+ else:
19
+ data[field.name] = value
20
+ return data
21
+
22
+ @classmethod
23
+ def from_dict(cls: Type[T], data: dict[str, Any]) -> Optional[T]:
24
+ if data is None:
25
+ return cls()
26
+ init_data = {}
27
+ for field in fields(cls):
28
+ value = data.get(field.name)
29
+ field_type = field.type
30
+ origin = get_origin(field_type)
31
+ if isinstance(value, dict) and isinstance(field_type, type) and issubclass(field_type, Dict):
32
+ init_data[field.name] = field_type.from_dict(value)
33
+ elif origin == list:
34
+ inner_type = get_args(field_type)[0]
35
+ if isinstance(inner_type, type) and issubclass(inner_type, Dict):
36
+ init_data[field.name] = [inner_type.from_dict(v) if isinstance(v, dict) else v for v in (value or [])]
37
+ else:
38
+ init_data[field.name] = value or []
39
+ elif get_origin(field_type) is Union:
40
+ args = get_args(field_type)
41
+ dict_type = next((a for a in args if isinstance(a, type) and issubclass(a, Dict)), None)
42
+ if dict_type and isinstance(value, dict):
43
+ init_data[field.name] = dict_type.from_dict(value)
44
+ else:
45
+ init_data[field.name] = value
46
+ else:
47
+ init_data[field.name] = value
48
+ return cls(**init_data)
49
+
50
+
6
51
  @dataclass
7
- class Location:
52
+ class Location(Dict):
8
53
  longitude: Optional[str] = None
9
54
  latitude: Optional[str] = None
10
-
11
- def _dict(self) -> Dict:
12
- return {
13
- "longitude": self.longitude,
14
- "latitude": self.latitude
15
- }
16
-
17
- @classmethod
18
- def read(cls, data: dict[str, Any]) -> "Location":
19
- return cls(
20
- longitude = data.get("longitude"),
21
- latitude = data.get("latitude"),
22
- )
55
+
56
+
57
+ @dataclass
58
+ class OpenChatData(Dict):
59
+ object_guid: Optional[str] = None
60
+ object_type: Optional[Literal["User", "Bot", "Group", "Channel"]] = None
61
+
62
+
63
+ @dataclass
64
+ class JoinChannelData(Dict):
65
+ username: Optional[str] = None
66
+ ask_join: Optional[bool] = False
67
+
68
+ @dataclass
69
+ class ButtonLink(Dict):
70
+ type: Optional[Literal["joinchannel", "url"]] = None
71
+ link_url: Optional[str] = None
72
+ joinchannel_data: Optional[JoinChannelData] = None
73
+ open_chat_data: Optional[OpenChatData] = None
74
+
23
75
 
24
76
  @dataclass
25
- class ButtonSelectionItem:
77
+ class ButtonSelectionItem(Dict):
26
78
  text: Optional[str] = None
27
79
  image_url: Optional[str] = None
28
80
  type: Optional[Literal["TextOnly", "TextImgThu", "TextImgBig"]] = None
29
-
30
- def _dict(self) -> Dict:
31
- return {
32
- "text": self.text,
33
- "image_url": self.image_url,
34
- "type": self.type
35
- }
81
+
36
82
 
37
83
  @dataclass
38
- class ButtonTextbox:
84
+ class ButtonTextbox(Dict):
39
85
  type_line: Optional[Literal["SingleLine", "MultiLine"]] = None
40
86
  type_keypad: Optional[Literal["String", "Number"]] = None
41
87
  place_holder: Optional[str] = None
42
88
  title: Optional[str] = None
43
89
  default_value: Optional[str] = None
44
-
45
- def _dict(self) -> Dict:
46
- return {
47
- "type_line": self.type_line,
48
- "type_keypad": self.type_keypad,
49
- "place_holder": self.place_holder,
50
- "title": self.title,
51
- "default_value": self.default_value
52
- }
90
+
53
91
 
54
92
  @dataclass
55
- class ButtonLocation:
93
+ class ButtonLocation(Dict):
56
94
  default_pointer_location: Optional[Location] = None
57
95
  default_map_location: Optional[Location] = None
58
96
  type: Optional[Literal["Picker", "View"]] = None
59
97
  title: Optional[str] = None
60
98
  location_image_url: Optional[str] = None
61
-
62
- def _dict(self) -> Dict:
63
- return {
64
- "default_pointer_location": self.default_pointer_location._dict() if self.default_pointer_location else None,
65
- "default_map_location": self.default_map_location._dict() if self.default_map_location else None,
66
- "type": self.type,
67
- "title": self.title,
68
- "location_image_url": self.location_image_url
69
- }
70
-
99
+
100
+
71
101
  @dataclass
72
- class ButtonStringPicker:
73
- items: Optional[List[str]] = None
102
+ class ButtonStringPicker(Dict):
103
+ items: Optional[list[str]] = None
74
104
  default_value: Optional[str] = None
75
105
  title: Optional[str] = None
76
-
77
- def _dict(self) -> Dict:
78
- return {
79
- "items": self.items,
80
- "default_value": self.default_value,
81
- "title": self.title,
82
- }
106
+
83
107
 
84
108
  @dataclass
85
- class ButtonNumberPicker:
109
+ class ButtonNumberPicker(Dict):
86
110
  min_value: Optional[str] = None
87
111
  max_value: Optional[str] = None
88
112
  default_value: Optional[str] = None
89
113
  title: Optional[str] = None
90
-
91
- def _dict(self) -> Dict:
92
- return {
93
- "min_value": self.min_value,
94
- "max_value": self.max_value,
95
- "default_value": self.default_value,
96
- "title": self.title
97
- }
98
-
114
+
115
+
99
116
  @dataclass
100
- class ButtonCalendar:
117
+ class ButtonCalendar(Dict):
101
118
  default_value: Optional[str] = None
102
119
  type: Optional[Literal["DatePersian", "DateGregorian"]] = None
103
120
  min_year: Optional[str] = None
104
121
  max_year: Optional[str] = None
105
122
  title: Optional[str] = None
106
-
107
- def _dict(self) -> Dict:
108
- return {
109
- "default_value": self.default_value,
110
- "type": self.type,
111
- "min_year": self.min_year,
112
- "max_year": self.max_year,
113
- "title": self.title
114
- }
123
+
115
124
 
116
125
  @dataclass
117
- class ButtonSelection:
126
+ class ButtonSelection(Dict):
118
127
  selection_id: Optional[str] = None
119
128
  search_type: Optional[str] = None
120
129
  get_type: Optional[str] = None
121
- items: Optional[ButtonSelectionItem] = None
130
+ items: Optional[list[ButtonSelectionItem]] = None
122
131
  is_multi_selection: Optional[bool] = None
123
132
  columns_count: Optional[str] = None
124
133
  title: Optional[str] = None
125
-
126
- def _dict(self) -> Dict:
127
- return {
128
- "selection_id": self.selection_id,
129
- "search_type": self.search_type,
130
- "get_type": self.get_type,
131
- "items": self.items._dict() if self.items else None,
132
- "is_multi_selection": self.is_multi_selection,
133
- "columns_count": self.columns_count,
134
- "title": self.title
135
- }
136
-
137
-
138
-
134
+
135
+
139
136
  @dataclass
140
- class Button:
137
+ class Button(Dict):
141
138
  id: Optional[str] = None
139
+ button_text: Optional[str] = None
142
140
  type: Literal[
143
141
  "Simple", "Selection", "Calendar", "NumberPicker", "StringPicker", "Location", "Payment",
144
142
  "CameraImage", "CameraVideo", "GalleryImage", "GalleryVideo", "File", "Audio", "RecordAudio",
145
143
  "MyPhoneNumber", "MyLocation", "Textbox", "Link", "AskMyPhoneNumber", "AskLocation", "Barcode"
146
144
  ] = "Simple"
147
- button_text: Optional[str] = None
148
145
  button_selection: Optional[ButtonSelection] = None
149
146
  button_calendar: Optional[ButtonCalendar] = None
150
147
  button_number_picker: Optional[ButtonNumberPicker] = None
151
148
  button_string_picker: Optional[ButtonStringPicker] = None
152
149
  button_location: Optional[ButtonLocation] = None
153
150
  button_textbox: Optional[ButtonTextbox] = None
154
-
155
- def _dict(self) -> Dict:
156
- return {
157
- "id": self.id,
158
- "type": self.type,
159
- "button_text": self.button_text,
160
- "button_selection": self.button_selection._dict() if self.button_selection else None,
161
- "button_calendar": self.button_calendar._dict() if self.button_calendar else None,
162
- "button_number_picker": self.button_number_picker._dict() if self.button_number_picker else None,
163
- "button_string_picker": self.button_string_picker._dict() if self.button_string_picker else None,
164
- "button_location": self.button_location._dict() if self.button_location else None,
165
- "button_textbox": self.button_textbox._dict() if self.button_textbox else None
166
- }
151
+ button_link: Optional[ButtonLink] = None
152
+
167
153
 
168
154
  @dataclass
169
- class KeypadRow:
170
- buttons: List[Button]
171
-
172
- def _dict(self) -> Dict:
173
- return {
174
- "buttons": [button._dict() for button in self.buttons]
175
- }
155
+ class KeypadRow(Dict):
156
+ buttons: list[Button]
157
+
176
158
 
177
159
  @dataclass
178
- class Keypad:
179
- rows: List[KeypadRow]
160
+ class Keypad(Dict):
161
+ rows: list[KeypadRow]
180
162
  resize_keyboard: bool = True
181
163
  on_time_keyboard: bool = False
182
-
183
- def _dict(self) -> Dict:
184
- return {
185
- "rows": [row._dict() for row in self.rows],
186
- "resize_keyboard": self.resize_keyboard,
187
- "one_time_keyboard": self.on_time_keyboard
188
- }
189
164
 
190
- @dataclass
191
- class MessageId:
192
- client: Optional["rubigram.Client"] = None
193
- message_id: Optional[str] = None
194
- file_id: Optional[str] = None
195
-
196
- @classmethod
197
- def read(cls, data: Dict[str, Any]) -> "MessageId":
198
- return cls(
199
- message_id = data.get("message_id"),
200
- file_id = data.get("file_id")
201
- )
202
-
203
165
 
204
166
  @dataclass
205
- class PollStatus:
167
+ class PollStatus(Dict):
206
168
  state: Optional[Literal["Open", "Closed"]] = None
207
169
  selection_index: Optional[int] = None
208
- percent_vote_options: Optional[List[int]] = None
170
+ percent_vote_options: Optional[list[int]] = None
209
171
  total_vote: Optional[int] = None
210
172
  show_total_votes: Optional[bool] = None
211
-
212
- @classmethod
213
- def read(cls, data: Dict[str, Any]) -> "PollStatus":
214
- return cls(
215
- state = data.get("state"),
216
- selection_index = data.get("selection_index"),
217
- percent_vote_options = data.get("percent_vote_options"),
218
- total_vote = data.get("total_vote"),
219
- show_total_votes = data.get("show_total_votes"),
220
- )
173
+
221
174
 
222
175
  @dataclass
223
- class File:
176
+ class File(Dict):
224
177
  file_id: Optional[str] = None
225
178
  file_name: Optional[str] = None
226
179
  size: Optional[str] = None
227
-
228
- @classmethod
229
- def read(cls, data: dict[str, Any]) -> "File":
230
- return cls(
231
- file_id = data.get("file_id"),
232
- file_name = data.get("file_name"),
233
- size = data.get("size"),
234
- )
235
-
180
+
181
+
236
182
  @dataclass
237
- class LiveLocation:
183
+ class LiveLocation(Dict):
238
184
  start_time: Optional[str] = None
239
185
  live_period: Optional[int] = None
240
186
  current_location: Optional[Location] = None
241
187
  user_id: Optional[str] = None
242
188
  status: Optional[Literal["Stopped", "Live"]] = None
243
189
  last_update_time: Optional[str] = None
244
-
245
- @classmethod
246
- def read(cls, data: dict[str, Any]) -> "LiveLocation":
247
- return cls(
248
- start_time = data.get("start_time"),
249
- live_period = data.get("live_period"),
250
- current_location = Location.read(data.get("current_location")) if "current_location" in data else None,
251
- user_id = data.get("user_id"),
252
- status = data.get("status"),
253
- last_update_time = data.get("last_update_time")
254
- )
255
-
190
+
191
+
256
192
  @dataclass
257
- class Poll:
193
+ class Poll(Dict):
258
194
  question: Optional[str] = None
259
- options: Optional[List[str]] = None
195
+ options: Optional[list[str]] = None
260
196
  poll_status: Optional[PollStatus] = None
261
-
262
- @classmethod
263
- def read(cls, data: dict[str, Any]) -> "Poll":
264
- return cls(
265
- question = data.get("question"),
266
- options = data.get("options"),
267
- poll_status = PollStatus.read(data.get("poll_status")) if "poll_status" in data else None
268
- )
269
-
197
+
198
+
270
199
  @dataclass
271
- class ContactMessage:
200
+ class ContactMessage(Dict):
272
201
  phone_number: Optional[str] = None
273
202
  first_name: Optional[str] = None
274
203
  last_name: Optional[str] = None
275
-
276
- @classmethod
277
- def read(cls, data: dict[str, Any]) -> "ContactMessage":
278
- return cls(
279
- phone_number = data.get("phone_number"),
280
- first_name = data.get("first_name"),
281
- last_name = data.get("last_name")
282
- )
283
-
204
+
205
+
284
206
  @dataclass
285
- class Sticker:
207
+ class Sticker(Dict):
286
208
  sticker_id: Optional[str] = None
287
209
  file: Optional[File] = None
288
210
  emoji_character: Optional[str] = None
289
-
290
- @classmethod
291
- def read(cls, data: dict[str, Any]) -> "Sticker":
292
- return cls(
293
- sticker_id = data.get("sticker_id"),
294
- file = File.read(data.get("file")) if "file" in data else None,
295
- emoji_character = data.get("emoji_character")
296
- )
211
+
297
212
 
298
213
  @dataclass
299
- class ForwardedFrom:
214
+ class ForwardedFrom(Dict):
300
215
  type_from: Optional[Literal["User", "Channel", "Bot"]] = None
301
216
  message_id: Optional[str] = None
302
217
  from_chat_id: Optional[str] = None
303
218
  from_sender_id: Optional[str] = None
304
-
305
- @classmethod
306
- def read(cls, data: dict[str, Any]) -> "ForwardedFrom":
307
- return cls(
308
- type_from = data.get("type_from"),
309
- message_id = data.get("message_id"),
310
- from_chat_id = data.get("from_chat_id"),
311
- from_sender_id = data.get("from_sender_id")
312
- )
219
+
313
220
 
314
221
  @dataclass
315
- class AuxData:
222
+ class AuxData(Dict):
316
223
  start_id: Optional[str] = None
317
224
  button_id: Optional[str] = None
318
-
319
- @classmethod
320
- def read(cls, data: Dict[str, Any]) -> "AuxData":
321
- return cls(
322
- start_id = data.get("start_id"),
323
- button_id = data.get("button_id")
324
- )
325
-
326
- @dataclass
327
- class PaymentStatus:
328
- payment_id: Optional[str] = None
329
- status: Optional[Literal["Paid", "NotPaid"]] = None
330
-
331
- @classmethod
332
- def read(cls, data: Dict[str, Any]) -> "PaymentStatus":
333
- return cls(
334
- payment_id = data.get("payment_id"),
335
- status = data.get("status")
336
- )
337
225
 
338
- @dataclass
339
- class Chat:
340
- chat_id: Optional[str] = None
341
- chat_type: Optional[Literal["User", "Bot", "Group", "Channel"]] = None
342
- user_id: Optional[str] = None
343
- first_name: Optional[str] = None
344
- last_name: Optional[str] = None
345
- title: Optional[str] = None
346
- username: Optional[str] = None
347
-
348
- @classmethod
349
- def read(cls, data: Dict[str, Any]) -> "Chat":
350
- return cls(
351
- chat_id = data.get("chat_id"),
352
- chat_type = data.get("chat_type"),
353
- user_id = data.get("user_id"),
354
- first_name = data.get("first_name"),
355
- last_name = data.get("last_name"),
356
- title = data.get("title"),
357
- username = data.get("username")
358
- )
359
226
 
360
227
  @dataclass
361
- class Bot:
362
- bot_id: Optional[str] = None
363
- bot_title: Optional[str] = None
364
- avatar: Optional[File] = None
365
- description: Optional[str] = None
366
- username: Optional[str] = None
367
- start_message: Optional[str] = None
368
- share_url: Optional[str] = None
369
-
370
- @classmethod
371
- def read(cls, data: Dict[str, Any]) -> "Bot":
372
- return cls(
373
- bot_id = data.get("bot_id"),
374
- bot_title = data.get("bot_title"),
375
- avatar = File.read(data.get("avatar")) if data.get("avatar") else None,
376
- description = data.get("description"),
377
- username = data.get("username"),
378
- start_message = data.get("start_message"),
379
- share_url = data.get("share_url")
380
- )
228
+ class PaymentStatus(Dict):
229
+ payment_id: Optional[str] = None
230
+ status: Optional[Literal["Paid", "NotPaid"]] = None
381
231
 
382
- @dataclass
383
- class InlineMessage:
384
- sender_id: Optional[str] = None
385
- text: Optional[str] = None
386
- message_id: Optional[str] = None
387
- chat_id: Optional[str] = None
388
- file: Optional[File] = None
389
- location: Optional[Location] = None
390
- aux_data: Optional[AuxData] = None
391
-
392
- @classmethod
393
- def read(cls, data: Dict[str, Any]) -> "InlineMessage":
394
- return cls(
395
- sender_id = data.get("sender_id"),
396
- text = data.get("text"),
397
- message_id = data.get("message_id"),
398
- chat_id = data.get("chat_id"),
399
- file = File.read(data.get("file")) if data.get("file") else None,
400
- location = Location.read(data.get("location")) if data.get("location") else None,
401
- aux_data = AuxData.read(data.get("aux_data")) if data.get("aux_data") else None
402
- )
403
232
 
404
233
  @dataclass
405
- class Message:
234
+ class Message(Dict):
406
235
  message_id: Optional[str] = None
407
236
  text: Optional[str] = None
408
237
  time: Optional[str] = None
@@ -419,55 +248,216 @@ class Message:
419
248
  contact_message: Optional[ContactMessage] = None
420
249
  poll: Optional[Poll] = None
421
250
  live_location: Optional[LiveLocation] = None
422
-
423
- @classmethod
424
- def read(cls, data: Dict[str, Any]) -> "Message":
425
- return cls(
426
- message_id = data["message_id"],
427
- text = data.get("text"),
428
- time = data["time"],
429
- is_edited = data["is_edited"],
430
- sender_type = data["sender_type"],
431
- sender_id = data["sender_id"],
432
- aux_data = AuxData.read(data["aux_data"]) if "aux_data" in data else None,
433
- file = File.read(data["file"]) if "file" in data else None,
434
- reply_to_message_id = data.get("reply_to_message_id"),
435
- forwarded_from = ForwardedFrom.read(data["forwarded_from"]) if "forwarded_from" in data else None,
436
- forwarded_no_link = data.get("forwarded_no_link"),
437
- location = Location.read(data["location"]) if "location" in data else None,
438
- sticker = Sticker.read(data["sticker"]) if "sticker" in data else None,
439
- contact_message = ContactMessage.read(data["contact_message"]) if "contact_message" in data else None,
440
- poll = Poll.read(data["poll"]) if "poll" in data else None,
441
- live_location = LiveLocation.read(data["live_location"]) if "live_location" in data else None
442
- )
251
+
443
252
 
444
253
  @dataclass
445
- class Update:
254
+ class InlineMessage(Dict):
255
+ sender_id: Optional[str] = None
256
+ text: Optional[str] = None
257
+ message_id: Optional[str] = None
258
+ chat_id: Optional[str] = None
259
+ file: Optional[File] = None
260
+ location: Optional[Location] = None
261
+ aux_data: Optional[AuxData] = None
262
+
263
+
264
+ @dataclass
265
+ class Bot(Dict):
266
+ bot_id: Optional[str] = None
267
+ bot_title: Optional[str] = None
268
+ avatar: Optional[File] = None
269
+ description: Optional[str] = None
270
+ username: Optional[str] = None
271
+ start_message: Optional[str] = None
272
+ share_url: Optional[str] = None
273
+
274
+
275
+ @dataclass
276
+ class Chat(Dict):
277
+ chat_id: Optional[str] = None
278
+ chat_type: Optional[Literal["User", "Bot", "Group", "Channel"]] = None
279
+ user_id: Optional[str] = None
280
+ first_name: Optional[str] = None
281
+ last_name: Optional[str] = None
282
+ title: Optional[str] = None
283
+ username: Optional[str] = None
284
+
285
+
286
+ @dataclass
287
+ class MessageId(Dict):
288
+ message_id: Optional[str] = None
289
+ file_id: Optional[str] = None
290
+
291
+
292
+ @dataclass
293
+ class Update(Dict):
446
294
  client: Optional["rubigram.Client"] = None
447
295
  type: Optional[Literal["NewMessage", "UpdatedMessage", "RemovedMessage", "StartedBot", "StoppedBot", "UpdatedPayment"]] = None
448
296
  chat_id: Optional[str] = None
449
- removed_message_id: Optional[str] = None
297
+ removed_message_id: Optional[str] = None
450
298
  new_message: Optional[Message] = None
451
299
  updated_message: Optional[Message] = None
452
300
  updated_payment: Optional[PaymentStatus] = None
453
301
 
454
- @classmethod
455
- def read(cls, data: Dict[str, Any], client: Optional["rubigram.Client"] = None) -> "Update":
456
- return cls(
457
- client = client,
458
- type = data["type"],
459
- chat_id = data["chat_id"],
460
- removed_message_id = data.get("removed_message_id"),
461
- new_message = Message.read(data["new_message"]) if "new_message" in data else None,
462
- updated_message = Message.read(data["updated_message"]) if "updated_message" in data else None,
463
- updated_payment = PaymentStatus.read(data["updated_payment"]) if "updated_payment" in data else None
302
+ async def send_text(
303
+ self,
304
+ text: str,
305
+ chat_keypad: Keypad = None,
306
+ inline_keypad: Keypad= None,
307
+ chat_keypad_type: Literal["New", "Remove"] = None,
308
+ disable_notification: bool = None,
309
+ reply_to_message_id = None
310
+ ) -> "MessageId":
311
+ return await self.client.send_message(self.chat_id, text, chat_keypad, inline_keypad, chat_keypad_type, disable_notification, reply_to_message_id)
312
+
313
+ async def reply(
314
+ self,
315
+ text: str,
316
+ chat_keypad: Keypad = None,
317
+ inline_keypad: Keypad= None,
318
+ chat_keypad_type: Literal["New", "Remove"] = None,
319
+ disable_notification: bool = None,
320
+ ) -> "MessageId":
321
+ return await self.client.send_message(self.chat_id, text, chat_keypad, inline_keypad, chat_keypad_type, disable_notification, self.new_message.message_id)
322
+
323
+ async def reply_file(
324
+ self,
325
+ file: str,
326
+ file_name: str,
327
+ type: Literal["File", "Image", "Voice", "Music", "Gif", "Video"] = "File",
328
+ chat_keypad: Keypad = None,
329
+ inline_keypad: Keypad = None,
330
+ chat_keypad_type: Literal["New", "Remove"] = None,
331
+ disable_notification: bool = False,
332
+ ) -> "MessageId":
333
+ return await self.client.send_file(
334
+ self.chat_id,
335
+ file,
336
+ file_name,
337
+ type,
338
+ chat_keypad,
339
+ inline_keypad,
340
+ chat_keypad_type,
341
+ disable_notification,
342
+ self.new_message.message_id
464
343
  )
465
344
 
466
- async def reply_text(self, text: str) -> "MessageId":
467
- return await self.client.send_message(self.chat_id, text, reply_to_message_id=self.new_message.message_id)
345
+ async def reply_document(
346
+ self,
347
+ document: str,
348
+ name: str,
349
+ chat_keypad: Keypad = None,
350
+ inline_keypad: Keypad = None,
351
+ chat_keypad_type: Literal["New", "Remove"] = None,
352
+ disable_notification: bool = False,
353
+ ) -> "MessageId":
354
+ return await self.client.send_document(
355
+ self.chat_id,
356
+ document,
357
+ name,
358
+ chat_keypad,
359
+ inline_keypad,
360
+ chat_keypad_type,
361
+ disable_notification,
362
+ self.new_message.message_id
363
+ )
468
364
 
469
- async def reply_file(self, path: str, file_name: str, type: Literal["File", "Image", "Voice", "Music", "Gif", "Video"] = "File") -> "MessageId":
470
- return await self.client.send_file(self.chat_id, path, file_name, type, reply_to_message_id=self.new_message.message_id)
471
-
472
- async def download(self, file_name: str):
473
- return await self.client.download_file(self.new_message.file.file_id, file_name)
365
+ async def reply_photo(
366
+ self,
367
+ photo: str,
368
+ name: str,
369
+ chat_keypad: Keypad = None,
370
+ inline_keypad: Keypad = None,
371
+ chat_keypad_type: Literal["New", "Remove"] = None,
372
+ disable_notification: bool = False,
373
+ ) -> "MessageId":
374
+ return await self.client.send_photo(
375
+ self.chat_id,
376
+ photo,
377
+ name,
378
+ chat_keypad,
379
+ inline_keypad,
380
+ chat_keypad_type,
381
+ disable_notification,
382
+ self.new_message.message_id
383
+ )
384
+
385
+ async def reply_video(
386
+ self,
387
+ video: str,
388
+ name: str,
389
+ chat_keypad: Keypad = None,
390
+ inline_keypad: Keypad = None,
391
+ chat_keypad_type: Literal["New", "Remove"] = None,
392
+ disable_notification: bool = False,
393
+ ) -> "MessageId":
394
+ return await self.client.send_video(
395
+ self.chat_id,
396
+ video,
397
+ name,
398
+ chat_keypad,
399
+ inline_keypad,
400
+ chat_keypad_type,
401
+ disable_notification,
402
+ self.new_message.message_id
403
+ )
404
+
405
+ async def reply_gif(
406
+ self,
407
+ gif: str,
408
+ name: str,
409
+ chat_keypad: Keypad = None,
410
+ inline_keypad: Keypad = None,
411
+ chat_keypad_type: Literal["New", "Remove"] = None,
412
+ disable_notification: bool = False,
413
+ ) -> "MessageId":
414
+ return await self.client.send_gif(
415
+ self.chat_id,
416
+ gif,
417
+ name,
418
+ chat_keypad,
419
+ inline_keypad,
420
+ chat_keypad_type,
421
+ disable_notification,
422
+ self.new_message.message_id
423
+ )
424
+
425
+ async def reply_music(
426
+ self,
427
+ music: str,
428
+ name: str,
429
+ chat_keypad: Keypad = None,
430
+ inline_keypad: Keypad = None,
431
+ chat_keypad_type: Literal["New", "Remove"] = None,
432
+ disable_notification: bool = False,
433
+ ) -> "MessageId":
434
+ return await self.client.send_music(
435
+ self.chat_id,
436
+ music,
437
+ name,
438
+ chat_keypad,
439
+ inline_keypad,
440
+ chat_keypad_type,
441
+ disable_notification,
442
+ self.new_message.message_id
443
+ )
444
+
445
+ async def replyvoice(
446
+ self,
447
+ voice: str,
448
+ name: str,
449
+ chat_keypad: Keypad = None,
450
+ inline_keypad: Keypad = None,
451
+ chat_keypad_type: Literal["New", "Remove"] = None,
452
+ disable_notification: bool = False,
453
+ ) -> "MessageId":
454
+ return await self.client.send_voice(
455
+ self.chat_id,
456
+ voice,
457
+ name,
458
+ chat_keypad,
459
+ inline_keypad,
460
+ chat_keypad_type,
461
+ disable_notification,
462
+ self.new_message.message_id
463
+ )