telegrinder 0.1.dev158__py3-none-any.whl → 0.1.dev160__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 +4 -2
- telegrinder/api/__init__.py +0 -0
- telegrinder/api/abc.py +6 -4
- telegrinder/api/api.py +25 -11
- telegrinder/api/error.py +0 -0
- telegrinder/api/response.py +0 -0
- telegrinder/bot/__init__.py +0 -0
- telegrinder/bot/bot.py +0 -0
- telegrinder/bot/cute_types/__init__.py +0 -0
- telegrinder/bot/cute_types/base.py +100 -9
- telegrinder/bot/cute_types/callback_query.py +426 -37
- telegrinder/bot/cute_types/inline_query.py +44 -17
- telegrinder/bot/cute_types/message.py +2885 -117
- telegrinder/bot/cute_types/update.py +14 -7
- telegrinder/bot/cute_types/utils.py +542 -0
- telegrinder/bot/dispatch/__init__.py +0 -0
- telegrinder/bot/dispatch/abc.py +0 -0
- telegrinder/bot/dispatch/composition.py +0 -0
- telegrinder/bot/dispatch/context.py +0 -0
- telegrinder/bot/dispatch/dispatch.py +0 -0
- telegrinder/bot/dispatch/handler/__init__.py +0 -0
- telegrinder/bot/dispatch/handler/abc.py +0 -0
- telegrinder/bot/dispatch/handler/func.py +1 -1
- telegrinder/bot/dispatch/handler/message_reply.py +0 -0
- telegrinder/bot/dispatch/middleware/__init__.py +0 -0
- telegrinder/bot/dispatch/middleware/abc.py +0 -0
- telegrinder/bot/dispatch/process.py +0 -0
- telegrinder/bot/dispatch/return_manager/__init__.py +0 -0
- telegrinder/bot/dispatch/return_manager/abc.py +0 -0
- telegrinder/bot/dispatch/return_manager/callback_query.py +0 -0
- telegrinder/bot/dispatch/return_manager/inline_query.py +0 -0
- telegrinder/bot/dispatch/return_manager/message.py +0 -0
- telegrinder/bot/dispatch/view/__init__.py +0 -0
- telegrinder/bot/dispatch/view/abc.py +40 -29
- telegrinder/bot/dispatch/view/box.py +0 -0
- telegrinder/bot/dispatch/view/callback_query.py +0 -0
- telegrinder/bot/dispatch/view/inline_query.py +0 -0
- telegrinder/bot/dispatch/view/message.py +0 -0
- telegrinder/bot/dispatch/waiter_machine/__init__.py +0 -0
- telegrinder/bot/dispatch/waiter_machine/machine.py +0 -0
- telegrinder/bot/dispatch/waiter_machine/middleware.py +0 -0
- telegrinder/bot/dispatch/waiter_machine/short_state.py +0 -0
- telegrinder/bot/polling/__init__.py +0 -0
- telegrinder/bot/polling/abc.py +0 -0
- telegrinder/bot/polling/polling.py +7 -11
- telegrinder/bot/rules/__init__.py +0 -0
- telegrinder/bot/rules/abc.py +1 -1
- telegrinder/bot/rules/adapter/__init__.py +0 -0
- telegrinder/bot/rules/adapter/abc.py +0 -0
- telegrinder/bot/rules/adapter/errors.py +0 -0
- telegrinder/bot/rules/adapter/event.py +12 -6
- telegrinder/bot/rules/adapter/raw_update.py +0 -0
- telegrinder/bot/rules/callback_data.py +3 -11
- telegrinder/bot/rules/command.py +0 -0
- telegrinder/bot/rules/enum_text.py +0 -0
- telegrinder/bot/rules/func.py +0 -0
- telegrinder/bot/rules/fuzzy.py +0 -0
- telegrinder/bot/rules/inline.py +2 -1
- telegrinder/bot/rules/integer.py +0 -0
- telegrinder/bot/rules/is_from.py +0 -0
- telegrinder/bot/rules/markup.py +3 -1
- telegrinder/bot/rules/mention.py +0 -0
- telegrinder/bot/rules/message_entities.py +3 -1
- telegrinder/bot/rules/regex.py +1 -1
- telegrinder/bot/rules/rule_enum.py +0 -0
- telegrinder/bot/rules/start.py +0 -0
- telegrinder/bot/rules/text.py +0 -0
- telegrinder/bot/scenario/__init__.py +0 -0
- telegrinder/bot/scenario/abc.py +0 -0
- telegrinder/bot/scenario/checkbox.py +0 -0
- telegrinder/bot/scenario/choice.py +0 -0
- telegrinder/client/__init__.py +2 -2
- telegrinder/client/abc.py +35 -12
- telegrinder/client/aiohttp.py +35 -22
- telegrinder/model.py +70 -23
- telegrinder/modules.py +22 -12
- telegrinder/msgspec_json.py +0 -0
- telegrinder/msgspec_utils.py +30 -10
- telegrinder/node/__init__.py +0 -0
- telegrinder/node/attachment.py +0 -0
- telegrinder/node/base.py +0 -0
- telegrinder/node/composer.py +0 -0
- telegrinder/node/container.py +0 -0
- telegrinder/node/message.py +0 -0
- telegrinder/node/rule.py +0 -0
- telegrinder/node/source.py +0 -0
- telegrinder/node/text.py +0 -0
- telegrinder/node/tools/__init__.py +0 -0
- telegrinder/node/tools/generator.py +0 -0
- telegrinder/node/update.py +0 -0
- telegrinder/rules.py +0 -0
- telegrinder/tools/__init__.py +2 -30
- telegrinder/tools/buttons.py +19 -5
- telegrinder/tools/error_handler/__init__.py +2 -0
- telegrinder/tools/error_handler/abc.py +5 -1
- telegrinder/tools/error_handler/error.py +10 -0
- telegrinder/tools/error_handler/error_handler.py +100 -81
- telegrinder/tools/formatting/__init__.py +0 -0
- telegrinder/tools/formatting/html.py +0 -0
- telegrinder/tools/formatting/links.py +0 -0
- telegrinder/tools/formatting/spec_html_formats.py +0 -0
- telegrinder/tools/global_context/__init__.py +0 -0
- telegrinder/tools/global_context/abc.py +0 -0
- telegrinder/tools/global_context/global_context.py +65 -67
- telegrinder/tools/global_context/telegrinder_ctx.py +0 -0
- telegrinder/tools/i18n/__init__.py +0 -0
- telegrinder/tools/i18n/base.py +0 -0
- telegrinder/tools/i18n/middleware/__init__.py +0 -0
- telegrinder/tools/i18n/middleware/base.py +0 -0
- telegrinder/tools/i18n/simple.py +0 -0
- telegrinder/tools/kb_set/__init__.py +0 -0
- telegrinder/tools/kb_set/base.py +0 -0
- telegrinder/tools/kb_set/yaml.py +3 -3
- telegrinder/tools/keyboard.py +17 -26
- telegrinder/tools/loop_wrapper/__init__.py +0 -0
- telegrinder/tools/loop_wrapper/abc.py +0 -0
- telegrinder/tools/loop_wrapper/loop_wrapper.py +0 -0
- telegrinder/tools/magic.py +1 -1
- telegrinder/tools/parse_mode.py +0 -0
- telegrinder/types/__init__.py +0 -0
- telegrinder/types/enums.py +13 -9
- telegrinder/types/methods.py +783 -673
- telegrinder/types/objects.py +317 -163
- {telegrinder-0.1.dev158.dist-info → telegrinder-0.1.dev160.dist-info}/LICENSE +0 -0
- {telegrinder-0.1.dev158.dist-info → telegrinder-0.1.dev160.dist-info}/METADATA +9 -7
- {telegrinder-0.1.dev158.dist-info → telegrinder-0.1.dev160.dist-info}/RECORD +42 -41
- {telegrinder-0.1.dev158.dist-info → telegrinder-0.1.dev160.dist-info}/WHEEL +1 -1
- telegrinder/tools/inline_query.py +0 -684
|
@@ -2,20 +2,25 @@ import typing
|
|
|
2
2
|
from contextlib import suppress
|
|
3
3
|
|
|
4
4
|
import msgspec
|
|
5
|
-
from fntypes.co import Result, Some, Variative
|
|
5
|
+
from fntypes.co import Nothing, Result, Some, Variative, unwrapping
|
|
6
6
|
|
|
7
7
|
from telegrinder.api import ABCAPI, APIError
|
|
8
8
|
from telegrinder.model import get_params
|
|
9
|
-
from telegrinder.msgspec_utils import
|
|
9
|
+
from telegrinder.msgspec_utils import Option, decoder
|
|
10
10
|
from telegrinder.types import (
|
|
11
11
|
CallbackQuery,
|
|
12
12
|
InlineKeyboardMarkup,
|
|
13
|
-
|
|
13
|
+
InputFile,
|
|
14
|
+
InputMedia,
|
|
15
|
+
LinkPreviewOptions,
|
|
14
16
|
MessageEntity,
|
|
17
|
+
MessageId,
|
|
18
|
+
ReplyParameters,
|
|
15
19
|
User,
|
|
16
20
|
)
|
|
17
21
|
|
|
18
|
-
from .base import BaseCute
|
|
22
|
+
from .base import BaseCute, compose_method_params, shortcut
|
|
23
|
+
from .message import MediaType, MessageCute, ReplyMarkup, execute_method_edit
|
|
19
24
|
|
|
20
25
|
|
|
21
26
|
class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, dict=True):
|
|
@@ -24,55 +29,439 @@ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, di
|
|
|
24
29
|
@property
|
|
25
30
|
def from_user(self) -> User:
|
|
26
31
|
return self.from_
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def chat_id(self) -> Option[int]:
|
|
35
|
+
"""Optional. Message from chat ID. This will be present if the message is sent
|
|
36
|
+
by the bot with the callback button that originated the query."""
|
|
37
|
+
|
|
38
|
+
return self.message.map(lambda m: m.v.chat.id)
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def is_topic_message(self) -> Option[bool]:
|
|
42
|
+
"""Optional. True, if the message is a topic message with a name,
|
|
43
|
+
color and icon. This will be present if the message is sent
|
|
44
|
+
by the bot with the callback button that originated the query."""
|
|
45
|
+
|
|
46
|
+
return self.message.map(
|
|
47
|
+
lambda m: m.only()
|
|
48
|
+
.map(lambda m: m.is_topic_message.unwrap_or(False))
|
|
49
|
+
.unwrap_or(False)
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
@unwrapping
|
|
54
|
+
def message_thread_id(self) -> Option[int]:
|
|
55
|
+
"""Optional. Unique identifier of the target message thread (for forum supergroups only).
|
|
56
|
+
This will be present if the message is sent
|
|
57
|
+
by the bot with the callback button that originated the query."""
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
self.message.unwrap()
|
|
61
|
+
.only()
|
|
62
|
+
.map(lambda m: m.message_thread_id.unwrap())
|
|
63
|
+
.cast(Some, Nothing)
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def message_id(self) -> Option[int]:
|
|
68
|
+
"""Optional. Unique message identifier inside this chat. This will be present
|
|
69
|
+
if the message is sent by the bot with the callback button that originated the query.
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
return self.message.map(lambda m: m.v.message_id)
|
|
73
|
+
|
|
74
|
+
def decode_callback_data(self) -> Option[dict[str, typing.Any]]:
|
|
29
75
|
if "cached_callback_data" in self.__dict__:
|
|
30
76
|
return self.__dict__["cached_callback_data"]
|
|
31
|
-
|
|
32
|
-
data = Nothing
|
|
77
|
+
data = Nothing()
|
|
33
78
|
with suppress(msgspec.ValidationError):
|
|
34
79
|
data = Some(decoder.decode(self.data.unwrap()))
|
|
35
|
-
|
|
36
80
|
self.__dict__["cached_callback_data"] = data
|
|
37
81
|
return data
|
|
38
82
|
|
|
83
|
+
@shortcut("answer_callback_query")
|
|
39
84
|
async def answer(
|
|
40
85
|
self,
|
|
41
|
-
text: str |
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
86
|
+
text: str | None = None,
|
|
87
|
+
callback_query_id: str | None = None,
|
|
88
|
+
show_alert: bool | None = None,
|
|
89
|
+
url: str | None = None,
|
|
90
|
+
cache_time: int | None = None,
|
|
91
|
+
**other: typing.Any,
|
|
92
|
+
) -> Result[bool, APIError]:
|
|
93
|
+
"""Shortcut `API.answer_callback_query()`, see the [documentation](https://core.telegram.org/bots/api#answercallbackquery)
|
|
94
|
+
|
|
95
|
+
Use this method to send answers to callback queries sent from inline keyboards.
|
|
96
|
+
The answer will be displayed to the user as a notification at the top of the
|
|
97
|
+
chat screen or as an alert. On success, True is returned.
|
|
98
|
+
|
|
99
|
+
:param callback_query_id: Unique identifier for the query to be answered.
|
|
100
|
+
|
|
101
|
+
:param text: Text of the notification. If not specified, nothing will be shown to the \
|
|
102
|
+
user, 0-200 characters.
|
|
103
|
+
|
|
104
|
+
:param show_alert: If True, an alert will be shown by the client instead of a notification at \
|
|
105
|
+
the top of the chat screen. Defaults to false.
|
|
106
|
+
|
|
107
|
+
:param url: URL that will be opened by the user's client. If you have created a Game and \
|
|
108
|
+
accepted the conditions via @BotFather, specify the URL that opens your \
|
|
109
|
+
game - note that this will only work if the query comes from a callback_game \
|
|
110
|
+
button. Otherwise, you may use links like t.me/your_bot?start=XXXX that \
|
|
111
|
+
open your bot with a parameter.
|
|
112
|
+
|
|
113
|
+
:param cache_time: The maximum amount of time in seconds that the result of the callback query \
|
|
114
|
+
may be cached client-side. Telegram apps will support caching starting \
|
|
115
|
+
in version 3.14. Defaults to 0."""
|
|
116
|
+
|
|
117
|
+
params = compose_method_params(
|
|
118
|
+
get_params(locals()), self, default_params={("callback_query_id", "id")}
|
|
119
|
+
)
|
|
120
|
+
return await self.ctx_api.answer_callback_query(**params)
|
|
121
|
+
|
|
122
|
+
@shortcut(
|
|
123
|
+
"copy_message",
|
|
124
|
+
custom_params={"reply_parameters", "message_thread_id"},
|
|
125
|
+
)
|
|
126
|
+
async def copy(
|
|
127
|
+
self,
|
|
128
|
+
chat_id: int | str | None = None,
|
|
129
|
+
from_chat_id: int | str | None = None,
|
|
130
|
+
message_id: int | None = None,
|
|
131
|
+
message_thread_id: int | None = None,
|
|
132
|
+
caption: str | None = None,
|
|
133
|
+
parse_mode: str | None = None,
|
|
134
|
+
caption_entities: list[MessageEntity] | None = None,
|
|
135
|
+
disable_notification: bool | None = None,
|
|
136
|
+
protect_content: bool | None = None,
|
|
137
|
+
reply_parameters: ReplyParameters | dict[str, typing.Any] | None = None,
|
|
138
|
+
reply_markup: ReplyMarkup | None = None,
|
|
139
|
+
**other: typing.Any,
|
|
140
|
+
) -> Result[MessageId, APIError]:
|
|
141
|
+
"""Shortcut `API.copy_message()`, see the [documentation](https://core.telegram.org/bots/api#copymessage)
|
|
142
|
+
|
|
143
|
+
Use this method to copy messages of any kind. Service messages, giveaway
|
|
144
|
+
messages, giveaway winners messages, and invoice messages can't be copied.
|
|
145
|
+
A quiz poll can be copied only if the value of the field correct_option_id
|
|
146
|
+
is known to the bot. The method is analogous to the method forwardMessage,
|
|
147
|
+
but the copied message doesn't have a link to the original message. Returns
|
|
148
|
+
the MessageId of the sent message on success.
|
|
149
|
+
|
|
150
|
+
:param chat_id: Unique identifier for the target chat or username of the target channel \
|
|
151
|
+
(in the format @channelusername).
|
|
152
|
+
|
|
153
|
+
:param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for \
|
|
154
|
+
forum supergroups only.
|
|
155
|
+
|
|
156
|
+
:param from_chat_id: Unique identifier for the chat where the original message was sent (or channel \
|
|
157
|
+
username in the format @channelusername).
|
|
158
|
+
|
|
159
|
+
:param message_id: Message identifier in the chat specified in from_chat_id.
|
|
160
|
+
|
|
161
|
+
:param caption: New caption for media, 0-1024 characters after entities parsing. If not \
|
|
162
|
+
specified, the original caption is kept.
|
|
163
|
+
|
|
164
|
+
:param parse_mode: Mode for parsing entities in the new caption. See formatting options for \
|
|
165
|
+
more details.
|
|
166
|
+
|
|
167
|
+
:param caption_entities: A JSON-serialized list of special entities that appear in the new caption, \
|
|
168
|
+
which can be specified instead of parse_mode.
|
|
169
|
+
|
|
170
|
+
:param disable_notification: Sends the message silently. Users will receive a notification with no sound. \
|
|
171
|
+
|
|
172
|
+
:param protect_content: Protects the contents of the sent message from forwarding and saving.
|
|
173
|
+
|
|
174
|
+
:param reply_parameters: Description of the message to reply to.
|
|
175
|
+
|
|
176
|
+
:param reply_markup: Additional interface options. A JSON-serialized object for an inline \
|
|
177
|
+
keyboard, custom reply keyboard, instructions to remove reply keyboard \
|
|
178
|
+
or to force a reply from the user.
|
|
179
|
+
"""
|
|
180
|
+
|
|
181
|
+
return await MessageCute.copy(self, **get_params(locals())) # type: ignore
|
|
182
|
+
|
|
183
|
+
@shortcut("delete_message", custom_params={"message_thread_id"})
|
|
184
|
+
async def delete(
|
|
185
|
+
self,
|
|
186
|
+
chat_id: int | None = None,
|
|
187
|
+
message_id: int | None = None,
|
|
188
|
+
message_thread_id: int | None = None,
|
|
45
189
|
**other: typing.Any,
|
|
46
190
|
) -> Result[bool, APIError]:
|
|
47
|
-
|
|
48
|
-
|
|
191
|
+
"""Shortcut `API.delete_message()`, see the [documentation](https://core.telegram.org/bots/api#deletemessage)
|
|
192
|
+
|
|
193
|
+
Use this method to delete a message, including service messages, with the
|
|
194
|
+
following limitations: - A message can only be deleted if it was sent less
|
|
195
|
+
than 48 hours ago. - Service messages about a supergroup, channel, or forum
|
|
196
|
+
topic creation can't be deleted. - A dice message in a private chat can only
|
|
197
|
+
be deleted if it was sent more than 24 hours ago. - Bots can delete outgoing
|
|
198
|
+
messages in private chats, groups, and supergroups. - Bots can delete incoming
|
|
199
|
+
messages in private chats. - Bots granted can_post_messages permissions
|
|
200
|
+
can delete outgoing messages in channels. - If the bot is an administrator
|
|
201
|
+
of a group, it can delete any message there. - If the bot has can_delete_messages
|
|
202
|
+
permission in a supergroup or a channel, it can delete any message there.
|
|
203
|
+
Returns True on success.
|
|
204
|
+
|
|
205
|
+
:param chat_id: Unique identifier for the target chat or username of the target channel \
|
|
206
|
+
(in the format @channelusername).
|
|
207
|
+
|
|
208
|
+
:param message_id: Identifier of the message to delete.
|
|
49
209
|
|
|
210
|
+
:param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for \
|
|
211
|
+
forum supergroups only."""
|
|
212
|
+
|
|
213
|
+
return await MessageCute.delete(self, **get_params(locals())) # type: ignore
|
|
214
|
+
|
|
215
|
+
@shortcut(
|
|
216
|
+
"edit_message_text",
|
|
217
|
+
executor=execute_method_edit,
|
|
218
|
+
custom_params={"message_thread_id", "link_preview_options"},
|
|
219
|
+
)
|
|
50
220
|
async def edit_text(
|
|
51
221
|
self,
|
|
52
|
-
text: str |
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
|
58
|
-
=
|
|
222
|
+
text: str | None,
|
|
223
|
+
inline_message_id: int | None = None,
|
|
224
|
+
chat_id: int | str | None = None,
|
|
225
|
+
message_id: int | None = None,
|
|
226
|
+
message_thread_id: int | None = None,
|
|
227
|
+
parse_mode: str | None = None,
|
|
228
|
+
entities: list[MessageEntity] | None = None,
|
|
229
|
+
link_preview_options: LinkPreviewOptions | dict[str, typing.Any] | None = None,
|
|
230
|
+
reply_markup: InlineKeyboardMarkup | None = None,
|
|
59
231
|
**other: typing.Any,
|
|
60
|
-
) -> Result[Variative[
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
232
|
+
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
233
|
+
"""Shortcut `API.edit_message_text()`, see the [documentation](https://core.telegram.org/bots/api#editmessagetext)
|
|
234
|
+
|
|
235
|
+
Use this method to edit text and game messages. On success, if the edited
|
|
236
|
+
message is not an inline message, the edited Message is returned, otherwise
|
|
237
|
+
True is returned.
|
|
238
|
+
|
|
239
|
+
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of the \
|
|
240
|
+
inline message.
|
|
241
|
+
|
|
242
|
+
:param chat_id: Required if inline_message_id is not specified. Unique identifier for \
|
|
243
|
+
the target chat or username of the target channel (in the format @channelusername). \
|
|
244
|
+
|
|
245
|
+
:param message_id: Required if inline_message_id is not specified. Identifier of the message \
|
|
246
|
+
to edit.
|
|
247
|
+
|
|
248
|
+
:param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for \
|
|
249
|
+
forum supergroups only.
|
|
250
|
+
|
|
251
|
+
:param text: New text of the message, 1-4096 characters after entities parsing.
|
|
252
|
+
|
|
253
|
+
:param parse_mode: Mode for parsing entities in the message text. See formatting options for \
|
|
254
|
+
more details.
|
|
255
|
+
|
|
256
|
+
:param entities: A JSON-serialized list of special entities that appear in message text, \
|
|
257
|
+
which can be specified instead of parse_mode.
|
|
258
|
+
|
|
259
|
+
:param link_preview_options: Link preview generation options for the message.
|
|
260
|
+
|
|
261
|
+
:param reply_markup: A JSON-serialized object for an inline keyboard."""
|
|
262
|
+
|
|
263
|
+
...
|
|
264
|
+
|
|
265
|
+
@shortcut(
|
|
266
|
+
"edit_message_live_location",
|
|
267
|
+
executor=execute_method_edit,
|
|
268
|
+
custom_params={"message_thread_id"},
|
|
269
|
+
)
|
|
270
|
+
async def edit_live_location(
|
|
271
|
+
self,
|
|
272
|
+
latitude: float,
|
|
273
|
+
longitude: float,
|
|
274
|
+
inline_message_id: str | None = None,
|
|
275
|
+
message_thread_id: int | None = None,
|
|
276
|
+
chat_id: int | str | None = None,
|
|
277
|
+
message_id: int | None = None,
|
|
278
|
+
horizontal_accuracy: float | None = None,
|
|
279
|
+
heading: int | None = None,
|
|
280
|
+
proximity_alert_radius: int | None = None,
|
|
281
|
+
reply_markup: InlineKeyboardMarkup | None = None,
|
|
282
|
+
**other: typing.Any,
|
|
283
|
+
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
284
|
+
"""Shortcut `API.edit_message_live_location()`, see the [documentation](https://core.telegram.org/bots/api#editmessagelivelocation)
|
|
285
|
+
|
|
286
|
+
Use this method to edit live location messages. A location can be edited
|
|
287
|
+
until its live_period expires or editing is explicitly disabled by a call
|
|
288
|
+
to stopMessageLiveLocation. On success, if the edited message is not an
|
|
289
|
+
inline message, the edited Message is returned, otherwise True is returned.
|
|
290
|
+
|
|
291
|
+
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of the \
|
|
292
|
+
inline message.
|
|
293
|
+
|
|
294
|
+
:param chat_id: Required if inline_message_id is not specified. Unique identifier for \
|
|
295
|
+
the target chat or username of the target channel (in the format @channelusername). \
|
|
296
|
+
|
|
297
|
+
:param message_id: Required if inline_message_id is not specified. Identifier of the message \
|
|
298
|
+
to edit.
|
|
299
|
+
|
|
300
|
+
:param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for \
|
|
301
|
+
forum supergroups only.
|
|
302
|
+
|
|
303
|
+
:param latitude: Latitude of new location.
|
|
304
|
+
|
|
305
|
+
:param longitude: Longitude of new location.
|
|
306
|
+
|
|
307
|
+
:param horizontal_accuracy: The radius of uncertainty for the location, measured in meters; 0-1500. \
|
|
308
|
+
|
|
309
|
+
:param heading: Direction in which the user is moving, in degrees. Must be between 1 and 360 \
|
|
310
|
+
if specified.
|
|
311
|
+
|
|
312
|
+
:param proximity_alert_radius: The maximum distance for proximity alerts about approaching another chat \
|
|
313
|
+
member, in meters. Must be between 1 and 100000 if specified.
|
|
314
|
+
|
|
315
|
+
:param reply_markup: A JSON-serialized object for a new inline keyboard."""
|
|
316
|
+
|
|
317
|
+
...
|
|
318
|
+
|
|
319
|
+
@shortcut(
|
|
320
|
+
"edit_message_caption",
|
|
321
|
+
executor=execute_method_edit,
|
|
322
|
+
custom_params={"message_thread_id"},
|
|
323
|
+
)
|
|
324
|
+
async def edit_caption(
|
|
325
|
+
self,
|
|
326
|
+
caption: str,
|
|
327
|
+
chat_id: int | str | None = None,
|
|
328
|
+
message_id: int | None = None,
|
|
329
|
+
message_thread_id: int | None = None,
|
|
330
|
+
inline_message_id: str | None = None,
|
|
331
|
+
parse_mode: str | None = None,
|
|
332
|
+
caption_entities: list[MessageEntity] | None = None,
|
|
333
|
+
reply_markup: InlineKeyboardMarkup | None = None,
|
|
334
|
+
**other: typing.Any,
|
|
335
|
+
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
336
|
+
"""Shortcut `API.edit_message_caption()`, see the [documentation](https://core.telegram.org/bots/api#editmessagecaption)
|
|
337
|
+
|
|
338
|
+
Use this method to edit captions of messages. On success, if the edited message
|
|
339
|
+
is not an inline message, the edited Message is returned, otherwise True
|
|
340
|
+
is returned.
|
|
341
|
+
|
|
342
|
+
:param chat_id: Required if inline_message_id is not specified. Unique identifier for \
|
|
343
|
+
the target chat or username of the target channel (in the format @channelusername). \
|
|
344
|
+
|
|
345
|
+
:param message_id: Required if inline_message_id is not specified. Identifier of the message \
|
|
346
|
+
to edit.
|
|
347
|
+
|
|
348
|
+
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of the \
|
|
349
|
+
inline message.
|
|
350
|
+
|
|
351
|
+
:param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for \
|
|
352
|
+
forum supergroups only.
|
|
353
|
+
|
|
354
|
+
:param caption: New caption of the message, 0-1024 characters after entities parsing. \
|
|
355
|
+
|
|
356
|
+
:param parse_mode: Mode for parsing entities in the message caption. See formatting options \
|
|
357
|
+
for more details.
|
|
358
|
+
|
|
359
|
+
:param caption_entities: A JSON-serialized list of special entities that appear in the caption, \
|
|
360
|
+
which can be specified instead of parse_mode.
|
|
361
|
+
|
|
362
|
+
:param reply_markup: A JSON-serialized object for an inline keyboard."""
|
|
363
|
+
|
|
364
|
+
...
|
|
365
|
+
|
|
366
|
+
@shortcut(
|
|
367
|
+
"edit_message_media",
|
|
368
|
+
custom_params={
|
|
369
|
+
"media",
|
|
370
|
+
"type",
|
|
371
|
+
"message_thread_id",
|
|
372
|
+
"caption",
|
|
373
|
+
"parse_mode",
|
|
374
|
+
"caption_entities",
|
|
375
|
+
},
|
|
376
|
+
)
|
|
377
|
+
async def edit_media(
|
|
378
|
+
self,
|
|
379
|
+
media: str | InputFile | InputMedia,
|
|
380
|
+
type: MediaType | None = None,
|
|
381
|
+
caption: str | None = None,
|
|
382
|
+
parse_mode: str | None = None,
|
|
383
|
+
caption_entities: list[MessageEntity] | None = None,
|
|
384
|
+
inline_message_id: str | None = None,
|
|
385
|
+
chat_id: int | str | None = None,
|
|
386
|
+
message_id: int | None = None,
|
|
387
|
+
message_thread_id: int | None = None,
|
|
388
|
+
reply_markup: InlineKeyboardMarkup | None = None,
|
|
389
|
+
**other: typing.Any,
|
|
390
|
+
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
391
|
+
"""Shortcut `API.edit_message_media()`, see the [documentation](https://core.telegram.org/bots/api#editmessagemedia)
|
|
392
|
+
|
|
393
|
+
Use this method to edit animation, audio, document, photo, or video messages.
|
|
394
|
+
If a message is part of a message album, then it can be edited only to an audio
|
|
395
|
+
for audio albums, only to a document for document albums and to a photo or
|
|
396
|
+
a video otherwise. When an inline message is edited, a new file can't be uploaded;
|
|
397
|
+
use a previously uploaded file via its file_id or specify a URL. On success,
|
|
398
|
+
if the edited message is not an inline message, the edited Message is returned,
|
|
399
|
+
otherwise True is returned.
|
|
400
|
+
|
|
401
|
+
:param chat_id: Required if inline_message_id is not specified. Unique identifier for \
|
|
402
|
+
the target chat or username of the target channel (in the format @channelusername). \
|
|
403
|
+
|
|
404
|
+
:param message_id: Required if inline_message_id is not specified. Identifier of the message \
|
|
405
|
+
to edit.
|
|
406
|
+
|
|
407
|
+
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of the \
|
|
408
|
+
inline message.
|
|
409
|
+
|
|
410
|
+
:param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for \
|
|
411
|
+
forum supergroups only.
|
|
412
|
+
|
|
413
|
+
:param media: A JSON-serialized object for a new media content of the message.
|
|
414
|
+
|
|
415
|
+
:param caption: Audio caption, 0-1024 characters after entities parsing.
|
|
416
|
+
|
|
417
|
+
:param parse_mode: Mode for parsing entities in the audio caption. See formatting options \
|
|
418
|
+
for more details.
|
|
419
|
+
|
|
420
|
+
:param caption_entities: A JSON-serialized list of special entities that appear in the caption, \
|
|
421
|
+
which can be specified instead of parse_mode.
|
|
71
422
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
423
|
+
:param type: Required if media is not an `str | InputMedia` object. Type of the media, \
|
|
424
|
+
must be one of `photo`, `video`, `animation`, `audio`, `document`.
|
|
425
|
+
|
|
426
|
+
:param reply_markup: A JSON-serialized object for a new inline keyboard."""
|
|
427
|
+
|
|
428
|
+
return await MessageCute.edit_media(self, **get_params(locals())) # type: ignore
|
|
429
|
+
|
|
430
|
+
@shortcut(
|
|
431
|
+
"edit_message_reply_markup",
|
|
432
|
+
executor=execute_method_edit,
|
|
433
|
+
custom_params={"message_thread_id"},
|
|
434
|
+
)
|
|
435
|
+
async def edit_reply_markup(
|
|
436
|
+
self,
|
|
437
|
+
inline_message_id: str | None = None,
|
|
438
|
+
message_id: int | None = None,
|
|
439
|
+
message_thread_id: int | None = None,
|
|
440
|
+
chat_id: int | str | None = None,
|
|
441
|
+
reply_markup: InlineKeyboardMarkup | None = None,
|
|
442
|
+
**other: typing.Any,
|
|
443
|
+
) -> Result[Variative[MessageCute, bool], APIError]:
|
|
444
|
+
"""Shortcut `API.edit_message_reply_markup()`, see the [documentation](https://core.telegram.org/bots/api#editmessagereplymarkup)
|
|
445
|
+
|
|
446
|
+
Use this method to edit only the reply markup of messages. On success, if
|
|
447
|
+
the edited message is not an inline message, the edited Message is returned,
|
|
448
|
+
otherwise True is returned.
|
|
449
|
+
|
|
450
|
+
:param chat_id: Required if inline_message_id is not specified. Unique identifier for \
|
|
451
|
+
the target chat or username of the target channel (in the format @channelusername). \
|
|
452
|
+
|
|
453
|
+
:param message_id: Required if inline_message_id is not specified. Identifier of the message \
|
|
454
|
+
to edit.
|
|
455
|
+
|
|
456
|
+
:param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for \
|
|
457
|
+
forum supergroups only.
|
|
458
|
+
|
|
459
|
+
:param inline_message_id: Required if chat_id and message_id are not specified. Identifier of the \
|
|
460
|
+
inline message.
|
|
461
|
+
|
|
462
|
+
:param reply_markup: A JSON-serialized object for an inline keyboard."""
|
|
463
|
+
|
|
464
|
+
...
|
|
76
465
|
|
|
77
466
|
|
|
78
467
|
__all__ = ("CallbackQueryCute",)
|
|
@@ -3,10 +3,15 @@ import typing
|
|
|
3
3
|
from fntypes.result import Result
|
|
4
4
|
|
|
5
5
|
from telegrinder.api import ABCAPI, APIError
|
|
6
|
-
from telegrinder.
|
|
7
|
-
from telegrinder.types import
|
|
6
|
+
from telegrinder.model import get_params
|
|
7
|
+
from telegrinder.types import (
|
|
8
|
+
InlineQuery,
|
|
9
|
+
InlineQueryResult,
|
|
10
|
+
InlineQueryResultsButton,
|
|
11
|
+
User,
|
|
12
|
+
)
|
|
8
13
|
|
|
9
|
-
from .base import BaseCute
|
|
14
|
+
from .base import BaseCute, compose_method_params, shortcut
|
|
10
15
|
|
|
11
16
|
|
|
12
17
|
class InlineQueryCute(BaseCute[InlineQuery], InlineQuery, kw_only=True):
|
|
@@ -16,26 +21,48 @@ class InlineQueryCute(BaseCute[InlineQuery], InlineQuery, kw_only=True):
|
|
|
16
21
|
def from_user(self) -> User:
|
|
17
22
|
return self.from_
|
|
18
23
|
|
|
24
|
+
@shortcut("answer_inline_query", custom_params={"results"})
|
|
19
25
|
async def answer(
|
|
20
26
|
self,
|
|
21
27
|
results: InlineQueryResult | list[InlineQueryResult],
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
inline_query_id: str | None = None,
|
|
29
|
+
cache_time: int | None = None,
|
|
30
|
+
is_personal: bool | None = None,
|
|
31
|
+
next_offset: str | None = None,
|
|
32
|
+
button: InlineQueryResultsButton | None = None,
|
|
27
33
|
**other: typing.Any,
|
|
28
34
|
) -> Result[bool, APIError]:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
"""Shortcut `API.answer_inline_query()`, see the [documentation](https://core.telegram.org/bots/api#answerinlinequery)
|
|
36
|
+
|
|
37
|
+
Use this method to send answers to an inline query. On success, True is returned.
|
|
38
|
+
No more than 50 results per query are allowed.
|
|
39
|
+
|
|
40
|
+
:param inline_query_id: Unique identifier for the answered query.
|
|
41
|
+
|
|
42
|
+
:param results: A JSON-serialized array of results for the inline query.
|
|
43
|
+
|
|
44
|
+
:param cache_time: The maximum amount of time in seconds that the result of the inline query \
|
|
45
|
+
may be cached on the server. Defaults to 300.
|
|
46
|
+
|
|
47
|
+
:param is_personal: Pass True if results may be cached on the server side only for the user that \
|
|
48
|
+
sent the query. By default, results may be returned to any user who sends \
|
|
49
|
+
the same query.
|
|
50
|
+
|
|
51
|
+
:param next_offset: Pass the offset that a client should send in the next query with the same text \
|
|
52
|
+
to receive more results. Pass an empty string if there are no more results \
|
|
53
|
+
or if you don't support pagination. Offset length can't exceed 64 bytes. \
|
|
54
|
+
|
|
55
|
+
:param button: A JSON-serialized object describing a button to be shown above inline query \
|
|
56
|
+
results.
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
params = compose_method_params(
|
|
60
|
+
get_params(locals()),
|
|
61
|
+
self,
|
|
62
|
+
default_params={("inline_query_id", "id")},
|
|
38
63
|
)
|
|
64
|
+
params["results"] = [results] if not isinstance(results, list) else results
|
|
65
|
+
return await self.ctx_api.answer_inline_query(**params)
|
|
39
66
|
|
|
40
67
|
|
|
41
68
|
__all__ = ("InlineQueryCute",)
|