RubigramClient 1.7.17__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.
- rubigram/__init__.py +15 -0
- rubigram/client.py +294 -0
- rubigram/enums/__init__.py +52 -0
- rubigram/enums/buttons/__init__.py +13 -0
- rubigram/enums/buttons/button_calendar_type.py +20 -0
- rubigram/enums/buttons/button_location_type.py +20 -0
- rubigram/enums/buttons/button_selection_get_type.py +20 -0
- rubigram/enums/buttons/button_selection_search_type.py +20 -0
- rubigram/enums/buttons/button_selection_type.py +22 -0
- rubigram/enums/buttons/button_textbox_type_keypad.py +20 -0
- rubigram/enums/buttons/button_textbox_type_line.py +20 -0
- rubigram/enums/buttons/button_type.py +58 -0
- rubigram/enums/chat_action_type.py +22 -0
- rubigram/enums/chat_keypad_type.py +20 -0
- rubigram/enums/chat_type.py +24 -0
- rubigram/enums/enum.py +6 -0
- rubigram/enums/file_type.py +28 -0
- rubigram/enums/forwarded_from_type.py +22 -0
- rubigram/enums/live_location_status.py +20 -0
- rubigram/enums/message_sender_type.py +20 -0
- rubigram/enums/metadata_type.py +18 -0
- rubigram/enums/parse_mode.py +20 -0
- rubigram/enums/payment_status_type.py +20 -0
- rubigram/enums/poll_status_type.py +20 -0
- rubigram/enums/update_endpoint_type.py +26 -0
- rubigram/enums/update_type.py +28 -0
- rubigram/errors.py +16 -0
- rubigram/filters.py +865 -0
- rubigram/http_session.py +96 -0
- rubigram/methods/__init__.py +26 -0
- rubigram/methods/chats/__init__.py +10 -0
- rubigram/methods/chats/get_chat.py +53 -0
- rubigram/methods/decorators/__init__.py +25 -0
- rubigram/methods/decorators/on_inline_message.py +70 -0
- rubigram/methods/decorators/on_message.py +62 -0
- rubigram/methods/decorators/on_remove_message.py +65 -0
- rubigram/methods/decorators/on_start.py +65 -0
- rubigram/methods/decorators/on_started_bot.py +70 -0
- rubigram/methods/decorators/on_stop.py +65 -0
- rubigram/methods/decorators/on_stopped_bot.py +70 -0
- rubigram/methods/decorators/on_update_message.py +70 -0
- rubigram/methods/files/__init__.py +32 -0
- rubigram/methods/files/download_file.py +118 -0
- rubigram/methods/files/get_file.py +41 -0
- rubigram/methods/files/get_file_name.py +41 -0
- rubigram/methods/files/request_send_file.py +49 -0
- rubigram/methods/files/send_file.py +133 -0
- rubigram/methods/files/send_gif.py +51 -0
- rubigram/methods/files/send_music.py +97 -0
- rubigram/methods/files/send_photo.py +95 -0
- rubigram/methods/files/send_video.py +96 -0
- rubigram/methods/files/send_voice.py +96 -0
- rubigram/methods/files/upload_file.py +114 -0
- rubigram/methods/messages/__init__.py +34 -0
- rubigram/methods/messages/delete_messages.py +84 -0
- rubigram/methods/messages/edit_chat_keypad.py +68 -0
- rubigram/methods/messages/edit_message.py +82 -0
- rubigram/methods/messages/edit_message_keypad.py +72 -0
- rubigram/methods/messages/edit_message_text.py +68 -0
- rubigram/methods/messages/forward_message.py +78 -0
- rubigram/methods/messages/remove_chat_keypad.py +46 -0
- rubigram/methods/messages/send_contact.py +114 -0
- rubigram/methods/messages/send_location.py +108 -0
- rubigram/methods/messages/send_message.py +115 -0
- rubigram/methods/messages/send_poll.py +104 -0
- rubigram/methods/messages/send_sticker.py +98 -0
- rubigram/methods/network/__init__.py +12 -0
- rubigram/methods/network/request.py +129 -0
- rubigram/methods/settings/__init__.py +16 -0
- rubigram/methods/settings/set_command.py +50 -0
- rubigram/methods/settings/setup_endpoints.py +48 -0
- rubigram/methods/settings/update_bot_endpoint.py +62 -0
- rubigram/methods/updates/__init__.py +14 -0
- rubigram/methods/updates/get_me.py +35 -0
- rubigram/methods/updates/get_update.py +62 -0
- rubigram/methods/utilities/__init__.py +14 -0
- rubigram/methods/utilities/dispatcher.py +66 -0
- rubigram/methods/utilities/run.py +118 -0
- rubigram/rubino/__init__.py +6 -0
- rubigram/rubino/client.py +374 -0
- rubigram/rubino/network.py +129 -0
- rubigram/server/__init__.py +6 -0
- rubigram/server/server.py +245 -0
- rubigram/state/__init__.py +7 -0
- rubigram/state/state.py +121 -0
- rubigram/state/storage.py +131 -0
- rubigram/types/__init__.py +66 -0
- rubigram/types/aux_data.py +28 -0
- rubigram/types/bot.py +51 -0
- rubigram/types/bot_command.py +26 -0
- rubigram/types/buttons/__init__.py +13 -0
- rubigram/types/buttons/button.py +59 -0
- rubigram/types/buttons/button_calendar.py +40 -0
- rubigram/types/buttons/button_location.py +40 -0
- rubigram/types/buttons/button_number_picker.py +34 -0
- rubigram/types/buttons/button_selection.py +48 -0
- rubigram/types/buttons/button_selection_item.py +32 -0
- rubigram/types/buttons/button_string_picker.py +29 -0
- rubigram/types/buttons/button_text_box.py +40 -0
- rubigram/types/chat.py +86 -0
- rubigram/types/config/__init__.py +6 -0
- rubigram/types/config/object.py +442 -0
- rubigram/types/contact_message.py +29 -0
- rubigram/types/file.py +78 -0
- rubigram/types/forwarded_from.py +39 -0
- rubigram/types/keypads/__init__.py +7 -0
- rubigram/types/keypads/keypad.py +31 -0
- rubigram/types/keypads/keypad_row.py +23 -0
- rubigram/types/live_location.py +44 -0
- rubigram/types/location.py +24 -0
- rubigram/types/messages/__init__.py +8 -0
- rubigram/types/messages/inline_message.py +78 -0
- rubigram/types/messages/message.py +117 -0
- rubigram/types/messages/update_message.py +341 -0
- rubigram/types/metadata/__init__.py +7 -0
- rubigram/types/metadata/metadata.py +43 -0
- rubigram/types/metadata/metadata_parts.py +42 -0
- rubigram/types/payment_status.py +30 -0
- rubigram/types/poll.py +32 -0
- rubigram/types/poll_status.py +40 -0
- rubigram/types/sticker.py +33 -0
- rubigram/types/updates/__init__.py +7 -0
- rubigram/types/updates/update.py +917 -0
- rubigram/types/updates/updates.py +56 -0
- rubigram/utils/__init__.py +14 -0
- rubigram/utils/auto_delete.py +93 -0
- rubigram/utils/parser.py +99 -0
- rubigramclient-1.7.17.dist-info/METADATA +215 -0
- rubigramclient-1.7.17.dist-info/RECORD +132 -0
- rubigramclient-1.7.17.dist-info/WHEEL +5 -0
- rubigramclient-1.7.17.dist-info/licenses/LICENSE +21 -0
- rubigramclient-1.7.17.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,917 @@
|
|
|
1
|
+
# RubigramClient - Rubika API library for python
|
|
2
|
+
# Copyright (C) 2025-present Javad <https://github.com/DevJavad>
|
|
3
|
+
# Github - https://github.com/DevJavad/rubigram
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from typing import Optional, Union, BinaryIO
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from ..config import Object
|
|
11
|
+
from io import BytesIO
|
|
12
|
+
import rubigram
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class Update(Object):
|
|
17
|
+
"""
|
|
18
|
+
**Represents an incoming update in Rubigram.**
|
|
19
|
+
`from rubigram.types import Update`
|
|
20
|
+
|
|
21
|
+
An update can include new messages, edited messages, deleted messages,
|
|
22
|
+
payment updates, and other types of events that occur in a chat.
|
|
23
|
+
|
|
24
|
+
Attributes:
|
|
25
|
+
type (`rubigram.enums.UpdateType`):
|
|
26
|
+
The type of the update (e.g., new message, edited message).
|
|
27
|
+
|
|
28
|
+
chat_id (`str`):
|
|
29
|
+
The chat ID related to this update.
|
|
30
|
+
|
|
31
|
+
removed_message_id (`Optional[str]`):
|
|
32
|
+
The ID of a deleted message, if applicable.
|
|
33
|
+
|
|
34
|
+
new_message (`Optional[rubigram.types.Message]`):
|
|
35
|
+
The new message associated with this update.
|
|
36
|
+
|
|
37
|
+
updated_message (`Optional[rubigram.types.Message]`):
|
|
38
|
+
The updated message associated with this update.
|
|
39
|
+
|
|
40
|
+
updated_payment (`Optional[rubigram.types.PaymentStatus]`):
|
|
41
|
+
Payment status update, if applicable.
|
|
42
|
+
|
|
43
|
+
client (`Optional[rubigram.Client]`):
|
|
44
|
+
The Rubigram client bound to this update for sending replies, etc.
|
|
45
|
+
"""
|
|
46
|
+
type: Union[str, rubigram.enums.UpdateType]
|
|
47
|
+
chat_id: str
|
|
48
|
+
update_time: Optional[int] = None
|
|
49
|
+
removed_message_id: Optional[str] = None
|
|
50
|
+
new_message: Optional[rubigram.types.Message] = None
|
|
51
|
+
updated_message: Optional[rubigram.types.Message] = None
|
|
52
|
+
updated_payment: Optional[rubigram.types.PaymentStatus] = None
|
|
53
|
+
client: Optional[rubigram.Client] = None
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def text(self) -> Optional[str]:
|
|
57
|
+
if self.new_message:
|
|
58
|
+
return self.new_message.text
|
|
59
|
+
elif self.updated_message:
|
|
60
|
+
return self.updated_message.text
|
|
61
|
+
return None
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def message_id(self) -> Optional[str]:
|
|
65
|
+
if self.new_message:
|
|
66
|
+
return self.new_message.id
|
|
67
|
+
elif self.updated_message:
|
|
68
|
+
return self.updated_message.id
|
|
69
|
+
return None
|
|
70
|
+
|
|
71
|
+
@property
|
|
72
|
+
def sender_id(self) -> Optional[str]:
|
|
73
|
+
if self.new_message and self.new_message.sender_id:
|
|
74
|
+
return self.new_message.sender_id
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
async def reply(
|
|
78
|
+
self,
|
|
79
|
+
text: str,
|
|
80
|
+
chat_keypad: Optional[rubigram.types.Keypad] = None,
|
|
81
|
+
inline_keypad: Optional[rubigram.types.Keypad] = None,
|
|
82
|
+
chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
|
|
83
|
+
disable_notification: bool = False,
|
|
84
|
+
parse_mode: Optional[Union[str, rubigram.enums.ParseMode]] = None,
|
|
85
|
+
auto_delete: Optional[int] = None
|
|
86
|
+
) -> rubigram.types.UMessage:
|
|
87
|
+
"""
|
|
88
|
+
**Reply to the current message with text and optional keypads.**
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
text (`str`):
|
|
92
|
+
The text of the reply message.
|
|
93
|
+
|
|
94
|
+
chat_keypad (`Optional[rubigram.types.Keypad]`):
|
|
95
|
+
Keypad to show in the chat. Defaults to None.
|
|
96
|
+
|
|
97
|
+
inline_keypad (`Optional[rubigram.types.Keypad]`):
|
|
98
|
+
Inline keypad to show. Defaults to None.
|
|
99
|
+
|
|
100
|
+
chat_keypad_type (`Optional[rubigramenums.ChatKeypadType]`):
|
|
101
|
+
Type of chat keypad. Defaults to None.
|
|
102
|
+
|
|
103
|
+
disable_notification (`Optional[bool]`):
|
|
104
|
+
If True, disables notification for the message. Defaults to None.
|
|
105
|
+
|
|
106
|
+
auto_delete (`Optional[int]`):
|
|
107
|
+
If set, the message will be automatically deleted after the specified number of seconds.
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
rubigram.types.UMessage: The sent reply message object.
|
|
111
|
+
|
|
112
|
+
Example:
|
|
113
|
+
.. code-block:: python
|
|
114
|
+
|
|
115
|
+
await update.reply(
|
|
116
|
+
text=text,
|
|
117
|
+
chat_keypad=chat_keypad,
|
|
118
|
+
chat_keypad_type=rubigram.enums.ChatKeypadType.New,
|
|
119
|
+
disable_notification=True
|
|
120
|
+
)
|
|
121
|
+
"""
|
|
122
|
+
return await self.client.send_message(
|
|
123
|
+
self.chat_id,
|
|
124
|
+
text,
|
|
125
|
+
chat_keypad,
|
|
126
|
+
inline_keypad,
|
|
127
|
+
chat_keypad_type,
|
|
128
|
+
disable_notification,
|
|
129
|
+
self.message_id,
|
|
130
|
+
parse_mode,
|
|
131
|
+
auto_delete
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
async def reply_poll(
|
|
135
|
+
self,
|
|
136
|
+
question: str,
|
|
137
|
+
options: list[str],
|
|
138
|
+
chat_keypad: Optional[rubigram.types.Keypad] = None,
|
|
139
|
+
inline_keypad: Optional[rubigram.types.Keypad] = None,
|
|
140
|
+
chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
|
|
141
|
+
disable_notification: bool = False,
|
|
142
|
+
auto_delete: Optional[int] = None
|
|
143
|
+
) -> rubigram.types.UMessage:
|
|
144
|
+
"""
|
|
145
|
+
**Reply to the current message with a poll.**
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
question (`str`):
|
|
149
|
+
The poll question text.
|
|
150
|
+
|
|
151
|
+
options (`list[str]`):
|
|
152
|
+
A list of options for the poll.
|
|
153
|
+
|
|
154
|
+
chat_keypad (`Optional[rubigram.types.Keypad]`):
|
|
155
|
+
Keypad to show in the chat. Defaults to None.
|
|
156
|
+
|
|
157
|
+
inline_keypad (`Optional[rubigram.types.Keypad]`):
|
|
158
|
+
Inline keypad to show. Defaults to None.
|
|
159
|
+
|
|
160
|
+
chat_keypad_type (`Optional[rubigram.enums.ChatKeypadType]`):
|
|
161
|
+
Type of chat keypad. Defaults to None.
|
|
162
|
+
|
|
163
|
+
disable_notification (`bool`):
|
|
164
|
+
If True, disables notification for the message. Defaults to False.
|
|
165
|
+
|
|
166
|
+
auto_delete (`Optional[int]`):
|
|
167
|
+
If set, the message will be automatically deleted after the specified number of seconds.
|
|
168
|
+
|
|
169
|
+
Returns:
|
|
170
|
+
rubigram.types.UMessage: The sent poll message object.
|
|
171
|
+
|
|
172
|
+
Example:
|
|
173
|
+
.. code-block:: python
|
|
174
|
+
|
|
175
|
+
options = ["option1", "option2"]
|
|
176
|
+
await update.reply_poll(
|
|
177
|
+
question=question,
|
|
178
|
+
options=options
|
|
179
|
+
)
|
|
180
|
+
"""
|
|
181
|
+
return await self.client.send_poll(
|
|
182
|
+
self.chat_id,
|
|
183
|
+
question,
|
|
184
|
+
options,
|
|
185
|
+
chat_keypad,
|
|
186
|
+
inline_keypad,
|
|
187
|
+
chat_keypad_type,
|
|
188
|
+
disable_notification,
|
|
189
|
+
self.message_id,
|
|
190
|
+
auto_delete
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
async def reply_location(
|
|
194
|
+
self,
|
|
195
|
+
latitude: str,
|
|
196
|
+
longitude: str,
|
|
197
|
+
chat_keypad: Optional[rubigram.types.Keypad] = None,
|
|
198
|
+
inline_keypad: Optional[rubigram.types.Keypad] = None,
|
|
199
|
+
chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
|
|
200
|
+
disable_notification: bool = False,
|
|
201
|
+
auto_delete: Optional[int] = None
|
|
202
|
+
) -> rubigram.types.UMessage:
|
|
203
|
+
"""
|
|
204
|
+
**Reply to the current message with a location.**
|
|
205
|
+
`await update.reply_location("35.6895", "139.6917")`
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
latitude (`str`):
|
|
209
|
+
Latitude of the location.
|
|
210
|
+
|
|
211
|
+
longitude (`str`):
|
|
212
|
+
Longitude of the location.
|
|
213
|
+
|
|
214
|
+
chat_keypad (`Optional[rubigram.types.Keypad]`):
|
|
215
|
+
Keypad to show in chat. Defaults to None.
|
|
216
|
+
|
|
217
|
+
inline_keypad (`Optional[rubigram.types.Keypad]`):
|
|
218
|
+
Inline keypad to show. Defaults to None.
|
|
219
|
+
|
|
220
|
+
chat_keypad_type (`Optional[rubigram.enums.ChatKeypadType]`):
|
|
221
|
+
Type of chat keypad. Defaults to None.
|
|
222
|
+
|
|
223
|
+
disable_notification (`bool`):
|
|
224
|
+
If True, disables notification. Defaults to False.
|
|
225
|
+
|
|
226
|
+
auto_delete (`Optional[int]`):
|
|
227
|
+
If set, the message will be automatically deleted after the specified number of seconds.
|
|
228
|
+
|
|
229
|
+
Returns:
|
|
230
|
+
rubigram.types.UMessage: The sent location message.
|
|
231
|
+
|
|
232
|
+
Example:
|
|
233
|
+
.. code-block:: python
|
|
234
|
+
|
|
235
|
+
await update.reply_location("35.6895", "139.6917")
|
|
236
|
+
"""
|
|
237
|
+
return await self.client.send_location(
|
|
238
|
+
self.chat_id,
|
|
239
|
+
latitude,
|
|
240
|
+
longitude,
|
|
241
|
+
chat_keypad,
|
|
242
|
+
inline_keypad,
|
|
243
|
+
chat_keypad_type,
|
|
244
|
+
disable_notification,
|
|
245
|
+
self.message_id,
|
|
246
|
+
auto_delete
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
async def reply_contact(
|
|
250
|
+
self,
|
|
251
|
+
phone_number: str,
|
|
252
|
+
first_name: str,
|
|
253
|
+
last_name: Optional[str] = None,
|
|
254
|
+
chat_keypad: Optional[rubigram.types.Keypad] = None,
|
|
255
|
+
inline_keypad: Optional[rubigram.types.Keypad] = None,
|
|
256
|
+
chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
|
|
257
|
+
disable_notification: bool = False,
|
|
258
|
+
auto_delete: Optional[int] = None
|
|
259
|
+
) -> rubigram.types.UMessage:
|
|
260
|
+
"""
|
|
261
|
+
**Reply to the current message with a contact.**
|
|
262
|
+
|
|
263
|
+
Args:
|
|
264
|
+
phone_number (`str`):
|
|
265
|
+
Contact's phone number.
|
|
266
|
+
|
|
267
|
+
first_name (`str`):
|
|
268
|
+
Contact's first name.
|
|
269
|
+
|
|
270
|
+
last_name (`Optional[str]`):
|
|
271
|
+
Contact's last name.
|
|
272
|
+
|
|
273
|
+
chat_keypad (`Optional[rubigram.types.Keypad]`):
|
|
274
|
+
Keypad to show in chat. Defaults to None.
|
|
275
|
+
|
|
276
|
+
inline_keypad (`Optional[rubigram.types.Keypad]`):
|
|
277
|
+
Inline keypad to show. Defaults to None.
|
|
278
|
+
|
|
279
|
+
chat_keypad_type (`Optional[rubigram.enums.ChatKeypadType]`):
|
|
280
|
+
Type of chat keypad. Defaults to None.
|
|
281
|
+
|
|
282
|
+
disable_notification (`bool`):
|
|
283
|
+
If True, disables notification. Defaults to False.
|
|
284
|
+
|
|
285
|
+
auto_delete (`Optional[int]`):
|
|
286
|
+
If set, the message will be automatically deleted after the specified number of seconds.
|
|
287
|
+
|
|
288
|
+
Returns:
|
|
289
|
+
rubigram.types.UMessage: The sent contact message.
|
|
290
|
+
|
|
291
|
+
Example:
|
|
292
|
+
.. code-block:: python
|
|
293
|
+
|
|
294
|
+
await update.reply_contact(
|
|
295
|
+
phone_number=phone_number,
|
|
296
|
+
first_name=first_name,
|
|
297
|
+
last_name=last_name
|
|
298
|
+
)
|
|
299
|
+
"""
|
|
300
|
+
return await self.client.send_contact(
|
|
301
|
+
self.chat_id,
|
|
302
|
+
first_name,
|
|
303
|
+
last_name,
|
|
304
|
+
phone_number,
|
|
305
|
+
chat_keypad,
|
|
306
|
+
inline_keypad,
|
|
307
|
+
chat_keypad_type,
|
|
308
|
+
disable_notification,
|
|
309
|
+
self.message_id,
|
|
310
|
+
auto_delete
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
async def reply_sticker(
|
|
314
|
+
self,
|
|
315
|
+
sticker_id: str,
|
|
316
|
+
chat_keypad: Optional[rubigram.types.Keypad] = None,
|
|
317
|
+
inline_keypad: Optional[rubigram.types.Keypad] = None,
|
|
318
|
+
chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
|
|
319
|
+
disable_notification: bool = False,
|
|
320
|
+
auto_delete: Optional[int] = None
|
|
321
|
+
) -> rubigram.types.UMessage:
|
|
322
|
+
"""
|
|
323
|
+
**Reply to the current message with a sticker.**
|
|
324
|
+
|
|
325
|
+
Args:
|
|
326
|
+
sticker_id (`str`):
|
|
327
|
+
The ID of the sticker to send.
|
|
328
|
+
|
|
329
|
+
chat_keypad (`Optional[rubigram.types.Keypad]`):
|
|
330
|
+
Keypad to show in chat. Defaults to None.
|
|
331
|
+
|
|
332
|
+
inline_keypad (`Optional[rubigram.types.Keypad]`):
|
|
333
|
+
Inline keypad to show. Defaults to None.
|
|
334
|
+
|
|
335
|
+
chat_keypad_type (`Optional[rubigram.enums.ChatKeypadType]`):
|
|
336
|
+
Type of chat keypad. Defaults to None.
|
|
337
|
+
|
|
338
|
+
disable_notification (`bool`):
|
|
339
|
+
If True, disables notification. Defaults to False.
|
|
340
|
+
|
|
341
|
+
auto_delete (`Optional[int]`):
|
|
342
|
+
If set, the message will be automatically deleted after the specified number of seconds.
|
|
343
|
+
|
|
344
|
+
Returns:
|
|
345
|
+
rubigram.types.UMessage: The sent sticker message.
|
|
346
|
+
|
|
347
|
+
Example:
|
|
348
|
+
.. code-block:: python
|
|
349
|
+
|
|
350
|
+
await update.reply_sticker(sticker_id=sticker_id)
|
|
351
|
+
"""
|
|
352
|
+
return await self.client.send_sticker(
|
|
353
|
+
self.chat_id,
|
|
354
|
+
sticker_id,
|
|
355
|
+
chat_keypad,
|
|
356
|
+
inline_keypad,
|
|
357
|
+
chat_keypad_type,
|
|
358
|
+
disable_notification,
|
|
359
|
+
self.message_id,
|
|
360
|
+
auto_delete
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
async def reply_file(
|
|
364
|
+
self,
|
|
365
|
+
file: Union[str, bytes, BinaryIO],
|
|
366
|
+
caption: Optional[str] = None,
|
|
367
|
+
file_name: Optional[str] = None,
|
|
368
|
+
type: Optional[Union[str, rubigram.enums.FileType]] = rubigram.enums.FileType.FILE,
|
|
369
|
+
chat_keypad: Optional[rubigram.types.Keypad] = None,
|
|
370
|
+
inline_keypad: Optional[rubigram.types.Keypad] = None,
|
|
371
|
+
chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
|
|
372
|
+
disable_notification: bool = False,
|
|
373
|
+
parse_mode: Optional[Union[str, rubigram.enums.ParseMode]] = None,
|
|
374
|
+
auto_delete: Optional[int] = None
|
|
375
|
+
) -> rubigram.types.UMessage:
|
|
376
|
+
"""
|
|
377
|
+
**Reply to the current message with a file.**
|
|
378
|
+
|
|
379
|
+
Args:
|
|
380
|
+
file (`Union[str, bytes, BinaryIO]`):
|
|
381
|
+
The file path or binary data to send.
|
|
382
|
+
|
|
383
|
+
caption (`Optional[str]`):
|
|
384
|
+
Caption for the file. Defaults to None.
|
|
385
|
+
|
|
386
|
+
file_name (`Optional[str]`):
|
|
387
|
+
Custom name for the file. Defaults to None.
|
|
388
|
+
|
|
389
|
+
type (`Optional[Union[str, rubigram.enums.FileType]]`):
|
|
390
|
+
Type of the file (File, Document, etc.). Defaults to File.
|
|
391
|
+
|
|
392
|
+
chat_keypad (`Optional[rubigram.types.Keypad]`):
|
|
393
|
+
Keypad to show in chat. Defaults to None.
|
|
394
|
+
|
|
395
|
+
inline_keypad (`Optional[rubigram.types.Keypad]`):
|
|
396
|
+
Inline keypad to show. Defaults to None.
|
|
397
|
+
|
|
398
|
+
chat_keypad_type (`Optional[rubigram.enums.ChatKeypadType]`):
|
|
399
|
+
Type of chat keypad. Defaults to None.
|
|
400
|
+
|
|
401
|
+
disable_notification (`bool`):
|
|
402
|
+
If True, disables notification. Defaults to False.
|
|
403
|
+
|
|
404
|
+
auto_delete (`Optional[int]`):
|
|
405
|
+
If set, the message will be automatically deleted after the specified number of seconds.
|
|
406
|
+
|
|
407
|
+
Returns:
|
|
408
|
+
rubigram.types.UMessage: The sent file message.
|
|
409
|
+
|
|
410
|
+
Example:
|
|
411
|
+
.. code-block:: python
|
|
412
|
+
|
|
413
|
+
file = "home/users/rubigram/project/photo.jpg"
|
|
414
|
+
await update.reply_file(
|
|
415
|
+
file=file,
|
|
416
|
+
caption=caption
|
|
417
|
+
)
|
|
418
|
+
|
|
419
|
+
file = "https://rubigram.ir/rubigram.jpg"
|
|
420
|
+
file_name = "photo.jpg"
|
|
421
|
+
await update.reply_file(
|
|
422
|
+
file=file,
|
|
423
|
+
caption=caption,
|
|
424
|
+
file_name=file_name
|
|
425
|
+
)
|
|
426
|
+
"""
|
|
427
|
+
return await self.client.send_file(
|
|
428
|
+
self.chat_id,
|
|
429
|
+
file,
|
|
430
|
+
caption,
|
|
431
|
+
file_name,
|
|
432
|
+
type,
|
|
433
|
+
chat_keypad,
|
|
434
|
+
inline_keypad,
|
|
435
|
+
chat_keypad_type,
|
|
436
|
+
disable_notification,
|
|
437
|
+
self.message_id,
|
|
438
|
+
parse_mode,
|
|
439
|
+
auto_delete
|
|
440
|
+
)
|
|
441
|
+
|
|
442
|
+
async def reply_document(
|
|
443
|
+
self,
|
|
444
|
+
document: Union[str, bytes, BinaryIO],
|
|
445
|
+
caption: Optional[str] = None,
|
|
446
|
+
file_name: Optional[str] = None,
|
|
447
|
+
chat_keypad: Optional[rubigram.types.Keypad] = None,
|
|
448
|
+
inline_keypad: Optional[rubigram.types.Keypad] = None,
|
|
449
|
+
chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
|
|
450
|
+
disable_notification: bool = False,
|
|
451
|
+
parse_mode: Optional[Union[str, rubigram.enums.ParseMode]] = None,
|
|
452
|
+
auto_delete: Optional[int] = None
|
|
453
|
+
) -> rubigram.types.UMessage:
|
|
454
|
+
"""
|
|
455
|
+
**Reply to the current message with a document file.**
|
|
456
|
+
|
|
457
|
+
Args:
|
|
458
|
+
document (`Union[str, bytes, BinaryIO]`):
|
|
459
|
+
The path or bytes of the document to send.
|
|
460
|
+
|
|
461
|
+
caption (`Optional[str]`):
|
|
462
|
+
Text caption for the document. Defaults to None.
|
|
463
|
+
|
|
464
|
+
file_name (`Optional[str]`):
|
|
465
|
+
Custom name for the file. Defaults to None.
|
|
466
|
+
|
|
467
|
+
chat_keypad (`Optional[rubigram.types.Keypad]`):
|
|
468
|
+
Keypad to attach to the chat. Defaults to None.
|
|
469
|
+
|
|
470
|
+
inline_keypad (`Optional[rubigram.types.Keypad]`):
|
|
471
|
+
Keypad to attach inline. Defaults to None.
|
|
472
|
+
|
|
473
|
+
chat_keypad_type (`Optional[rubigram.enums.ChatKeypadType]`):
|
|
474
|
+
Type of chat keypad if applicable. Defaults to None.
|
|
475
|
+
|
|
476
|
+
disable_notification (`bool`):
|
|
477
|
+
If True, disables notification for this message. Defaults to False.
|
|
478
|
+
|
|
479
|
+
auto_delete (`Optional[int]`):
|
|
480
|
+
If set, the message will be automatically deleted after the specified number of seconds.
|
|
481
|
+
|
|
482
|
+
Returns:
|
|
483
|
+
rubigram.types.UMessage: The sent reply message object.
|
|
484
|
+
|
|
485
|
+
Example:
|
|
486
|
+
.. code-block:: python
|
|
487
|
+
|
|
488
|
+
await update.reply_document(
|
|
489
|
+
document=document,
|
|
490
|
+
caption=caption
|
|
491
|
+
)
|
|
492
|
+
"""
|
|
493
|
+
return await self.reply_file(
|
|
494
|
+
document,
|
|
495
|
+
caption,
|
|
496
|
+
file_name,
|
|
497
|
+
rubigram.enums.FileType.FILE,
|
|
498
|
+
chat_keypad,
|
|
499
|
+
inline_keypad,
|
|
500
|
+
chat_keypad_type,
|
|
501
|
+
disable_notification,
|
|
502
|
+
parse_mode,
|
|
503
|
+
auto_delete
|
|
504
|
+
)
|
|
505
|
+
|
|
506
|
+
async def reply_photo(
|
|
507
|
+
self,
|
|
508
|
+
photo: Union[str, bytes, BinaryIO],
|
|
509
|
+
caption: Optional[str] = None,
|
|
510
|
+
file_name: Optional[str] = None,
|
|
511
|
+
chat_keypad: Optional[rubigram.types.Keypad] = None,
|
|
512
|
+
inline_keypad: Optional[rubigram.types.Keypad] = None,
|
|
513
|
+
chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
|
|
514
|
+
disable_notification: bool = False,
|
|
515
|
+
parse_mode: Optional[Union[str, rubigram.enums.ParseMode]] = None,
|
|
516
|
+
auto_delete: Optional[int] = None
|
|
517
|
+
) -> rubigram.types.UMessage:
|
|
518
|
+
"""
|
|
519
|
+
**Reply to the current message with a photo.**
|
|
520
|
+
|
|
521
|
+
Args:
|
|
522
|
+
photo (`Union[str, bytes, BinaryIO]`):
|
|
523
|
+
The path or bytes of the photo to send.
|
|
524
|
+
|
|
525
|
+
caption (`Optional[str]`):
|
|
526
|
+
Text caption for the photo. Defaults to None.
|
|
527
|
+
|
|
528
|
+
file_name (`Optional[str]`):
|
|
529
|
+
Custom name for the file. Defaults to None.
|
|
530
|
+
|
|
531
|
+
chat_keypad (`Optional[rubigram.types.Keypad]`):
|
|
532
|
+
Keypad to attach to the chat. Defaults to None.
|
|
533
|
+
|
|
534
|
+
inline_keypad (`Optional[rubigram.types.Keypad]`):
|
|
535
|
+
Keypad to attach inline. Defaults to None.
|
|
536
|
+
|
|
537
|
+
chat_keypad_type (`Optional[rubigram.enums.ChatKeypadType]`):
|
|
538
|
+
Type of chat keypad if applicable. Defaults to None.
|
|
539
|
+
|
|
540
|
+
disable_notification (`bool`):
|
|
541
|
+
If True, disables notification for this message. Defaults to False.
|
|
542
|
+
|
|
543
|
+
auto_delete (`Optional[int]`):
|
|
544
|
+
If set, the message will be automatically deleted after the specified number of seconds.
|
|
545
|
+
|
|
546
|
+
Returns:
|
|
547
|
+
rubigram.types.UMessage: The sent reply message object.
|
|
548
|
+
|
|
549
|
+
Example:
|
|
550
|
+
.. code-block:: python
|
|
551
|
+
|
|
552
|
+
await update.reply_photo(
|
|
553
|
+
photo=photo,
|
|
554
|
+
caption=caption
|
|
555
|
+
)
|
|
556
|
+
"""
|
|
557
|
+
return await self.reply_file(
|
|
558
|
+
photo,
|
|
559
|
+
caption,
|
|
560
|
+
file_name,
|
|
561
|
+
rubigram.enums.FileType.IMAGE,
|
|
562
|
+
chat_keypad,
|
|
563
|
+
inline_keypad,
|
|
564
|
+
chat_keypad_type,
|
|
565
|
+
disable_notification,
|
|
566
|
+
parse_mode,
|
|
567
|
+
auto_delete
|
|
568
|
+
)
|
|
569
|
+
|
|
570
|
+
async def reply_video(
|
|
571
|
+
self,
|
|
572
|
+
video: Union[str, bytes, BinaryIO],
|
|
573
|
+
caption: Optional[str] = None,
|
|
574
|
+
file_name: Optional[str] = None,
|
|
575
|
+
chat_keypad: Optional[rubigram.types.Keypad] = None,
|
|
576
|
+
inline_keypad: Optional[rubigram.types.Keypad] = None,
|
|
577
|
+
chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
|
|
578
|
+
disable_notification: bool = False,
|
|
579
|
+
parse_mode: Optional[Union[str, rubigram.enums.ParseMode]] = None,
|
|
580
|
+
auto_delete: Optional[int] = None
|
|
581
|
+
) -> rubigram.types.UMessage:
|
|
582
|
+
"""
|
|
583
|
+
**Reply to the current message with a video file.**
|
|
584
|
+
|
|
585
|
+
Args:
|
|
586
|
+
video (`Union[str, bytes, BinaryIO]`):
|
|
587
|
+
The path or bytes of the video to send.
|
|
588
|
+
|
|
589
|
+
caption (`Optional[str]`):
|
|
590
|
+
Text caption for the video. Defaults to None.
|
|
591
|
+
|
|
592
|
+
file_name (`Optional[str]`):
|
|
593
|
+
Custom name for the file. Defaults to None.
|
|
594
|
+
|
|
595
|
+
chat_keypad (`Optional[rubigram.types.Keypad]`):
|
|
596
|
+
Keypad to attach to the chat. Defaults to None.
|
|
597
|
+
|
|
598
|
+
inline_keypad (`Optional[rubigram.types.Keypad]`):
|
|
599
|
+
Keypad to attach inline. Defaults to None.
|
|
600
|
+
|
|
601
|
+
chat_keypad_type (`Optional[rubigram.enums.ChatKeypadType]`):
|
|
602
|
+
Type of chat keypad if applicable. Defaults to None.
|
|
603
|
+
|
|
604
|
+
disable_notification (`bool`):
|
|
605
|
+
If True, disables notification for this message. Defaults to False.
|
|
606
|
+
|
|
607
|
+
auto_delete (`Optional[int]`):
|
|
608
|
+
If set, the message will be automatically deleted after the specified number of seconds.
|
|
609
|
+
|
|
610
|
+
Returns:
|
|
611
|
+
rubigram.types.UMessage: The sent reply message object.
|
|
612
|
+
|
|
613
|
+
Example:
|
|
614
|
+
.. code-block:: python
|
|
615
|
+
|
|
616
|
+
await update.reply_video(
|
|
617
|
+
video=video,
|
|
618
|
+
caption=caption
|
|
619
|
+
)
|
|
620
|
+
"""
|
|
621
|
+
return await self.reply_file(
|
|
622
|
+
video,
|
|
623
|
+
caption,
|
|
624
|
+
file_name,
|
|
625
|
+
rubigram.enums.FileType.VIDEO,
|
|
626
|
+
chat_keypad,
|
|
627
|
+
inline_keypad,
|
|
628
|
+
chat_keypad_type,
|
|
629
|
+
disable_notification,
|
|
630
|
+
parse_mode,
|
|
631
|
+
auto_delete
|
|
632
|
+
)
|
|
633
|
+
|
|
634
|
+
async def reply_gif(
|
|
635
|
+
self,
|
|
636
|
+
gif: Union[str, bytes, BinaryIO],
|
|
637
|
+
caption: Optional[str] = None,
|
|
638
|
+
file_name: Optional[str] = None,
|
|
639
|
+
chat_keypad: Optional[rubigram.types.Keypad] = None,
|
|
640
|
+
inline_keypad: Optional[rubigram.types.Keypad] = None,
|
|
641
|
+
chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
|
|
642
|
+
disable_notification: bool = False,
|
|
643
|
+
parse_mode: Optional[Union[str, rubigram.enums.ParseMode]] = None,
|
|
644
|
+
auto_delete: Optional[int] = None
|
|
645
|
+
) -> rubigram.types.UMessage:
|
|
646
|
+
"""
|
|
647
|
+
**Reply to the current message with a GIF file.**
|
|
648
|
+
|
|
649
|
+
Args:
|
|
650
|
+
gif (`Union[str, bytes, BinaryIO]`):
|
|
651
|
+
The path or bytes of the GIF to send.
|
|
652
|
+
|
|
653
|
+
caption (`Optional[str]`):
|
|
654
|
+
Text caption for the GIF. Defaults to None.
|
|
655
|
+
|
|
656
|
+
file_name (`Optional[str]`):
|
|
657
|
+
Custom name for the file. Defaults to None.
|
|
658
|
+
|
|
659
|
+
chat_keypad (`Optional[rubigram.types.Keypad]`):
|
|
660
|
+
Keypad to attach to the chat. Defaults to None.
|
|
661
|
+
|
|
662
|
+
inline_keypad (`Optional[rubigram.types.Keypad]`):
|
|
663
|
+
Keypad to attach inline. Defaults to None.
|
|
664
|
+
|
|
665
|
+
chat_keypad_type (`Optional[rubigram.enums.ChatKeypadType]`):
|
|
666
|
+
Type of chat keypad if applicable. Defaults to None.
|
|
667
|
+
|
|
668
|
+
disable_notification (`bool`):
|
|
669
|
+
If True, disables notification for this message. Defaults to False.
|
|
670
|
+
|
|
671
|
+
auto_delete (`Optional[int]`):
|
|
672
|
+
If set, the message will be automatically deleted after the specified number of seconds.
|
|
673
|
+
|
|
674
|
+
Returns:
|
|
675
|
+
rubigram.types.UMessage: The sent reply message object.
|
|
676
|
+
|
|
677
|
+
Example:
|
|
678
|
+
.. code-block:: python
|
|
679
|
+
|
|
680
|
+
await update.reply_gif(
|
|
681
|
+
gif=gif,
|
|
682
|
+
caption=caption
|
|
683
|
+
)
|
|
684
|
+
"""
|
|
685
|
+
return await self.reply_file(
|
|
686
|
+
gif,
|
|
687
|
+
caption,
|
|
688
|
+
file_name,
|
|
689
|
+
rubigram.enums.FileType.GIF,
|
|
690
|
+
chat_keypad,
|
|
691
|
+
inline_keypad,
|
|
692
|
+
chat_keypad_type,
|
|
693
|
+
disable_notification,
|
|
694
|
+
parse_mode,
|
|
695
|
+
auto_delete
|
|
696
|
+
)
|
|
697
|
+
|
|
698
|
+
async def reply_music(
|
|
699
|
+
self,
|
|
700
|
+
music: Union[str, bytes, BinaryIO],
|
|
701
|
+
caption: Optional[str] = None,
|
|
702
|
+
file_name: Optional[str] = None,
|
|
703
|
+
chat_keypad: Optional[rubigram.types.Keypad] = None,
|
|
704
|
+
inline_keypad: Optional[rubigram.types.Keypad] = None,
|
|
705
|
+
chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
|
|
706
|
+
disable_notification: bool = False,
|
|
707
|
+
parse_mode: Optional[Union[str, rubigram.enums.ParseMode]] = None,
|
|
708
|
+
auto_delete: Optional[int] = None
|
|
709
|
+
) -> rubigram.types.UMessage:
|
|
710
|
+
"""
|
|
711
|
+
**Reply to the current message with a music/audio file.**
|
|
712
|
+
|
|
713
|
+
Args:
|
|
714
|
+
music (`Union[str, bytes, BinaryIO]`):
|
|
715
|
+
The path or bytes of the music file to send.
|
|
716
|
+
|
|
717
|
+
caption (`Optional[str]`):
|
|
718
|
+
Text caption for the music. Defaults to None.
|
|
719
|
+
|
|
720
|
+
file_name (`Optional[str]`):
|
|
721
|
+
Custom name for the file. Defaults to None.
|
|
722
|
+
|
|
723
|
+
chat_keypad (`Optional[rubigram.types.Keypad]`):
|
|
724
|
+
Keypad to attach to the chat. Defaults to None.
|
|
725
|
+
|
|
726
|
+
inline_keypad (`Optional[rubigram.types.Keypad]`):
|
|
727
|
+
Keypad to attach inline. Defaults to None.
|
|
728
|
+
|
|
729
|
+
chat_keypad_type (`Optional[rubigram.enums.ChatKeypadType]`):
|
|
730
|
+
Type of chat keypad if applicable. Defaults to None.
|
|
731
|
+
|
|
732
|
+
disable_notification (`bool`):
|
|
733
|
+
If True, disables notification for this message. Defaults to False.
|
|
734
|
+
|
|
735
|
+
auto_delete (`Optional[int]`):
|
|
736
|
+
If set, the message will be automatically deleted after the specified number of seconds.
|
|
737
|
+
|
|
738
|
+
Returns:
|
|
739
|
+
rubigram.types.UMessage: The sent reply message object.
|
|
740
|
+
|
|
741
|
+
Example:
|
|
742
|
+
.. code-block:: python
|
|
743
|
+
|
|
744
|
+
await update.reply_music(
|
|
745
|
+
music=music,
|
|
746
|
+
caption=caption
|
|
747
|
+
)
|
|
748
|
+
"""
|
|
749
|
+
return await self.reply_file(
|
|
750
|
+
music,
|
|
751
|
+
caption,
|
|
752
|
+
file_name,
|
|
753
|
+
rubigram.enums.FileType.MUSIC,
|
|
754
|
+
chat_keypad,
|
|
755
|
+
inline_keypad,
|
|
756
|
+
chat_keypad_type,
|
|
757
|
+
disable_notification,
|
|
758
|
+
parse_mode,
|
|
759
|
+
auto_delete
|
|
760
|
+
)
|
|
761
|
+
|
|
762
|
+
async def reply_voice(
|
|
763
|
+
self,
|
|
764
|
+
voice: Union[str, bytes, BinaryIO],
|
|
765
|
+
caption: Optional[str] = None,
|
|
766
|
+
file_name: Optional[str] = None,
|
|
767
|
+
chat_keypad: Optional[rubigram.types.Keypad] = None,
|
|
768
|
+
inline_keypad: Optional[rubigram.types.Keypad] = None,
|
|
769
|
+
chat_keypad_type: Optional[Union[str, rubigram.enums.ChatKeypadType]] = None,
|
|
770
|
+
disable_notification: bool = False,
|
|
771
|
+
parse_mode: Optional[Union[str, rubigram.enums.ParseMode]] = None,
|
|
772
|
+
auto_delete: Optional[int] = None
|
|
773
|
+
) -> rubigram.types.UMessage:
|
|
774
|
+
"""
|
|
775
|
+
**Reply to the current message with a voice note.**
|
|
776
|
+
|
|
777
|
+
Args:
|
|
778
|
+
voice (`Union[str, bytes, BinaryIO]`):
|
|
779
|
+
The path or bytes of the voice file to send.
|
|
780
|
+
|
|
781
|
+
caption (`Optional[str]`):
|
|
782
|
+
Text caption for the voice message. Defaults to None.
|
|
783
|
+
|
|
784
|
+
file_name (`Optional[str]`):
|
|
785
|
+
Custom name for the file. Defaults to None.
|
|
786
|
+
|
|
787
|
+
chat_keypad (`Optional[rubigram.types.Keypad]`):
|
|
788
|
+
Keypad to attach to the chat. Defaults to None.
|
|
789
|
+
|
|
790
|
+
inline_keypad (`Optional[rubigram.types.Keypad]`):
|
|
791
|
+
Keypad to attach inline. Defaults to None.
|
|
792
|
+
|
|
793
|
+
chat_keypad_type (`Optional[rubigram.enums.ChatKeypadType]`):
|
|
794
|
+
Type of chat keypad if applicable. Defaults to None.
|
|
795
|
+
|
|
796
|
+
disable_notification (`bool`):
|
|
797
|
+
If True, disables notification for this message. Defaults to False.
|
|
798
|
+
|
|
799
|
+
auto_delete (`Optional[int]`):
|
|
800
|
+
If set, the message will be automatically deleted after the specified number of seconds.
|
|
801
|
+
|
|
802
|
+
Returns:
|
|
803
|
+
rubigram.types.UMessage: The sent reply message object.
|
|
804
|
+
|
|
805
|
+
Example:
|
|
806
|
+
.. code-block:: python
|
|
807
|
+
|
|
808
|
+
await update.reply_voice(
|
|
809
|
+
voice=voice,
|
|
810
|
+
caption=caption
|
|
811
|
+
)
|
|
812
|
+
"""
|
|
813
|
+
return await self.reply_file(
|
|
814
|
+
voice,
|
|
815
|
+
caption,
|
|
816
|
+
file_name,
|
|
817
|
+
rubigram.enums.FileType.VOICE,
|
|
818
|
+
chat_keypad,
|
|
819
|
+
inline_keypad,
|
|
820
|
+
chat_keypad_type,
|
|
821
|
+
disable_notification,
|
|
822
|
+
parse_mode,
|
|
823
|
+
auto_delete
|
|
824
|
+
)
|
|
825
|
+
|
|
826
|
+
async def download(
|
|
827
|
+
self,
|
|
828
|
+
file_name: Optional[str] = None,
|
|
829
|
+
directory: Optional[str] = None,
|
|
830
|
+
chunk_size: int = 64 * 1024,
|
|
831
|
+
in_memory: bool = False,
|
|
832
|
+
) -> Union[str, BytesIO]:
|
|
833
|
+
"""
|
|
834
|
+
**Download the file attached to the current message.**
|
|
835
|
+
|
|
836
|
+
Args:
|
|
837
|
+
save_as (`str`):
|
|
838
|
+
The name (including path if needed) to save the downloaded file as.
|
|
839
|
+
|
|
840
|
+
Returns:
|
|
841
|
+
str: The path to the downloaded file.
|
|
842
|
+
|
|
843
|
+
Example:
|
|
844
|
+
.. code-block:: python
|
|
845
|
+
|
|
846
|
+
save_as = "download/tmp/photo.jpg"
|
|
847
|
+
await update.download(save_as=save_as)
|
|
848
|
+
"""
|
|
849
|
+
if self.new_message.sticker:
|
|
850
|
+
file = self.new_message.sticker.file
|
|
851
|
+
elif self.new_message.file:
|
|
852
|
+
file = self.new_message.file
|
|
853
|
+
else:
|
|
854
|
+
raise ValueError("The message is not a file or has not file_id")
|
|
855
|
+
return await self.client.download_file(
|
|
856
|
+
file.file_id,
|
|
857
|
+
file.file_name or None,
|
|
858
|
+
directory,
|
|
859
|
+
chunk_size,
|
|
860
|
+
in_memory
|
|
861
|
+
)
|
|
862
|
+
|
|
863
|
+
async def forward(
|
|
864
|
+
self,
|
|
865
|
+
chat_id: str,
|
|
866
|
+
disable_notification: bool = False,
|
|
867
|
+
auto_delete: Optional[int] = None
|
|
868
|
+
) -> rubigram.types.UMessage:
|
|
869
|
+
"""
|
|
870
|
+
**Forward the current message to another chat.**
|
|
871
|
+
|
|
872
|
+
Args:
|
|
873
|
+
chat_id (`str`):
|
|
874
|
+
The target chat ID to forward the message to.
|
|
875
|
+
|
|
876
|
+
disable_notification (`bool`):
|
|
877
|
+
If True, disables notification for the message. Defaults to False.
|
|
878
|
+
|
|
879
|
+
auto_delete (`Optional[int]`):
|
|
880
|
+
If set, the message will be automatically deleted after the specified number of seconds.
|
|
881
|
+
|
|
882
|
+
Returns:
|
|
883
|
+
rubigram.types.UMessage: The forwarded message object in the target chat.
|
|
884
|
+
|
|
885
|
+
Example:
|
|
886
|
+
.. code-block:: python
|
|
887
|
+
|
|
888
|
+
await update.forward(chat_id=chat_id)
|
|
889
|
+
"""
|
|
890
|
+
return await self.client.forward_message(
|
|
891
|
+
self.chat_id,
|
|
892
|
+
self.message_id,
|
|
893
|
+
chat_id,
|
|
894
|
+
disable_notification,
|
|
895
|
+
auto_delete
|
|
896
|
+
)
|
|
897
|
+
|
|
898
|
+
async def delete(self):
|
|
899
|
+
"""
|
|
900
|
+
**Delete this message from the chat.**
|
|
901
|
+
|
|
902
|
+
Sends a request to Rubigram to remove the message identified
|
|
903
|
+
by this object's `message_id` from its associated chat.
|
|
904
|
+
|
|
905
|
+
Example:
|
|
906
|
+
.. code-block:: python
|
|
907
|
+
|
|
908
|
+
message = await client.send_message(
|
|
909
|
+
chat_id=chat_id,
|
|
910
|
+
text=text
|
|
911
|
+
)
|
|
912
|
+
await message.delete()
|
|
913
|
+
|
|
914
|
+
Returns:
|
|
915
|
+
Raises:
|
|
916
|
+
"""
|
|
917
|
+
return await self.client.delete_messages(self.chat_id, self.message_id)
|