telegrinder 0.1.dev159__py3-none-any.whl → 0.1.dev161__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.

Files changed (127) hide show
  1. telegrinder/__init__.py +4 -2
  2. telegrinder/api/__init__.py +0 -0
  3. telegrinder/api/abc.py +5 -0
  4. telegrinder/api/api.py +4 -4
  5. telegrinder/api/error.py +0 -0
  6. telegrinder/api/response.py +0 -0
  7. telegrinder/bot/__init__.py +0 -0
  8. telegrinder/bot/bot.py +0 -0
  9. telegrinder/bot/cute_types/__init__.py +0 -0
  10. telegrinder/bot/cute_types/base.py +0 -0
  11. telegrinder/bot/cute_types/callback_query.py +81 -85
  12. telegrinder/bot/cute_types/inline_query.py +36 -9
  13. telegrinder/bot/cute_types/message.py +524 -568
  14. telegrinder/bot/cute_types/update.py +0 -0
  15. telegrinder/bot/cute_types/utils.py +201 -453
  16. telegrinder/bot/dispatch/__init__.py +0 -0
  17. telegrinder/bot/dispatch/abc.py +0 -0
  18. telegrinder/bot/dispatch/composition.py +0 -0
  19. telegrinder/bot/dispatch/context.py +0 -0
  20. telegrinder/bot/dispatch/dispatch.py +0 -0
  21. telegrinder/bot/dispatch/handler/__init__.py +0 -0
  22. telegrinder/bot/dispatch/handler/abc.py +0 -0
  23. telegrinder/bot/dispatch/handler/func.py +1 -1
  24. telegrinder/bot/dispatch/handler/message_reply.py +0 -0
  25. telegrinder/bot/dispatch/middleware/__init__.py +0 -0
  26. telegrinder/bot/dispatch/middleware/abc.py +0 -0
  27. telegrinder/bot/dispatch/process.py +0 -0
  28. telegrinder/bot/dispatch/return_manager/__init__.py +0 -0
  29. telegrinder/bot/dispatch/return_manager/abc.py +0 -0
  30. telegrinder/bot/dispatch/return_manager/callback_query.py +0 -0
  31. telegrinder/bot/dispatch/return_manager/inline_query.py +0 -0
  32. telegrinder/bot/dispatch/return_manager/message.py +0 -0
  33. telegrinder/bot/dispatch/view/__init__.py +0 -0
  34. telegrinder/bot/dispatch/view/abc.py +20 -16
  35. telegrinder/bot/dispatch/view/box.py +0 -0
  36. telegrinder/bot/dispatch/view/callback_query.py +0 -0
  37. telegrinder/bot/dispatch/view/inline_query.py +0 -0
  38. telegrinder/bot/dispatch/view/message.py +0 -0
  39. telegrinder/bot/dispatch/waiter_machine/__init__.py +0 -0
  40. telegrinder/bot/dispatch/waiter_machine/machine.py +0 -0
  41. telegrinder/bot/dispatch/waiter_machine/middleware.py +0 -0
  42. telegrinder/bot/dispatch/waiter_machine/short_state.py +0 -0
  43. telegrinder/bot/polling/__init__.py +0 -0
  44. telegrinder/bot/polling/abc.py +0 -0
  45. telegrinder/bot/polling/polling.py +7 -11
  46. telegrinder/bot/rules/__init__.py +0 -0
  47. telegrinder/bot/rules/abc.py +1 -1
  48. telegrinder/bot/rules/adapter/__init__.py +0 -0
  49. telegrinder/bot/rules/adapter/abc.py +0 -0
  50. telegrinder/bot/rules/adapter/errors.py +0 -0
  51. telegrinder/bot/rules/adapter/event.py +0 -0
  52. telegrinder/bot/rules/adapter/raw_update.py +0 -0
  53. telegrinder/bot/rules/callback_data.py +3 -11
  54. telegrinder/bot/rules/command.py +0 -0
  55. telegrinder/bot/rules/enum_text.py +0 -0
  56. telegrinder/bot/rules/func.py +0 -0
  57. telegrinder/bot/rules/fuzzy.py +0 -0
  58. telegrinder/bot/rules/inline.py +2 -1
  59. telegrinder/bot/rules/integer.py +0 -0
  60. telegrinder/bot/rules/is_from.py +0 -0
  61. telegrinder/bot/rules/markup.py +3 -1
  62. telegrinder/bot/rules/mention.py +0 -0
  63. telegrinder/bot/rules/message_entities.py +3 -1
  64. telegrinder/bot/rules/regex.py +1 -1
  65. telegrinder/bot/rules/rule_enum.py +0 -0
  66. telegrinder/bot/rules/start.py +0 -0
  67. telegrinder/bot/rules/text.py +0 -0
  68. telegrinder/bot/scenario/__init__.py +2 -2
  69. telegrinder/bot/scenario/abc.py +0 -0
  70. telegrinder/bot/scenario/checkbox.py +9 -13
  71. telegrinder/bot/scenario/choice.py +2 -2
  72. telegrinder/client/__init__.py +0 -0
  73. telegrinder/client/abc.py +0 -0
  74. telegrinder/client/aiohttp.py +0 -0
  75. telegrinder/model.py +35 -36
  76. telegrinder/modules.py +21 -11
  77. telegrinder/msgspec_json.py +0 -0
  78. telegrinder/msgspec_utils.py +2 -2
  79. telegrinder/node/__init__.py +0 -0
  80. telegrinder/node/attachment.py +0 -0
  81. telegrinder/node/base.py +0 -0
  82. telegrinder/node/composer.py +0 -0
  83. telegrinder/node/container.py +0 -0
  84. telegrinder/node/message.py +0 -0
  85. telegrinder/node/rule.py +0 -0
  86. telegrinder/node/source.py +0 -0
  87. telegrinder/node/text.py +0 -0
  88. telegrinder/node/tools/__init__.py +0 -0
  89. telegrinder/node/tools/generator.py +0 -0
  90. telegrinder/node/update.py +0 -0
  91. telegrinder/rules.py +0 -0
  92. telegrinder/tools/__init__.py +2 -3
  93. telegrinder/tools/buttons.py +0 -0
  94. telegrinder/tools/error_handler/__init__.py +2 -0
  95. telegrinder/tools/error_handler/abc.py +5 -1
  96. telegrinder/tools/error_handler/error.py +10 -0
  97. telegrinder/tools/error_handler/error_handler.py +100 -81
  98. telegrinder/tools/formatting/__init__.py +0 -0
  99. telegrinder/tools/formatting/html.py +0 -0
  100. telegrinder/tools/formatting/links.py +0 -0
  101. telegrinder/tools/formatting/spec_html_formats.py +0 -0
  102. telegrinder/tools/global_context/__init__.py +0 -0
  103. telegrinder/tools/global_context/abc.py +0 -0
  104. telegrinder/tools/global_context/global_context.py +65 -67
  105. telegrinder/tools/global_context/telegrinder_ctx.py +0 -0
  106. telegrinder/tools/i18n/__init__.py +0 -0
  107. telegrinder/tools/i18n/base.py +0 -0
  108. telegrinder/tools/i18n/middleware/__init__.py +0 -0
  109. telegrinder/tools/i18n/middleware/base.py +0 -0
  110. telegrinder/tools/i18n/simple.py +0 -0
  111. telegrinder/tools/kb_set/__init__.py +0 -0
  112. telegrinder/tools/kb_set/base.py +0 -0
  113. telegrinder/tools/kb_set/yaml.py +3 -3
  114. telegrinder/tools/keyboard.py +17 -26
  115. telegrinder/tools/loop_wrapper/__init__.py +0 -0
  116. telegrinder/tools/loop_wrapper/abc.py +0 -0
  117. telegrinder/tools/loop_wrapper/loop_wrapper.py +0 -0
  118. telegrinder/tools/magic.py +1 -1
  119. telegrinder/tools/parse_mode.py +0 -0
  120. telegrinder/types/__init__.py +0 -0
  121. telegrinder/types/enums.py +2 -0
  122. telegrinder/types/methods.py +477 -526
  123. telegrinder/types/objects.py +209 -97
  124. {telegrinder-0.1.dev159.dist-info → telegrinder-0.1.dev161.dist-info}/LICENSE +0 -0
  125. {telegrinder-0.1.dev159.dist-info → telegrinder-0.1.dev161.dist-info}/METADATA +9 -8
  126. {telegrinder-0.1.dev159.dist-info → telegrinder-0.1.dev161.dist-info}/RECORD +38 -37
  127. {telegrinder-0.1.dev159.dist-info → telegrinder-0.1.dev161.dist-info}/WHEEL +1 -1
