telegrinder 0.3.0.post2__py3-none-any.whl → 0.3.2__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 telegrinder might be problematic. Click here for more details.
- telegrinder/__init__.py +144 -144
- telegrinder/api/__init__.py +8 -8
- telegrinder/api/api.py +93 -93
- telegrinder/api/error.py +16 -16
- telegrinder/api/response.py +20 -20
- telegrinder/api/token.py +36 -36
- telegrinder/bot/__init__.py +66 -66
- telegrinder/bot/bot.py +76 -76
- telegrinder/bot/cute_types/__init__.py +11 -11
- telegrinder/bot/cute_types/base.py +258 -234
- telegrinder/bot/cute_types/callback_query.py +382 -382
- telegrinder/bot/cute_types/chat_join_request.py +61 -61
- telegrinder/bot/cute_types/chat_member_updated.py +160 -160
- telegrinder/bot/cute_types/inline_query.py +53 -53
- telegrinder/bot/cute_types/message.py +2631 -2631
- telegrinder/bot/cute_types/update.py +75 -75
- telegrinder/bot/cute_types/utils.py +92 -92
- telegrinder/bot/dispatch/__init__.py +55 -55
- telegrinder/bot/dispatch/abc.py +77 -77
- telegrinder/bot/dispatch/context.py +92 -92
- telegrinder/bot/dispatch/dispatch.py +202 -201
- telegrinder/bot/dispatch/handler/__init__.py +13 -13
- telegrinder/bot/dispatch/handler/abc.py +24 -24
- telegrinder/bot/dispatch/handler/audio_reply.py +44 -44
- telegrinder/bot/dispatch/handler/base.py +57 -57
- telegrinder/bot/dispatch/handler/document_reply.py +44 -44
- telegrinder/bot/dispatch/handler/func.py +128 -123
- telegrinder/bot/dispatch/handler/media_group_reply.py +43 -43
- telegrinder/bot/dispatch/handler/message_reply.py +36 -36
- telegrinder/bot/dispatch/handler/photo_reply.py +44 -44
- telegrinder/bot/dispatch/handler/sticker_reply.py +37 -37
- telegrinder/bot/dispatch/handler/video_reply.py +44 -44
- telegrinder/bot/dispatch/middleware/__init__.py +3 -3
- telegrinder/bot/dispatch/middleware/abc.py +16 -16
- telegrinder/bot/dispatch/process.py +132 -132
- telegrinder/bot/dispatch/return_manager/__init__.py +13 -13
- telegrinder/bot/dispatch/return_manager/abc.py +108 -108
- telegrinder/bot/dispatch/return_manager/callback_query.py +20 -20
- telegrinder/bot/dispatch/return_manager/inline_query.py +15 -15
- telegrinder/bot/dispatch/return_manager/message.py +36 -36
- telegrinder/bot/dispatch/view/__init__.py +13 -13
- telegrinder/bot/dispatch/view/abc.py +41 -41
- telegrinder/bot/dispatch/view/base.py +200 -211
- telegrinder/bot/dispatch/view/box.py +129 -129
- telegrinder/bot/dispatch/view/callback_query.py +17 -17
- telegrinder/bot/dispatch/view/chat_join_request.py +16 -16
- telegrinder/bot/dispatch/view/chat_member.py +39 -39
- telegrinder/bot/dispatch/view/inline_query.py +17 -17
- telegrinder/bot/dispatch/view/message.py +44 -44
- telegrinder/bot/dispatch/view/raw.py +114 -118
- telegrinder/bot/dispatch/waiter_machine/__init__.py +17 -17
- telegrinder/bot/dispatch/waiter_machine/actions.py +13 -13
- telegrinder/bot/dispatch/waiter_machine/hasher/__init__.py +8 -8
- telegrinder/bot/dispatch/waiter_machine/hasher/callback.py +57 -57
- telegrinder/bot/dispatch/waiter_machine/hasher/hasher.py +57 -57
- telegrinder/bot/dispatch/waiter_machine/hasher/message.py +53 -53
- telegrinder/bot/dispatch/waiter_machine/hasher/state.py +19 -19
- telegrinder/bot/dispatch/waiter_machine/machine.py +168 -170
- telegrinder/bot/dispatch/waiter_machine/middleware.py +89 -89
- telegrinder/bot/dispatch/waiter_machine/short_state.py +65 -65
- telegrinder/bot/polling/__init__.py +4 -4
- telegrinder/bot/polling/abc.py +25 -25
- telegrinder/bot/polling/polling.py +131 -131
- telegrinder/bot/rules/__init__.py +62 -62
- telegrinder/bot/rules/abc.py +238 -233
- telegrinder/bot/rules/adapter/__init__.py +9 -9
- telegrinder/bot/rules/adapter/abc.py +29 -29
- telegrinder/bot/rules/adapter/errors.py +5 -5
- telegrinder/bot/rules/adapter/event.py +76 -76
- telegrinder/bot/rules/adapter/node.py +48 -48
- telegrinder/bot/rules/adapter/raw_update.py +30 -30
- telegrinder/bot/rules/callback_data.py +171 -171
- telegrinder/bot/rules/chat_join.py +48 -48
- telegrinder/bot/rules/command.py +126 -126
- telegrinder/bot/rules/enum_text.py +36 -33
- telegrinder/bot/rules/func.py +26 -26
- telegrinder/bot/rules/fuzzy.py +24 -24
- telegrinder/bot/rules/inline.py +60 -60
- telegrinder/bot/rules/integer.py +20 -20
- telegrinder/bot/rules/is_from.py +146 -146
- telegrinder/bot/rules/markup.py +43 -43
- telegrinder/bot/rules/mention.py +14 -14
- telegrinder/bot/rules/message.py +17 -17
- telegrinder/bot/rules/message_entities.py +35 -35
- telegrinder/bot/rules/node.py +27 -27
- telegrinder/bot/rules/regex.py +37 -37
- telegrinder/bot/rules/rule_enum.py +72 -72
- telegrinder/bot/rules/start.py +42 -42
- telegrinder/bot/rules/state.py +37 -37
- telegrinder/bot/rules/text.py +33 -33
- telegrinder/bot/rules/update.py +15 -15
- telegrinder/bot/scenario/__init__.py +5 -5
- telegrinder/bot/scenario/abc.py +19 -19
- telegrinder/bot/scenario/checkbox.py +167 -139
- telegrinder/bot/scenario/choice.py +46 -44
- telegrinder/client/__init__.py +4 -4
- telegrinder/client/abc.py +75 -75
- telegrinder/client/aiohttp.py +130 -130
- telegrinder/model.py +244 -244
- telegrinder/modules.py +237 -237
- telegrinder/msgspec_json.py +14 -14
- telegrinder/msgspec_utils.py +410 -410
- telegrinder/node/__init__.py +20 -20
- telegrinder/node/attachment.py +92 -92
- telegrinder/node/base.py +143 -144
- telegrinder/node/callback_query.py +14 -14
- telegrinder/node/command.py +33 -33
- telegrinder/node/composer.py +196 -184
- telegrinder/node/container.py +27 -27
- telegrinder/node/event.py +71 -73
- telegrinder/node/me.py +16 -16
- telegrinder/node/message.py +14 -14
- telegrinder/node/polymorphic.py +48 -52
- telegrinder/node/rule.py +76 -76
- telegrinder/node/scope.py +38 -38
- telegrinder/node/source.py +71 -71
- telegrinder/node/text.py +21 -21
- telegrinder/node/tools/__init__.py +3 -3
- telegrinder/node/tools/generator.py +40 -40
- telegrinder/node/update.py +15 -15
- telegrinder/rules.py +0 -0
- telegrinder/tools/__init__.py +74 -74
- telegrinder/tools/buttons.py +79 -79
- telegrinder/tools/error_handler/__init__.py +7 -7
- telegrinder/tools/error_handler/abc.py +33 -33
- telegrinder/tools/error_handler/error.py +9 -9
- telegrinder/tools/error_handler/error_handler.py +193 -193
- telegrinder/tools/formatting/__init__.py +46 -46
- telegrinder/tools/formatting/html.py +308 -308
- telegrinder/tools/formatting/links.py +33 -33
- telegrinder/tools/formatting/spec_html_formats.py +111 -111
- telegrinder/tools/functional.py +12 -12
- telegrinder/tools/global_context/__init__.py +7 -7
- telegrinder/tools/global_context/abc.py +63 -63
- telegrinder/tools/global_context/global_context.py +412 -412
- telegrinder/tools/global_context/telegrinder_ctx.py +27 -27
- telegrinder/tools/i18n/__init__.py +12 -12
- telegrinder/tools/i18n/abc.py +32 -32
- telegrinder/tools/i18n/middleware/__init__.py +3 -3
- telegrinder/tools/i18n/middleware/abc.py +25 -25
- telegrinder/tools/i18n/simple.py +43 -43
- telegrinder/tools/kb_set/__init__.py +4 -4
- telegrinder/tools/kb_set/base.py +15 -15
- telegrinder/tools/kb_set/yaml.py +63 -63
- telegrinder/tools/keyboard.py +128 -128
- telegrinder/tools/limited_dict.py +37 -37
- telegrinder/tools/loop_wrapper/__init__.py +4 -4
- telegrinder/tools/loop_wrapper/abc.py +15 -15
- telegrinder/tools/loop_wrapper/loop_wrapper.py +216 -216
- telegrinder/tools/magic.py +168 -164
- telegrinder/tools/parse_mode.py +6 -6
- telegrinder/tools/state_storage/__init__.py +4 -4
- telegrinder/tools/state_storage/abc.py +35 -35
- telegrinder/tools/state_storage/memory.py +25 -25
- telegrinder/types/__init__.py +6 -6
- telegrinder/types/enums.py +672 -672
- telegrinder/types/methods.py +4633 -4633
- telegrinder/types/objects.py +6317 -6317
- telegrinder/verification_utils.py +32 -32
- {telegrinder-0.3.0.post2.dist-info → telegrinder-0.3.2.dist-info}/LICENSE +22 -22
- {telegrinder-0.3.0.post2.dist-info → telegrinder-0.3.2.dist-info}/METADATA +1 -1
- telegrinder-0.3.2.dist-info/RECORD +164 -0
- telegrinder-0.3.0.post2.dist-info/RECORD +0 -164
- {telegrinder-0.3.0.post2.dist-info → telegrinder-0.3.2.dist-info}/WHEEL +0 -0
|
@@ -1,382 +1,382 @@
|
|
|
1
|
-
import typing
|
|
2
|
-
from contextlib import suppress
|
|
3
|
-
|
|
4
|
-
import msgspec
|
|
5
|
-
from fntypes.co import Nothing, Result, Some, Variative, unwrapping
|
|
6
|
-
|
|
7
|
-
from telegrinder.api import API, APIError
|
|
8
|
-
from telegrinder.bot.cute_types.base import BaseCute, compose_method_params, shortcut
|
|
9
|
-
from telegrinder.bot.cute_types.message import MediaType, MessageCute, ReplyMarkup, execute_method_edit
|
|
10
|
-
from telegrinder.model import get_params
|
|
11
|
-
from telegrinder.msgspec_utils import Option, decoder
|
|
12
|
-
from telegrinder.types.objects import *
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True):
|
|
16
|
-
api: API
|
|
17
|
-
|
|
18
|
-
message: Option[Variative[MessageCute, InaccessibleMessage]] = Nothing()
|
|
19
|
-
"""Optional. Message sent by the bot with the callback button that originated
|
|
20
|
-
the query."""
|
|
21
|
-
|
|
22
|
-
@property
|
|
23
|
-
def from_user(self) -> User:
|
|
24
|
-
return self.from_
|
|
25
|
-
|
|
26
|
-
@property
|
|
27
|
-
def chat_id(self) -> Option[int]:
|
|
28
|
-
"""Optional. Message from chat ID. This will be present if the message is sent
|
|
29
|
-
by the bot with the callback button that originated the query."""
|
|
30
|
-
|
|
31
|
-
return self.message.map(lambda m: m.v.chat.id)
|
|
32
|
-
|
|
33
|
-
@property
|
|
34
|
-
def is_topic_message(self) -> Option[bool]:
|
|
35
|
-
"""Optional. True, if the message is a topic message with a name,
|
|
36
|
-
color and icon. This will be present if the message is sent
|
|
37
|
-
by the bot with the callback button that originated the query."""
|
|
38
|
-
|
|
39
|
-
return self.message.map(
|
|
40
|
-
lambda m: m.only().map(lambda m: m.is_topic_message.unwrap_or(False)).unwrap_or(False),
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
@property
|
|
44
|
-
@unwrapping
|
|
45
|
-
def message_thread_id(self) -> Option[int]:
|
|
46
|
-
"""Optional. Unique identifier of the target message thread (for forum supergroups only).
|
|
47
|
-
This will be present if the message is sent
|
|
48
|
-
by the bot with the callback button that originated the query."""
|
|
49
|
-
|
|
50
|
-
return self.message.unwrap().only().map(lambda m: m.message_thread_id.unwrap()).cast(Some, Nothing)
|
|
51
|
-
|
|
52
|
-
@property
|
|
53
|
-
def message_id(self) -> Option[int]:
|
|
54
|
-
"""Optional. Unique message identifier inside this chat. This will be present
|
|
55
|
-
if the message is sent by the bot with the callback button that originated the query.
|
|
56
|
-
"""
|
|
57
|
-
|
|
58
|
-
return self.message.map(lambda m: m.v.message_id)
|
|
59
|
-
|
|
60
|
-
@property
|
|
61
|
-
def chat(self) -> Option[Chat]:
|
|
62
|
-
"""Optional. Chat the callback query originated from. This will be present
|
|
63
|
-
if the message is sent by the bot with the callback button that originated the query.
|
|
64
|
-
"""
|
|
65
|
-
|
|
66
|
-
return self.message.map(lambda m: m.v.chat)
|
|
67
|
-
|
|
68
|
-
def decode_callback_data(self) -> Option[dict[str, typing.Any]]:
|
|
69
|
-
if "cached_callback_data" in self.__dict__:
|
|
70
|
-
return self.__dict__["cached_callback_data"]
|
|
71
|
-
data = Nothing()
|
|
72
|
-
with suppress(msgspec.ValidationError, msgspec.DecodeError):
|
|
73
|
-
data = Some(decoder.decode(self.data.unwrap()))
|
|
74
|
-
self.__dict__["cached_callback_data"] = data
|
|
75
|
-
return data
|
|
76
|
-
|
|
77
|
-
@shortcut("answer_callback_query", custom_params={"callback_query_id"})
|
|
78
|
-
async def answer(
|
|
79
|
-
self,
|
|
80
|
-
text: str | None = None,
|
|
81
|
-
callback_query_id: str | None = None,
|
|
82
|
-
show_alert: bool | None = None,
|
|
83
|
-
url: str | None = None,
|
|
84
|
-
cache_time: int | None = None,
|
|
85
|
-
**other: typing.Any,
|
|
86
|
-
) -> Result[bool, APIError]:
|
|
87
|
-
"""Shortcut `API.answer_callback_query()`, see the [documentation](https://core.telegram.org/bots/api#answercallbackquery)
|
|
88
|
-
|
|
89
|
-
Use this method to send answers to callback queries sent from inline keyboards.
|
|
90
|
-
The answer will be displayed to the user as a notification at the top of the
|
|
91
|
-
chat screen or as an alert. On success, True is returned."""
|
|
92
|
-
|
|
93
|
-
params = compose_method_params(
|
|
94
|
-
get_params(locals()), self, default_params={("callback_query_id", "id")}
|
|
95
|
-
)
|
|
96
|
-
return await self.ctx_api.answer_callback_query(**params)
|
|
97
|
-
|
|
98
|
-
@shortcut(
|
|
99
|
-
"copy_message",
|
|
100
|
-
custom_params={
|
|
101
|
-
"reply_parameters",
|
|
102
|
-
"message_thread_id",
|
|
103
|
-
"chat_id",
|
|
104
|
-
"message_id",
|
|
105
|
-
"from_chat_id",
|
|
106
|
-
"reply_markup",
|
|
107
|
-
},
|
|
108
|
-
)
|
|
109
|
-
async def copy(
|
|
110
|
-
self,
|
|
111
|
-
chat_id: int | str | None = None,
|
|
112
|
-
from_chat_id: int | str | None = None,
|
|
113
|
-
message_id: int | None = None,
|
|
114
|
-
message_thread_id: int | None = None,
|
|
115
|
-
caption: str | None = None,
|
|
116
|
-
parse_mode: str | None = None,
|
|
117
|
-
caption_entities: list[MessageEntity] | None = None,
|
|
118
|
-
disable_notification: bool | None = None,
|
|
119
|
-
protect_content: bool | None = None,
|
|
120
|
-
reply_parameters: ReplyParameters | dict[str, typing.Any] | None = None,
|
|
121
|
-
reply_markup: ReplyMarkup | None = None,
|
|
122
|
-
show_caption_above_media: bool | None = None,
|
|
123
|
-
**other: typing.Any,
|
|
124
|
-
) -> Result[MessageId, APIError]:
|
|
125
|
-
"""Shortcut `API.copy_message()`, see the [documentation](https://core.telegram.org/bots/api#copymessage)
|
|
126
|
-
|
|
127
|
-
Use this method to copy messages of any kind. Service messages, paid media
|
|
128
|
-
messages, giveaway messages, giveaway winners messages, and invoice
|
|
129
|
-
messages can't be copied. A quiz poll can be copied only if the value of the
|
|
130
|
-
field correct_option_id is known to the bot. The method is analogous to
|
|
131
|
-
the method forwardMessage, but the copied message doesn't have a link to
|
|
132
|
-
the original message. Returns the MessageId of the sent message on success."""
|
|
133
|
-
|
|
134
|
-
return await MessageCute.copy(self, **get_params(locals())) # type: ignore
|
|
135
|
-
|
|
136
|
-
@shortcut("delete_message", custom_params={"message_thread_id", "chat_id", "message_id"})
|
|
137
|
-
async def delete(
|
|
138
|
-
self,
|
|
139
|
-
chat_id: int | None = None,
|
|
140
|
-
message_id: int | None = None,
|
|
141
|
-
message_thread_id: int | None = None,
|
|
142
|
-
**other: typing.Any,
|
|
143
|
-
) -> Result[bool, APIError]:
|
|
144
|
-
"""Shortcut `API.delete_message()`, see the [documentation](https://core.telegram.org/bots/api#deletemessage)
|
|
145
|
-
|
|
146
|
-
Use this method to delete a message, including service messages, with the
|
|
147
|
-
following limitations: - A message can only be deleted if it was sent less
|
|
148
|
-
than 48 hours ago. - Service messages about a supergroup, channel, or forum
|
|
149
|
-
topic creation can't be deleted. - A dice message in a private chat can only
|
|
150
|
-
be deleted if it was sent more than 24 hours ago. - Bots can delete outgoing
|
|
151
|
-
messages in private chats, groups, and supergroups. - Bots can delete incoming
|
|
152
|
-
messages in private chats. - Bots granted can_post_messages permissions
|
|
153
|
-
can delete outgoing messages in channels. - If the bot is an administrator
|
|
154
|
-
of a group, it can delete any message there. - If the bot has can_delete_messages
|
|
155
|
-
permission in a supergroup or a channel, it can delete any message there.
|
|
156
|
-
Returns True on success."""
|
|
157
|
-
|
|
158
|
-
return await MessageCute.delete(self, **get_params(locals())) # type: ignore
|
|
159
|
-
|
|
160
|
-
@shortcut(
|
|
161
|
-
"edit_message_text",
|
|
162
|
-
executor=execute_method_edit,
|
|
163
|
-
custom_params={"message_thread_id", "link_preview_options"},
|
|
164
|
-
)
|
|
165
|
-
async def edit_text(
|
|
166
|
-
self,
|
|
167
|
-
text: str,
|
|
168
|
-
inline_message_id: str | None = None,
|
|
169
|
-
chat_id: int | str | None = None,
|
|
170
|
-
message_id: int | None = None,
|
|
171
|
-
message_thread_id: int | None = None,
|
|
172
|
-
parse_mode: str | None = None,
|
|
173
|
-
entities: list[MessageEntity] | None = None,
|
|
174
|
-
link_preview_options: LinkPreviewOptions | dict[str, typing.Any] | None = None,
|
|
175
|
-
reply_markup: InlineKeyboardMarkup | None = None,
|
|
176
|
-
business_connection_id: str | None = None,
|
|
177
|
-
**other: typing.Any,
|
|
178
|
-
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
179
|
-
"""Shortcut `API.edit_message_text()`, see the [documentation](https://core.telegram.org/bots/api#editmessagetext)
|
|
180
|
-
|
|
181
|
-
Use this method to edit text and game messages. On success, if the edited
|
|
182
|
-
message is not an inline message, the edited Message is returned, otherwise
|
|
183
|
-
True is returned. Note that business messages that were not sent by the bot
|
|
184
|
-
and do not contain an inline keyboard can only be edited within 48 hours from
|
|
185
|
-
the time they were sent.
|
|
186
|
-
:param business_connection_id: Unique identifier of the business connection on behalf of which the messageto be edited was sent.
|
|
187
|
-
|
|
188
|
-
:param chat_id: Required if inline_message_id is not specified. Unique identifier forthe target chat or username of the target channel (in the format @channelusername).
|
|
189
|
-
:param message_id: Required if inline_message_id is not specified. Identifier of the messageto edit.
|
|
190
|
-
|
|
191
|
-
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of theinline message.
|
|
192
|
-
|
|
193
|
-
:param text: New text of the message, 1-4096 characters after entities parsing.
|
|
194
|
-
|
|
195
|
-
:param parse_mode: Mode for parsing entities in the message text. See formatting options formore details.
|
|
196
|
-
|
|
197
|
-
:param entities: A JSON-serialized list of special entities that appear in message text,which can be specified instead of parse_mode.
|
|
198
|
-
|
|
199
|
-
:param link_preview_options: Link preview generation options for the message.
|
|
200
|
-
|
|
201
|
-
:param reply_markup: A JSON-serialized object for an inline keyboard."""
|
|
202
|
-
|
|
203
|
-
...
|
|
204
|
-
|
|
205
|
-
@shortcut(
|
|
206
|
-
"edit_message_live_location",
|
|
207
|
-
executor=execute_method_edit,
|
|
208
|
-
custom_params={"message_thread_id"},
|
|
209
|
-
)
|
|
210
|
-
async def edit_live_location(
|
|
211
|
-
self,
|
|
212
|
-
latitude: float,
|
|
213
|
-
longitude: float,
|
|
214
|
-
inline_message_id: str | None = None,
|
|
215
|
-
message_thread_id: int | None = None,
|
|
216
|
-
chat_id: int | str | None = None,
|
|
217
|
-
message_id: int | None = None,
|
|
218
|
-
horizontal_accuracy: float | None = None,
|
|
219
|
-
heading: int | None = None,
|
|
220
|
-
proximity_alert_radius: int | None = None,
|
|
221
|
-
reply_markup: InlineKeyboardMarkup | None = None,
|
|
222
|
-
business_connection_id: str | None = None,
|
|
223
|
-
live_period: int | None = None,
|
|
224
|
-
**other: typing.Any,
|
|
225
|
-
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
226
|
-
"""Shortcut `API.edit_message_live_location()`, see the [documentation](https://core.telegram.org/bots/api#editmessagelivelocation)
|
|
227
|
-
|
|
228
|
-
Use this method to edit live location messages. A location can be edited
|
|
229
|
-
until its live_period expires or editing is explicitly disabled by a call
|
|
230
|
-
to stopMessageLiveLocation. On success, if the edited message is not an
|
|
231
|
-
inline message, the edited Message is returned, otherwise True is returned.
|
|
232
|
-
:param business_connection_id: Unique identifier of the business connection on behalf of which the messageto be edited was sent.
|
|
233
|
-
|
|
234
|
-
:param chat_id: Required if inline_message_id is not specified. Unique identifier forthe target chat or username of the target channel (in the format @channelusername).
|
|
235
|
-
:param message_id: Required if inline_message_id is not specified. Identifier of the messageto edit.
|
|
236
|
-
|
|
237
|
-
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of theinline message.
|
|
238
|
-
|
|
239
|
-
:param latitude: Latitude of new location.
|
|
240
|
-
|
|
241
|
-
:param longitude: Longitude of new location.
|
|
242
|
-
|
|
243
|
-
:param live_period: New period in seconds during which the location can be updated, startingfrom the message send date. If 0x7FFFFFFF is specified, then the locationcan be updated forever. Otherwise, the new value must not exceed the currentlive_period by more than a day, and the live location expiration date mustremain within the next 90 days. If not specified, then live_period remainsunchanged.
|
|
244
|
-
|
|
245
|
-
:param horizontal_accuracy: The radius of uncertainty for the location, measured in meters; 0-1500.
|
|
246
|
-
:param heading: Direction in which the user is moving, in degrees. Must be between 1 and 360if specified.
|
|
247
|
-
|
|
248
|
-
:param proximity_alert_radius: The maximum distance for proximity alerts about approaching another chatmember, in meters. Must be between 1 and 100000 if specified.
|
|
249
|
-
|
|
250
|
-
:param reply_markup: A JSON-serialized object for a new inline keyboard."""
|
|
251
|
-
|
|
252
|
-
...
|
|
253
|
-
|
|
254
|
-
@shortcut(
|
|
255
|
-
"edit_message_caption",
|
|
256
|
-
executor=execute_method_edit,
|
|
257
|
-
custom_params={"message_thread_id"},
|
|
258
|
-
)
|
|
259
|
-
async def edit_caption(
|
|
260
|
-
self,
|
|
261
|
-
caption: str | None = None,
|
|
262
|
-
chat_id: int | str | None = None,
|
|
263
|
-
message_id: int | None = None,
|
|
264
|
-
message_thread_id: int | None = None,
|
|
265
|
-
inline_message_id: str | None = None,
|
|
266
|
-
parse_mode: str | None = None,
|
|
267
|
-
caption_entities: list[MessageEntity] | None = None,
|
|
268
|
-
reply_markup: InlineKeyboardMarkup | None = None,
|
|
269
|
-
business_connection_id: str | None = None,
|
|
270
|
-
show_caption_above_media: bool | None = None,
|
|
271
|
-
**other: typing.Any,
|
|
272
|
-
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
273
|
-
"""Shortcut `API.edit_message_caption()`, see the [documentation](https://core.telegram.org/bots/api#editmessagecaption)
|
|
274
|
-
|
|
275
|
-
Use this method to edit captions of messages. On success, if the edited message
|
|
276
|
-
is not an inline message, the edited Message is returned, otherwise True
|
|
277
|
-
is returned. Note that business messages that were not sent by the bot and
|
|
278
|
-
do not contain an inline keyboard can only be edited within 48 hours from
|
|
279
|
-
the time they were sent.
|
|
280
|
-
:param business_connection_id: Unique identifier of the business connection on behalf of which the messageto be edited was sent.
|
|
281
|
-
|
|
282
|
-
:param chat_id: Required if inline_message_id is not specified. Unique identifier forthe target chat or username of the target channel (in the format @channelusername).
|
|
283
|
-
:param message_id: Required if inline_message_id is not specified. Identifier of the messageto edit.
|
|
284
|
-
|
|
285
|
-
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of theinline message.
|
|
286
|
-
|
|
287
|
-
:param caption: New caption of the message, 0-1024 characters after entities parsing.
|
|
288
|
-
:param parse_mode: Mode for parsing entities in the message caption. See formatting optionsfor more details.
|
|
289
|
-
|
|
290
|
-
:param caption_entities: A JSON-serialized list of special entities that appear in the caption,which can be specified instead of parse_mode.
|
|
291
|
-
|
|
292
|
-
:param show_caption_above_media: Pass True, if the caption must be shown above the message media. Supportedonly for animation, photo and video messages.
|
|
293
|
-
|
|
294
|
-
:param reply_markup: A JSON-serialized object for an inline keyboard."""
|
|
295
|
-
|
|
296
|
-
...
|
|
297
|
-
|
|
298
|
-
@shortcut(
|
|
299
|
-
"edit_message_media",
|
|
300
|
-
custom_params={
|
|
301
|
-
"media",
|
|
302
|
-
"type",
|
|
303
|
-
"message_thread_id",
|
|
304
|
-
"caption",
|
|
305
|
-
"parse_mode",
|
|
306
|
-
"caption_entities",
|
|
307
|
-
},
|
|
308
|
-
)
|
|
309
|
-
async def edit_media(
|
|
310
|
-
self,
|
|
311
|
-
media: str | InputFile | InputMedia,
|
|
312
|
-
type: MediaType | None = None,
|
|
313
|
-
caption: str | None = None,
|
|
314
|
-
parse_mode: str | None = None,
|
|
315
|
-
caption_entities: list[MessageEntity] | None = None,
|
|
316
|
-
inline_message_id: str | None = None,
|
|
317
|
-
chat_id: int | str | None = None,
|
|
318
|
-
message_id: int | None = None,
|
|
319
|
-
message_thread_id: int | None = None,
|
|
320
|
-
reply_markup: InlineKeyboardMarkup | None = None,
|
|
321
|
-
business_connection_id: str | None = None,
|
|
322
|
-
**other: typing.Any,
|
|
323
|
-
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
324
|
-
"""Shortcut `API.edit_message_media()`, see the [documentation](https://core.telegram.org/bots/api#editmessagemedia)
|
|
325
|
-
|
|
326
|
-
Use this method to edit animation, audio, document, photo, or video messages.
|
|
327
|
-
If a message is part of a message album, then it can be edited only to an audio
|
|
328
|
-
for audio albums, only to a document for document albums and to a photo or
|
|
329
|
-
a video otherwise. When an inline message is edited, a new file can't be uploaded;
|
|
330
|
-
use a previously uploaded file via its file_id or specify a URL. On success,
|
|
331
|
-
if the edited message is not an inline message, the edited Message is returned,
|
|
332
|
-
otherwise True is returned. Note that business messages that were not sent
|
|
333
|
-
by the bot and do not contain an inline keyboard can only be edited within
|
|
334
|
-
48 hours from the time they were sent.
|
|
335
|
-
:param business_connection_id: Unique identifier of the business connection on behalf of which the messageto be edited was sent.
|
|
336
|
-
|
|
337
|
-
:param chat_id: Required if inline_message_id is not specified. Unique identifier forthe target chat or username of the target channel (in the format @channelusername).
|
|
338
|
-
:param message_id: Required if inline_message_id is not specified. Identifier of the messageto edit.
|
|
339
|
-
|
|
340
|
-
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of theinline message.
|
|
341
|
-
|
|
342
|
-
:param media: A JSON-serialized object for a new media content of the message.
|
|
343
|
-
|
|
344
|
-
:param reply_markup: A JSON-serialized object for a new inline keyboard."""
|
|
345
|
-
|
|
346
|
-
return await MessageCute.edit_media(self, **get_params(locals())) # type: ignore
|
|
347
|
-
|
|
348
|
-
@shortcut(
|
|
349
|
-
"edit_message_reply_markup",
|
|
350
|
-
executor=execute_method_edit,
|
|
351
|
-
custom_params={"message_thread_id"},
|
|
352
|
-
)
|
|
353
|
-
async def edit_reply_markup(
|
|
354
|
-
self,
|
|
355
|
-
inline_message_id: str | None = None,
|
|
356
|
-
message_id: int | None = None,
|
|
357
|
-
message_thread_id: int | None = None,
|
|
358
|
-
chat_id: int | str | None = None,
|
|
359
|
-
reply_markup: InlineKeyboardMarkup | None = None,
|
|
360
|
-
business_connection_id: str | None = None,
|
|
361
|
-
**other: typing.Any,
|
|
362
|
-
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
363
|
-
"""Shortcut `API.edit_message_reply_markup()`, see the [documentation](https://core.telegram.org/bots/api#editmessagereplymarkup)
|
|
364
|
-
|
|
365
|
-
Use this method to edit only the reply markup of messages. On success, if
|
|
366
|
-
the edited message is not an inline message, the edited Message is returned,
|
|
367
|
-
otherwise True is returned. Note that business messages that were not sent
|
|
368
|
-
by the bot and do not contain an inline keyboard can only be edited within
|
|
369
|
-
48 hours from the time they were sent.
|
|
370
|
-
:param business_connection_id: Unique identifier of the business connection on behalf of which the messageto be edited was sent.
|
|
371
|
-
|
|
372
|
-
:param chat_id: Required if inline_message_id is not specified. Unique identifier forthe target chat or username of the target channel (in the format @channelusername).
|
|
373
|
-
:param message_id: Required if inline_message_id is not specified. Identifier of the messageto edit.
|
|
374
|
-
|
|
375
|
-
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of theinline message.
|
|
376
|
-
|
|
377
|
-
:param reply_markup: A JSON-serialized object for an inline keyboard."""
|
|
378
|
-
|
|
379
|
-
...
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
__all__ = ("CallbackQueryCute",)
|
|
1
|
+
import typing
|
|
2
|
+
from contextlib import suppress
|
|
3
|
+
|
|
4
|
+
import msgspec
|
|
5
|
+
from fntypes.co import Nothing, Result, Some, Variative, unwrapping
|
|
6
|
+
|
|
7
|
+
from telegrinder.api import API, APIError
|
|
8
|
+
from telegrinder.bot.cute_types.base import BaseCute, compose_method_params, shortcut
|
|
9
|
+
from telegrinder.bot.cute_types.message import MediaType, MessageCute, ReplyMarkup, execute_method_edit
|
|
10
|
+
from telegrinder.model import get_params
|
|
11
|
+
from telegrinder.msgspec_utils import Option, decoder
|
|
12
|
+
from telegrinder.types.objects import *
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True):
|
|
16
|
+
api: API
|
|
17
|
+
|
|
18
|
+
message: Option[Variative[MessageCute, InaccessibleMessage]] = Nothing()
|
|
19
|
+
"""Optional. Message sent by the bot with the callback button that originated
|
|
20
|
+
the query."""
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def from_user(self) -> User:
|
|
24
|
+
return self.from_
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def chat_id(self) -> Option[int]:
|
|
28
|
+
"""Optional. Message from chat ID. This will be present if the message is sent
|
|
29
|
+
by the bot with the callback button that originated the query."""
|
|
30
|
+
|
|
31
|
+
return self.message.map(lambda m: m.v.chat.id)
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def is_topic_message(self) -> Option[bool]:
|
|
35
|
+
"""Optional. True, if the message is a topic message with a name,
|
|
36
|
+
color and icon. This will be present if the message is sent
|
|
37
|
+
by the bot with the callback button that originated the query."""
|
|
38
|
+
|
|
39
|
+
return self.message.map(
|
|
40
|
+
lambda m: m.only().map(lambda m: m.is_topic_message.unwrap_or(False)).unwrap_or(False),
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
@unwrapping
|
|
45
|
+
def message_thread_id(self) -> Option[int]:
|
|
46
|
+
"""Optional. Unique identifier of the target message thread (for forum supergroups only).
|
|
47
|
+
This will be present if the message is sent
|
|
48
|
+
by the bot with the callback button that originated the query."""
|
|
49
|
+
|
|
50
|
+
return self.message.unwrap().only().map(lambda m: m.message_thread_id.unwrap()).cast(Some, Nothing)
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def message_id(self) -> Option[int]:
|
|
54
|
+
"""Optional. Unique message identifier inside this chat. This will be present
|
|
55
|
+
if the message is sent by the bot with the callback button that originated the query.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
return self.message.map(lambda m: m.v.message_id)
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def chat(self) -> Option[Chat]:
|
|
62
|
+
"""Optional. Chat the callback query originated from. This will be present
|
|
63
|
+
if the message is sent by the bot with the callback button that originated the query.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
return self.message.map(lambda m: m.v.chat)
|
|
67
|
+
|
|
68
|
+
def decode_callback_data(self) -> Option[dict[str, typing.Any]]:
|
|
69
|
+
if "cached_callback_data" in self.__dict__:
|
|
70
|
+
return self.__dict__["cached_callback_data"]
|
|
71
|
+
data = Nothing()
|
|
72
|
+
with suppress(msgspec.ValidationError, msgspec.DecodeError):
|
|
73
|
+
data = Some(decoder.decode(self.data.unwrap()))
|
|
74
|
+
self.__dict__["cached_callback_data"] = data
|
|
75
|
+
return data
|
|
76
|
+
|
|
77
|
+
@shortcut("answer_callback_query", custom_params={"callback_query_id"})
|
|
78
|
+
async def answer(
|
|
79
|
+
self,
|
|
80
|
+
text: str | None = None,
|
|
81
|
+
callback_query_id: str | None = None,
|
|
82
|
+
show_alert: bool | None = None,
|
|
83
|
+
url: str | None = None,
|
|
84
|
+
cache_time: int | None = None,
|
|
85
|
+
**other: typing.Any,
|
|
86
|
+
) -> Result[bool, APIError]:
|
|
87
|
+
"""Shortcut `API.answer_callback_query()`, see the [documentation](https://core.telegram.org/bots/api#answercallbackquery)
|
|
88
|
+
|
|
89
|
+
Use this method to send answers to callback queries sent from inline keyboards.
|
|
90
|
+
The answer will be displayed to the user as a notification at the top of the
|
|
91
|
+
chat screen or as an alert. On success, True is returned."""
|
|
92
|
+
|
|
93
|
+
params = compose_method_params(
|
|
94
|
+
get_params(locals()), self, default_params={("callback_query_id", "id")}
|
|
95
|
+
)
|
|
96
|
+
return await self.ctx_api.answer_callback_query(**params)
|
|
97
|
+
|
|
98
|
+
@shortcut(
|
|
99
|
+
"copy_message",
|
|
100
|
+
custom_params={
|
|
101
|
+
"reply_parameters",
|
|
102
|
+
"message_thread_id",
|
|
103
|
+
"chat_id",
|
|
104
|
+
"message_id",
|
|
105
|
+
"from_chat_id",
|
|
106
|
+
"reply_markup",
|
|
107
|
+
},
|
|
108
|
+
)
|
|
109
|
+
async def copy(
|
|
110
|
+
self,
|
|
111
|
+
chat_id: int | str | None = None,
|
|
112
|
+
from_chat_id: int | str | None = None,
|
|
113
|
+
message_id: int | None = None,
|
|
114
|
+
message_thread_id: int | None = None,
|
|
115
|
+
caption: str | None = None,
|
|
116
|
+
parse_mode: str | None = None,
|
|
117
|
+
caption_entities: list[MessageEntity] | None = None,
|
|
118
|
+
disable_notification: bool | None = None,
|
|
119
|
+
protect_content: bool | None = None,
|
|
120
|
+
reply_parameters: ReplyParameters | dict[str, typing.Any] | None = None,
|
|
121
|
+
reply_markup: ReplyMarkup | None = None,
|
|
122
|
+
show_caption_above_media: bool | None = None,
|
|
123
|
+
**other: typing.Any,
|
|
124
|
+
) -> Result[MessageId, APIError]:
|
|
125
|
+
"""Shortcut `API.copy_message()`, see the [documentation](https://core.telegram.org/bots/api#copymessage)
|
|
126
|
+
|
|
127
|
+
Use this method to copy messages of any kind. Service messages, paid media
|
|
128
|
+
messages, giveaway messages, giveaway winners messages, and invoice
|
|
129
|
+
messages can't be copied. A quiz poll can be copied only if the value of the
|
|
130
|
+
field correct_option_id is known to the bot. The method is analogous to
|
|
131
|
+
the method forwardMessage, but the copied message doesn't have a link to
|
|
132
|
+
the original message. Returns the MessageId of the sent message on success."""
|
|
133
|
+
|
|
134
|
+
return await MessageCute.copy(self, **get_params(locals())) # type: ignore
|
|
135
|
+
|
|
136
|
+
@shortcut("delete_message", custom_params={"message_thread_id", "chat_id", "message_id"})
|
|
137
|
+
async def delete(
|
|
138
|
+
self,
|
|
139
|
+
chat_id: int | None = None,
|
|
140
|
+
message_id: int | None = None,
|
|
141
|
+
message_thread_id: int | None = None,
|
|
142
|
+
**other: typing.Any,
|
|
143
|
+
) -> Result[bool, APIError]:
|
|
144
|
+
"""Shortcut `API.delete_message()`, see the [documentation](https://core.telegram.org/bots/api#deletemessage)
|
|
145
|
+
|
|
146
|
+
Use this method to delete a message, including service messages, with the
|
|
147
|
+
following limitations: - A message can only be deleted if it was sent less
|
|
148
|
+
than 48 hours ago. - Service messages about a supergroup, channel, or forum
|
|
149
|
+
topic creation can't be deleted. - A dice message in a private chat can only
|
|
150
|
+
be deleted if it was sent more than 24 hours ago. - Bots can delete outgoing
|
|
151
|
+
messages in private chats, groups, and supergroups. - Bots can delete incoming
|
|
152
|
+
messages in private chats. - Bots granted can_post_messages permissions
|
|
153
|
+
can delete outgoing messages in channels. - If the bot is an administrator
|
|
154
|
+
of a group, it can delete any message there. - If the bot has can_delete_messages
|
|
155
|
+
permission in a supergroup or a channel, it can delete any message there.
|
|
156
|
+
Returns True on success."""
|
|
157
|
+
|
|
158
|
+
return await MessageCute.delete(self, **get_params(locals())) # type: ignore
|
|
159
|
+
|
|
160
|
+
@shortcut(
|
|
161
|
+
"edit_message_text",
|
|
162
|
+
executor=execute_method_edit,
|
|
163
|
+
custom_params={"message_thread_id", "link_preview_options"},
|
|
164
|
+
)
|
|
165
|
+
async def edit_text(
|
|
166
|
+
self,
|
|
167
|
+
text: str,
|
|
168
|
+
inline_message_id: str | None = None,
|
|
169
|
+
chat_id: int | str | None = None,
|
|
170
|
+
message_id: int | None = None,
|
|
171
|
+
message_thread_id: int | None = None,
|
|
172
|
+
parse_mode: str | None = None,
|
|
173
|
+
entities: list[MessageEntity] | None = None,
|
|
174
|
+
link_preview_options: LinkPreviewOptions | dict[str, typing.Any] | None = None,
|
|
175
|
+
reply_markup: InlineKeyboardMarkup | None = None,
|
|
176
|
+
business_connection_id: str | None = None,
|
|
177
|
+
**other: typing.Any,
|
|
178
|
+
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
179
|
+
"""Shortcut `API.edit_message_text()`, see the [documentation](https://core.telegram.org/bots/api#editmessagetext)
|
|
180
|
+
|
|
181
|
+
Use this method to edit text and game messages. On success, if the edited
|
|
182
|
+
message is not an inline message, the edited Message is returned, otherwise
|
|
183
|
+
True is returned. Note that business messages that were not sent by the bot
|
|
184
|
+
and do not contain an inline keyboard can only be edited within 48 hours from
|
|
185
|
+
the time they were sent.
|
|
186
|
+
:param business_connection_id: Unique identifier of the business connection on behalf of which the messageto be edited was sent.
|
|
187
|
+
|
|
188
|
+
:param chat_id: Required if inline_message_id is not specified. Unique identifier forthe target chat or username of the target channel (in the format @channelusername).
|
|
189
|
+
:param message_id: Required if inline_message_id is not specified. Identifier of the messageto edit.
|
|
190
|
+
|
|
191
|
+
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of theinline message.
|
|
192
|
+
|
|
193
|
+
:param text: New text of the message, 1-4096 characters after entities parsing.
|
|
194
|
+
|
|
195
|
+
:param parse_mode: Mode for parsing entities in the message text. See formatting options formore details.
|
|
196
|
+
|
|
197
|
+
:param entities: A JSON-serialized list of special entities that appear in message text,which can be specified instead of parse_mode.
|
|
198
|
+
|
|
199
|
+
:param link_preview_options: Link preview generation options for the message.
|
|
200
|
+
|
|
201
|
+
:param reply_markup: A JSON-serialized object for an inline keyboard."""
|
|
202
|
+
|
|
203
|
+
...
|
|
204
|
+
|
|
205
|
+
@shortcut(
|
|
206
|
+
"edit_message_live_location",
|
|
207
|
+
executor=execute_method_edit,
|
|
208
|
+
custom_params={"message_thread_id"},
|
|
209
|
+
)
|
|
210
|
+
async def edit_live_location(
|
|
211
|
+
self,
|
|
212
|
+
latitude: float,
|
|
213
|
+
longitude: float,
|
|
214
|
+
inline_message_id: str | None = None,
|
|
215
|
+
message_thread_id: int | None = None,
|
|
216
|
+
chat_id: int | str | None = None,
|
|
217
|
+
message_id: int | None = None,
|
|
218
|
+
horizontal_accuracy: float | None = None,
|
|
219
|
+
heading: int | None = None,
|
|
220
|
+
proximity_alert_radius: int | None = None,
|
|
221
|
+
reply_markup: InlineKeyboardMarkup | None = None,
|
|
222
|
+
business_connection_id: str | None = None,
|
|
223
|
+
live_period: int | None = None,
|
|
224
|
+
**other: typing.Any,
|
|
225
|
+
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
226
|
+
"""Shortcut `API.edit_message_live_location()`, see the [documentation](https://core.telegram.org/bots/api#editmessagelivelocation)
|
|
227
|
+
|
|
228
|
+
Use this method to edit live location messages. A location can be edited
|
|
229
|
+
until its live_period expires or editing is explicitly disabled by a call
|
|
230
|
+
to stopMessageLiveLocation. On success, if the edited message is not an
|
|
231
|
+
inline message, the edited Message is returned, otherwise True is returned.
|
|
232
|
+
:param business_connection_id: Unique identifier of the business connection on behalf of which the messageto be edited was sent.
|
|
233
|
+
|
|
234
|
+
:param chat_id: Required if inline_message_id is not specified. Unique identifier forthe target chat or username of the target channel (in the format @channelusername).
|
|
235
|
+
:param message_id: Required if inline_message_id is not specified. Identifier of the messageto edit.
|
|
236
|
+
|
|
237
|
+
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of theinline message.
|
|
238
|
+
|
|
239
|
+
:param latitude: Latitude of new location.
|
|
240
|
+
|
|
241
|
+
:param longitude: Longitude of new location.
|
|
242
|
+
|
|
243
|
+
:param live_period: New period in seconds during which the location can be updated, startingfrom the message send date. If 0x7FFFFFFF is specified, then the locationcan be updated forever. Otherwise, the new value must not exceed the currentlive_period by more than a day, and the live location expiration date mustremain within the next 90 days. If not specified, then live_period remainsunchanged.
|
|
244
|
+
|
|
245
|
+
:param horizontal_accuracy: The radius of uncertainty for the location, measured in meters; 0-1500.
|
|
246
|
+
:param heading: Direction in which the user is moving, in degrees. Must be between 1 and 360if specified.
|
|
247
|
+
|
|
248
|
+
:param proximity_alert_radius: The maximum distance for proximity alerts about approaching another chatmember, in meters. Must be between 1 and 100000 if specified.
|
|
249
|
+
|
|
250
|
+
:param reply_markup: A JSON-serialized object for a new inline keyboard."""
|
|
251
|
+
|
|
252
|
+
...
|
|
253
|
+
|
|
254
|
+
@shortcut(
|
|
255
|
+
"edit_message_caption",
|
|
256
|
+
executor=execute_method_edit,
|
|
257
|
+
custom_params={"message_thread_id"},
|
|
258
|
+
)
|
|
259
|
+
async def edit_caption(
|
|
260
|
+
self,
|
|
261
|
+
caption: str | None = None,
|
|
262
|
+
chat_id: int | str | None = None,
|
|
263
|
+
message_id: int | None = None,
|
|
264
|
+
message_thread_id: int | None = None,
|
|
265
|
+
inline_message_id: str | None = None,
|
|
266
|
+
parse_mode: str | None = None,
|
|
267
|
+
caption_entities: list[MessageEntity] | None = None,
|
|
268
|
+
reply_markup: InlineKeyboardMarkup | None = None,
|
|
269
|
+
business_connection_id: str | None = None,
|
|
270
|
+
show_caption_above_media: bool | None = None,
|
|
271
|
+
**other: typing.Any,
|
|
272
|
+
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
273
|
+
"""Shortcut `API.edit_message_caption()`, see the [documentation](https://core.telegram.org/bots/api#editmessagecaption)
|
|
274
|
+
|
|
275
|
+
Use this method to edit captions of messages. On success, if the edited message
|
|
276
|
+
is not an inline message, the edited Message is returned, otherwise True
|
|
277
|
+
is returned. Note that business messages that were not sent by the bot and
|
|
278
|
+
do not contain an inline keyboard can only be edited within 48 hours from
|
|
279
|
+
the time they were sent.
|
|
280
|
+
:param business_connection_id: Unique identifier of the business connection on behalf of which the messageto be edited was sent.
|
|
281
|
+
|
|
282
|
+
:param chat_id: Required if inline_message_id is not specified. Unique identifier forthe target chat or username of the target channel (in the format @channelusername).
|
|
283
|
+
:param message_id: Required if inline_message_id is not specified. Identifier of the messageto edit.
|
|
284
|
+
|
|
285
|
+
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of theinline message.
|
|
286
|
+
|
|
287
|
+
:param caption: New caption of the message, 0-1024 characters after entities parsing.
|
|
288
|
+
:param parse_mode: Mode for parsing entities in the message caption. See formatting optionsfor more details.
|
|
289
|
+
|
|
290
|
+
:param caption_entities: A JSON-serialized list of special entities that appear in the caption,which can be specified instead of parse_mode.
|
|
291
|
+
|
|
292
|
+
:param show_caption_above_media: Pass True, if the caption must be shown above the message media. Supportedonly for animation, photo and video messages.
|
|
293
|
+
|
|
294
|
+
:param reply_markup: A JSON-serialized object for an inline keyboard."""
|
|
295
|
+
|
|
296
|
+
...
|
|
297
|
+
|
|
298
|
+
@shortcut(
|
|
299
|
+
"edit_message_media",
|
|
300
|
+
custom_params={
|
|
301
|
+
"media",
|
|
302
|
+
"type",
|
|
303
|
+
"message_thread_id",
|
|
304
|
+
"caption",
|
|
305
|
+
"parse_mode",
|
|
306
|
+
"caption_entities",
|
|
307
|
+
},
|
|
308
|
+
)
|
|
309
|
+
async def edit_media(
|
|
310
|
+
self,
|
|
311
|
+
media: str | InputFile | InputMedia,
|
|
312
|
+
type: MediaType | None = None,
|
|
313
|
+
caption: str | None = None,
|
|
314
|
+
parse_mode: str | None = None,
|
|
315
|
+
caption_entities: list[MessageEntity] | None = None,
|
|
316
|
+
inline_message_id: str | None = None,
|
|
317
|
+
chat_id: int | str | None = None,
|
|
318
|
+
message_id: int | None = None,
|
|
319
|
+
message_thread_id: int | None = None,
|
|
320
|
+
reply_markup: InlineKeyboardMarkup | None = None,
|
|
321
|
+
business_connection_id: str | None = None,
|
|
322
|
+
**other: typing.Any,
|
|
323
|
+
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
324
|
+
"""Shortcut `API.edit_message_media()`, see the [documentation](https://core.telegram.org/bots/api#editmessagemedia)
|
|
325
|
+
|
|
326
|
+
Use this method to edit animation, audio, document, photo, or video messages.
|
|
327
|
+
If a message is part of a message album, then it can be edited only to an audio
|
|
328
|
+
for audio albums, only to a document for document albums and to a photo or
|
|
329
|
+
a video otherwise. When an inline message is edited, a new file can't be uploaded;
|
|
330
|
+
use a previously uploaded file via its file_id or specify a URL. On success,
|
|
331
|
+
if the edited message is not an inline message, the edited Message is returned,
|
|
332
|
+
otherwise True is returned. Note that business messages that were not sent
|
|
333
|
+
by the bot and do not contain an inline keyboard can only be edited within
|
|
334
|
+
48 hours from the time they were sent.
|
|
335
|
+
:param business_connection_id: Unique identifier of the business connection on behalf of which the messageto be edited was sent.
|
|
336
|
+
|
|
337
|
+
:param chat_id: Required if inline_message_id is not specified. Unique identifier forthe target chat or username of the target channel (in the format @channelusername).
|
|
338
|
+
:param message_id: Required if inline_message_id is not specified. Identifier of the messageto edit.
|
|
339
|
+
|
|
340
|
+
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of theinline message.
|
|
341
|
+
|
|
342
|
+
:param media: A JSON-serialized object for a new media content of the message.
|
|
343
|
+
|
|
344
|
+
:param reply_markup: A JSON-serialized object for a new inline keyboard."""
|
|
345
|
+
|
|
346
|
+
return await MessageCute.edit_media(self, **get_params(locals())) # type: ignore
|
|
347
|
+
|
|
348
|
+
@shortcut(
|
|
349
|
+
"edit_message_reply_markup",
|
|
350
|
+
executor=execute_method_edit,
|
|
351
|
+
custom_params={"message_thread_id"},
|
|
352
|
+
)
|
|
353
|
+
async def edit_reply_markup(
|
|
354
|
+
self,
|
|
355
|
+
inline_message_id: str | None = None,
|
|
356
|
+
message_id: int | None = None,
|
|
357
|
+
message_thread_id: int | None = None,
|
|
358
|
+
chat_id: int | str | None = None,
|
|
359
|
+
reply_markup: InlineKeyboardMarkup | None = None,
|
|
360
|
+
business_connection_id: str | None = None,
|
|
361
|
+
**other: typing.Any,
|
|
362
|
+
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
363
|
+
"""Shortcut `API.edit_message_reply_markup()`, see the [documentation](https://core.telegram.org/bots/api#editmessagereplymarkup)
|
|
364
|
+
|
|
365
|
+
Use this method to edit only the reply markup of messages. On success, if
|
|
366
|
+
the edited message is not an inline message, the edited Message is returned,
|
|
367
|
+
otherwise True is returned. Note that business messages that were not sent
|
|
368
|
+
by the bot and do not contain an inline keyboard can only be edited within
|
|
369
|
+
48 hours from the time they were sent.
|
|
370
|
+
:param business_connection_id: Unique identifier of the business connection on behalf of which the messageto be edited was sent.
|
|
371
|
+
|
|
372
|
+
:param chat_id: Required if inline_message_id is not specified. Unique identifier forthe target chat or username of the target channel (in the format @channelusername).
|
|
373
|
+
:param message_id: Required if inline_message_id is not specified. Identifier of the messageto edit.
|
|
374
|
+
|
|
375
|
+
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of theinline message.
|
|
376
|
+
|
|
377
|
+
:param reply_markup: A JSON-serialized object for an inline keyboard."""
|
|
378
|
+
|
|
379
|
+
...
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
__all__ = ("CallbackQueryCute",)
|