telegrinder/__init__.py CHANGED
@@ -39,6 +39,7 @@ from .client import ABCClient, AiohttpClient
39
39
  from .model import Model
40
40
  from .modules import logger
41
41
  from .tools import (
42
+ ABCErrorHandler,
42
43
  ABCGlobalContext,
43
44
  ABCLoopWrapper,
44
45
  ABCTranslator,
@@ -47,6 +48,7 @@ from .tools import (
47
48
  Button,
48
49
  CtxVar,
49
50
  DelayedTask,
51
+ ErrorHandler,
50
52
  FormatString,
51
53
  GlobalContext,
52
54
  HTMLFormatter,
@@ -62,7 +64,6 @@ from .tools import (
62
64
  SimpleI18n,
63
65
  SimpleTranslator,
64
66
  ctx_var,
65
- keyboard_remove,
66
67
  magic_bundle,
67
68
  )
68
69
 
@@ -76,6 +77,7 @@ __all__ = (
76
77
  "ABCAPI",
77
78
  "ABCClient",
78
79
  "ABCDispatch",
80
+ "ABCErrorHandler",
79
81
  "ABCGlobalContext",
80
82
  "ABCHandler",
81
83
  "ABCLoopWrapper",
@@ -107,6 +109,7 @@ __all__ = (
107
109
  "CtxVar",
108
110
  "DelayedTask",
109
111
  "Dispatch",
112
+ "ErrorHandler",
110
113
  "FormatString",
111
114
  "FuncHandler",
112
115
  "GlobalContext",
@@ -139,7 +142,6 @@ __all__ = (
139
142
  "ViewBox",
140
143
  "WaiterMachine",
141
144
  "ctx_var",
142
- "keyboard_remove",
143
145
  "logger",
144
146
  "magic_bundle",
145
147
  "register_manager",
File without changes
telegrinder/api/abc.py CHANGED
@@ -17,6 +17,9 @@ class Token(str):
17
17
  if token.count(":") != 1 or not token.split(":")[0].isdigit():
18
18
  raise InvalidTokenError("Invalid token, it should look like this '123:ABC'.")
19
19
  return super().__new__(cls, token)
20
+
21
+ def __repr__(self) -> str:
22
+ return f"<Token: {self.bot_id}:{''.join(self.split(':')[-1])[:6]}...>"
20
23
 
21
24
  @classmethod
22
25
  def from_env(
@@ -43,6 +46,7 @@ class ABCAPI(ABC):
43
46
  self,
44
47
  method: str,
45
48
  data: dict[str, typing.Any] | None = None,
49
+ files: dict[str, tuple[str, bytes]] | None = None,
46
50
  ) -> Result[list[typing.Any] | dict[str, typing.Any] | bool, APIError]:
47
51
  pass
48
52
 
@@ -51,6 +55,7 @@ class ABCAPI(ABC):
51
55
  self,
52
56
  method: str,
53
57
  data: dict[str, typing.Any] | None = None,
58
+ files: dict[str, tuple[str, bytes]] | None = None,
54
59
  ) -> Result[msgspec.Raw, APIError]:
55
60
  pass
56
61
 
telegrinder/api/api.py CHANGED
@@ -18,13 +18,13 @@ def compose_data(
18
18
  ) -> typing.Any:
19
19
  converter = DataConverter(files=files)
20
20
  return client.get_form(
21
- data={k: converter.convert(v) for k, v in data.items()},
21
+ data={k: converter(v) for k, v in data.items()},
22
22
  files=converter.files,
23
23
  )
24
24
 
25
25
 
26
26
  class API(ABCAPI, APIMethods):
27
- API_URL: typing.ClassVar[str] = "https://api.telegram.org/"
27
+ API_URL = "https://api.telegram.org/"
28
28
 
29
29
  def __init__(self, token: Token, *, http: ABCClient | None = None) -> None:
30
30
  self.token = token
@@ -32,9 +32,9 @@ class API(ABCAPI, APIMethods):
32
32
  super().__init__(self)
33
33
 
34
34
  def __repr__(self) -> str:
35
- return "<{}: id={}, http={!r}>".format(
35
+ return "<{}: token={!r}, http={!r}>".format(
36
36
  self.__class__.__name__,
37
- self.id,
37
+ self.token,
38
38
  self.http,
39
39
  )
40
40
 
telegrinder/api/error.py CHANGED
File without changes
File without changes
File without changes
telegrinder/bot/bot.py CHANGED
File without changes
File without changes
File without changes
@@ -2,11 +2,11 @@ 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 Nothing, Option, decoder
9
+ from telegrinder.msgspec_utils import Option, decoder
10
10
  from telegrinder.types import (
11
11
  CallbackQuery,
12
12
  InlineKeyboardMarkup,
@@ -23,22 +23,20 @@ from .base import BaseCute, compose_method_params, shortcut
23
23
  from .message import MediaType, MessageCute, ReplyMarkup, execute_method_edit
24
24
 
25
25
 
26
- class CallbackQueryCute(
27
- BaseCute[CallbackQuery], CallbackQuery, kw_only=True, dict=True
28
- ):
26
+ class CallbackQueryCute(BaseCute[CallbackQuery], CallbackQuery, kw_only=True, dict=True):
29
27
  api: ABCAPI
30
28
 
31
29
  @property
32
30
  def from_user(self) -> User:
33
31
  return self.from_
34
-
32
+
35
33
  @property
36
34
  def chat_id(self) -> Option[int]:
37
35
  """Optional. Message from chat ID. This will be present if the message is sent
38
36
  by the bot with the callback button that originated the query."""
39
37
 
40
38
  return self.message.map(lambda m: m.v.chat.id)
41
-
39
+
42
40
  @property
43
41
  def is_topic_message(self) -> Option[bool]:
44
42
  """Optional. True, if the message is a topic message with a name,
@@ -46,22 +44,24 @@ class CallbackQueryCute(
46
44
  by the bot with the callback button that originated the query."""
47
45
 
48
46
  return self.message.map(
49
- lambda m: m.only().map(
50
- lambda m: m.is_topic_message.unwrap_or(False)
51
- ).unwrap_or(False)
47
+ lambda m: m.only()
48
+ .map(lambda m: m.is_topic_message.unwrap_or(False))
49
+ .unwrap_or(False)
52
50
  )
53
-
51
+
54
52
  @property
53
+ @unwrapping
55
54
  def message_thread_id(self) -> Option[int]:
56
55
  """Optional. Unique identifier of the target message thread (for forum supergroups only).
57
56
  This will be present if the message is sent
58
57
  by the bot with the callback button that originated the query."""
59
58
 
60
- return self.message.map(
61
- lambda m: m.only().map(
62
- lambda m: m.message_thread_id,
63
- ).unwrap_or(Nothing)
64
- ).unwrap_or(Nothing)
59
+ return (
60
+ self.message.unwrap()
61
+ .only()
62
+ .map(lambda m: m.message_thread_id.unwrap())
63
+ .cast(Some, Nothing)
64
+ )
65
65
 
66
66
  @property
67
67
  def message_id(self) -> Option[int]:
@@ -71,23 +71,23 @@ class CallbackQueryCute(
71
71
 
72
72
  return self.message.map(lambda m: m.v.message_id)
73
73
 
74
- def decode_callback_data(self, *, strict: bool = True) -> Option[dict[str, typing.Any]]:
74
+ def decode_callback_data(self) -> Option[dict[str, typing.Any]]:
75
75
  if "cached_callback_data" in self.__dict__:
76
76
  return self.__dict__["cached_callback_data"]
77
- data = Nothing
77
+ data = Nothing()
78
78
  with suppress(msgspec.ValidationError):
79
- data = Some(decoder.decode(self.data.unwrap(), strict=strict))
79
+ data = Some(decoder.decode(self.data.unwrap()))
80
80
  self.__dict__["cached_callback_data"] = data
81
81
  return data
82
82
 
83
83
  @shortcut("answer_callback_query")
84
84
  async def answer(
85
85
  self,
86
- text: str | Option[str] = Nothing,
87
- callback_query_id: str | Option[str] = Nothing,
88
- show_alert: bool | Option[bool] = Nothing,
89
- url: str | Option[str] = Nothing,
90
- cache_time: int | Option[int] = Nothing,
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
91
  **other: typing.Any,
92
92
  ) -> Result[bool, APIError]:
93
93
  """Shortcut `API.answer_callback_query()`, see the [documentation](https://core.telegram.org/bots/api#answercallbackquery)
@@ -118,26 +118,24 @@ class CallbackQueryCute(
118
118
  get_params(locals()), self, default_params={("callback_query_id", "id")}
119
119
  )
120
120
  return await self.ctx_api.answer_callback_query(**params)
121
-
121
+
122
122
  @shortcut(
123
123
  "copy_message",
124
124
  custom_params={"reply_parameters", "message_thread_id"},
125
125
  )
126
126
  async def copy(
127
127
  self,
128
- chat_id: int | str | Option[int | str] = Nothing,
129
- from_chat_id: int | str | Option[int | str] = Nothing,
130
- message_id: int | Option[int] = Nothing,
131
- message_thread_id: Option[int] | int = Nothing,
132
- caption: Option[str] | str = Nothing,
133
- parse_mode: Option[str] | str = Nothing,
134
- caption_entities: Option[list[MessageEntity]] | list[MessageEntity] = Nothing,
135
- disable_notification: Option[bool] | bool = Nothing,
136
- protect_content: Option[bool] | bool = Nothing,
137
- reply_parameters: Option[ReplyParameters | dict[str, typing.Any]]
138
- | ReplyParameters
139
- | dict[str, typing.Any] = Nothing,
140
- reply_markup: Option[ReplyMarkup] | ReplyMarkup = Nothing,
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,
141
139
  **other: typing.Any,
142
140
  ) -> Result[MessageId, APIError]:
143
141
  """Shortcut `API.copy_message()`, see the [documentation](https://core.telegram.org/bots/api#copymessage)
@@ -185,9 +183,9 @@ class CallbackQueryCute(
185
183
  @shortcut("delete_message", custom_params={"message_thread_id"})
186
184
  async def delete(
187
185
  self,
188
- chat_id: int | Option[int] = Nothing,
189
- message_id: int | Option[int] = Nothing,
190
- message_thread_id: int | Option[int] = Nothing,
186
+ chat_id: int | None = None,
187
+ message_id: int | None = None,
188
+ message_thread_id: int | None = None,
191
189
  **other: typing.Any,
192
190
  ) -> Result[bool, APIError]:
193
191
  """Shortcut `API.delete_message()`, see the [documentation](https://core.telegram.org/bots/api#deletemessage)
@@ -217,21 +215,19 @@ class CallbackQueryCute(
217
215
  @shortcut(
218
216
  "edit_message_text",
219
217
  executor=execute_method_edit,
220
- custom_params={"message_thread_id", "link_preview_options"}
218
+ custom_params={"message_thread_id", "link_preview_options"},
221
219
  )
222
220
  async def edit_text(
223
221
  self,
224
- text: str | Option[str],
225
- inline_message_id: int | Option[int] = Nothing,
226
- chat_id: Option[int | str] | int | str = Nothing,
227
- message_id: Option[int] | int = Nothing,
228
- message_thread_id: int | Option[int] = Nothing,
229
- parse_mode: str | Option[str] = Nothing,
230
- entities: list[MessageEntity] | Option[list[MessageEntity]] = Nothing,
231
- link_preview_options: Option[LinkPreviewOptions | dict[str, typing.Any]]
232
- | LinkPreviewOptions
233
- | dict[str, typing.Any] = Nothing,
234
- reply_markup: InlineKeyboardMarkup | Option[InlineKeyboardMarkup] = Nothing,
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,
235
231
  **other: typing.Any,
236
232
  ) -> Result[Variative[MessageCute, bool], APIError]:
237
233
  """Shortcut `API.edit_message_text()`, see the [documentation](https://core.telegram.org/bots/api#editmessagetext)
@@ -265,7 +261,7 @@ class CallbackQueryCute(
265
261
  :param reply_markup: A JSON-serialized object for an inline keyboard."""
266
262
 
267
263
  ...
268
-
264
+
269
265
  @shortcut(
270
266
  "edit_message_live_location",
271
267
  executor=execute_method_edit,
@@ -275,14 +271,14 @@ class CallbackQueryCute(
275
271
  self,
276
272
  latitude: float,
277
273
  longitude: float,
278
- inline_message_id: Option[str] | str = Nothing,
279
- message_thread_id: int | Option[int] = Nothing,
280
- chat_id: Option[int | str] | int | str = Nothing,
281
- message_id: Option[int] | int = Nothing,
282
- horizontal_accuracy: Option[float] | float = Nothing,
283
- heading: Option[int] | int = Nothing,
284
- proximity_alert_radius: Option[int] | int = Nothing,
285
- reply_markup: Option[InlineKeyboardMarkup] | InlineKeyboardMarkup = Nothing,
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,
286
282
  **other: typing.Any,
287
283
  ) -> Result[Variative[MessageCute, bool], APIError]:
288
284
  """Shortcut `API.edit_message_live_location()`, see the [documentation](https://core.telegram.org/bots/api#editmessagelivelocation)
@@ -319,7 +315,7 @@ class CallbackQueryCute(
319
315
  :param reply_markup: A JSON-serialized object for a new inline keyboard."""
320
316
 
321
317
  ...
322
-
318
+
323
319
  @shortcut(
324
320
  "edit_message_caption",
325
321
  executor=execute_method_edit,
@@ -327,14 +323,14 @@ class CallbackQueryCute(
327
323
  )
328
324
  async def edit_caption(
329
325
  self,
330
- caption: Option[str] | str,
331
- chat_id: Option[int | str] | int | str = Nothing,
332
- message_id: Option[int] | int = Nothing,
333
- message_thread_id: int | Option[int] = Nothing,
334
- inline_message_id: Option[str] | str = Nothing,
335
- parse_mode: Option[str] | str = Nothing,
336
- caption_entities: Option[list[MessageEntity]] | list[MessageEntity] = Nothing,
337
- reply_markup: Option[InlineKeyboardMarkup] | InlineKeyboardMarkup = Nothing,
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,
338
334
  **other: typing.Any,
339
335
  ) -> Result[Variative[MessageCute, bool], APIError]:
340
336
  """Shortcut `API.edit_message_caption()`, see the [documentation](https://core.telegram.org/bots/api#editmessagecaption)
@@ -381,15 +377,15 @@ class CallbackQueryCute(
381
377
  async def edit_media(
382
378
  self,
383
379
  media: str | InputFile | InputMedia,
384
- type: MediaType | Option[MediaType] = Nothing,
385
- caption: Option[str] | str = Nothing,
386
- parse_mode: Option[str] | str = Nothing,
387
- caption_entities: Option[list[MessageEntity]] | list[MessageEntity] = Nothing,
388
- inline_message_id: Option[str] | str = Nothing,
389
- chat_id: Option[int | str] | int | str = Nothing,
390
- message_id: Option[int] | int = Nothing,
391
- message_thread_id: Option[int] | int = Nothing,
392
- reply_markup: Option[InlineKeyboardMarkup] | InlineKeyboardMarkup = Nothing,
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,
393
389
  **other: typing.Any,
394
390
  ) -> Result[Variative[MessageCute, bool], APIError]:
395
391
  """Shortcut `API.edit_message_media()`, see the [documentation](https://core.telegram.org/bots/api#editmessagemedia)
@@ -438,11 +434,11 @@ class CallbackQueryCute(
438
434
  )
439
435
  async def edit_reply_markup(
440
436
  self,
441
- inline_message_id: Option[str] | str = Nothing,
442
- message_id: Option[int] | int = Nothing,
443
- message_thread_id: Option[int] | int = Nothing,
444
- chat_id: Option[int | str] | int | str = Nothing,
445
- reply_markup: Option[InlineKeyboardMarkup] | InlineKeyboardMarkup = Nothing,
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,
446
442
  **other: typing.Any,
447
443
  ) -> Result[Variative[MessageCute, bool], APIError]:
448
444
  """Shortcut `API.edit_message_reply_markup()`, see the [documentation](https://core.telegram.org/bots/api#editmessagereplymarkup)
@@ -4,7 +4,6 @@ from fntypes.result import Result
4
4
 
5
5
  from telegrinder.api import ABCAPI, APIError
6
6
  from telegrinder.model import get_params
7
- from telegrinder.msgspec_utils import Nothing, Option
8
7
  from telegrinder.types import (
9
8
  InlineQuery,
10
9
  InlineQueryResult,
@@ -12,7 +11,7 @@ from telegrinder.types import (
12
11
  User,
13
12
  )
14
13
 
15
- from .base import BaseCute
14
+ from .base import BaseCute, compose_method_params, shortcut
16
15
 
17
16
 
18
17
  class InlineQueryCute(BaseCute[InlineQuery], InlineQuery, kw_only=True):
@@ -22,19 +21,47 @@ class InlineQueryCute(BaseCute[InlineQuery], InlineQuery, kw_only=True):
22
21
  def from_user(self) -> User:
23
22
  return self.from_
24
23
 
24
+ @shortcut("answer_inline_query", custom_params={"results"})
25
25
  async def answer(
26
26
  self,
27
27
  results: InlineQueryResult | list[InlineQueryResult],
28
- inline_query_id: str | Option[str] = Nothing,
29
- cache_time: int | Option[int] = Nothing,
30
- is_personal: bool | Option[bool] = Nothing,
31
- next_offset: str | Option[str] = Nothing,
32
- button: Option[InlineQueryResultsButton] | InlineQueryResultsButton = Nothing,
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,
33
33
  **other: typing.Any,
34
34
  ) -> Result[bool, APIError]:
35
- params = get_params(locals())
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")},
63
+ )
36
64
  params["results"] = [results] if not isinstance(results, list) else results
37
- params.setdefault("inline_query_id", self.id)
38
65
  return await self.ctx_api.answer_inline_query(**params)
39
66
 
40
67