mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-06 07:50:32 +00:00
Added codegen configuration for lost shortcuts (#1244)
* Added codegen configuration for lost shortcuts * Rollback inline_message_id * Added changelog
This commit is contained in:
parent
d3bec413db
commit
aea876dfe0
7 changed files with 112 additions and 31 deletions
|
|
@ -144,18 +144,18 @@ copy_to:
|
|||
from_chat_id: self.chat.id
|
||||
message_id: self.message_id
|
||||
|
||||
edit_text:
|
||||
method: editMessageText
|
||||
fill: &message-target
|
||||
chat_id: self.chat.id
|
||||
message_id: self.message_id
|
||||
|
||||
forward:
|
||||
method: forwardMessage
|
||||
fill:
|
||||
from_chat_id: self.chat.id
|
||||
message_id: self.message_id
|
||||
|
||||
edit_text:
|
||||
method: editMessageText
|
||||
fill: &message-target
|
||||
chat_id: self.chat.id if self.chat else None
|
||||
message_id: self.message_id
|
||||
|
||||
edit_media:
|
||||
method: editMessageMedia
|
||||
fill: *message-target
|
||||
|
|
@ -164,6 +164,12 @@ edit_reply_markup:
|
|||
method: editMessageReplyMarkup
|
||||
fill: *message-target
|
||||
|
||||
delete_reply_markup:
|
||||
method: editMessageReplyMarkup
|
||||
fill:
|
||||
<<: *message-target
|
||||
reply_markup: None
|
||||
|
||||
edit_live_location:
|
||||
method: editMessageLiveLocation
|
||||
fill: *message-target
|
||||
|
|
|
|||
4
.butcher/types/PreCheckoutQuery/aliases.yml
Normal file
4
.butcher/types/PreCheckoutQuery/aliases.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
answer:
|
||||
method: answerPreCheckoutQuery
|
||||
fill:
|
||||
pre_checkout_query_id: self.id
|
||||
4
.butcher/types/ShippingQuery/aliases.yml
Normal file
4
.butcher/types/ShippingQuery/aliases.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
answer:
|
||||
method: answerShippingQuery
|
||||
fill:
|
||||
shipping_query_id: self.id
|
||||
5
CHANGES/#1244.bugfix.rst
Normal file
5
CHANGES/#1244.bugfix.rst
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Added codegen configuration for lost shortcuts:
|
||||
|
||||
- ShippingQuery.answer
|
||||
- PreCheckoutQuery.answer
|
||||
- Message.delete_reply_markup
|
||||
|
|
@ -2721,7 +2721,7 @@ class Message(TelegramObject):
|
|||
from aiogram.methods import EditMessageText
|
||||
|
||||
return EditMessageText(
|
||||
chat_id=self.chat.id,
|
||||
chat_id=self.chat.id if self.chat else None,
|
||||
message_id=self.message_id,
|
||||
text=text,
|
||||
inline_message_id=inline_message_id,
|
||||
|
|
@ -2807,7 +2807,7 @@ class Message(TelegramObject):
|
|||
from aiogram.methods import EditMessageMedia
|
||||
|
||||
return EditMessageMedia(
|
||||
chat_id=self.chat.id,
|
||||
chat_id=self.chat.id if self.chat else None,
|
||||
message_id=self.message_id,
|
||||
media=media,
|
||||
inline_message_id=inline_message_id,
|
||||
|
|
@ -2842,15 +2842,45 @@ class Message(TelegramObject):
|
|||
from aiogram.methods import EditMessageReplyMarkup
|
||||
|
||||
return EditMessageReplyMarkup(
|
||||
chat_id=self.chat.id,
|
||||
chat_id=self.chat.id if self.chat else None,
|
||||
message_id=self.message_id,
|
||||
inline_message_id=inline_message_id,
|
||||
reply_markup=reply_markup,
|
||||
**kwargs,
|
||||
).as_(self._bot)
|
||||
|
||||
def delete_reply_markup(self) -> EditMessageReplyMarkup:
|
||||
return self.edit_reply_markup(reply_markup=None)
|
||||
def delete_reply_markup(
|
||||
self,
|
||||
inline_message_id: Optional[str] = None,
|
||||
**kwargs: Any,
|
||||
) -> EditMessageReplyMarkup:
|
||||
"""
|
||||
Shortcut for method :class:`aiogram.methods.edit_message_reply_markup.EditMessageReplyMarkup`
|
||||
will automatically fill method attributes:
|
||||
|
||||
- :code:`chat_id`
|
||||
- :code:`message_id`
|
||||
- :code:`reply_markup`
|
||||
|
||||
Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited :class:`aiogram.types.message.Message` is returned, otherwise :code:`True` is returned.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#editmessagereplymarkup
|
||||
|
||||
:param inline_message_id: Required if *chat_id* and *message_id* are not specified. Identifier of the inline message
|
||||
:return: instance of method :class:`aiogram.methods.edit_message_reply_markup.EditMessageReplyMarkup`
|
||||
"""
|
||||
# DO NOT EDIT MANUALLY!!!
|
||||
# This method was auto-generated via `butcher`
|
||||
|
||||
from aiogram.methods import EditMessageReplyMarkup
|
||||
|
||||
return EditMessageReplyMarkup(
|
||||
chat_id=self.chat.id if self.chat else None,
|
||||
message_id=self.message_id,
|
||||
reply_markup=None,
|
||||
inline_message_id=inline_message_id,
|
||||
**kwargs,
|
||||
).as_(self._bot)
|
||||
|
||||
def edit_live_location(
|
||||
self,
|
||||
|
|
@ -2889,7 +2919,7 @@ class Message(TelegramObject):
|
|||
from aiogram.methods import EditMessageLiveLocation
|
||||
|
||||
return EditMessageLiveLocation(
|
||||
chat_id=self.chat.id,
|
||||
chat_id=self.chat.id if self.chat else None,
|
||||
message_id=self.message_id,
|
||||
latitude=latitude,
|
||||
longitude=longitude,
|
||||
|
|
@ -2928,7 +2958,7 @@ class Message(TelegramObject):
|
|||
from aiogram.methods import StopMessageLiveLocation
|
||||
|
||||
return StopMessageLiveLocation(
|
||||
chat_id=self.chat.id,
|
||||
chat_id=self.chat.id if self.chat else None,
|
||||
message_id=self.message_id,
|
||||
inline_message_id=inline_message_id,
|
||||
reply_markup=reply_markup,
|
||||
|
|
@ -2968,7 +2998,7 @@ class Message(TelegramObject):
|
|||
from aiogram.methods import EditMessageCaption
|
||||
|
||||
return EditMessageCaption(
|
||||
chat_id=self.chat.id,
|
||||
chat_id=self.chat.id if self.chat else None,
|
||||
message_id=self.message_id,
|
||||
inline_message_id=inline_message_id,
|
||||
caption=caption,
|
||||
|
|
@ -3019,7 +3049,7 @@ class Message(TelegramObject):
|
|||
from aiogram.methods import DeleteMessage
|
||||
|
||||
return DeleteMessage(
|
||||
chat_id=self.chat.id,
|
||||
chat_id=self.chat.id if self.chat else None,
|
||||
message_id=self.message_id,
|
||||
**kwargs,
|
||||
).as_(self._bot)
|
||||
|
|
@ -3049,7 +3079,7 @@ class Message(TelegramObject):
|
|||
from aiogram.methods import PinChatMessage
|
||||
|
||||
return PinChatMessage(
|
||||
chat_id=self.chat.id,
|
||||
chat_id=self.chat.id if self.chat else None,
|
||||
message_id=self.message_id,
|
||||
disable_notification=disable_notification,
|
||||
**kwargs,
|
||||
|
|
@ -3078,7 +3108,7 @@ class Message(TelegramObject):
|
|||
from aiogram.methods import UnpinChatMessage
|
||||
|
||||
return UnpinChatMessage(
|
||||
chat_id=self.chat.id,
|
||||
chat_id=self.chat.id if self.chat else None,
|
||||
message_id=self.message_id,
|
||||
**kwargs,
|
||||
).as_(self._bot)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
from typing import TYPE_CHECKING, Optional, Any
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
|
|
@ -34,16 +34,34 @@ class PreCheckoutQuery(TelegramObject):
|
|||
order_info: Optional[OrderInfo] = None
|
||||
"""*Optional*. Order information provided by the user"""
|
||||
|
||||
def answer(self, ok: bool, error_message: Optional[str] = None) -> AnswerPreCheckoutQuery:
|
||||
def answer(
|
||||
self,
|
||||
ok: bool,
|
||||
error_message: Optional[str] = None,
|
||||
**kwargs: Any,
|
||||
) -> AnswerPreCheckoutQuery:
|
||||
"""
|
||||
:param ok:
|
||||
:param error_message:
|
||||
:return:
|
||||
Shortcut for method :class:`aiogram.methods.answer_pre_checkout_query.AnswerPreCheckoutQuery`
|
||||
will automatically fill method attributes:
|
||||
|
||||
- :code:`pre_checkout_query_id`
|
||||
|
||||
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an :class:`aiogram.types.update.Update` with the field *pre_checkout_query*. Use this method to respond to such pre-checkout queries. On success, :code:`True` is returned. **Note:** The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#answerprecheckoutquery
|
||||
|
||||
:param ok: Specify :code:`True` if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use :code:`False` if there are any problems.
|
||||
:param error_message: Required if *ok* is :code:`False`. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user.
|
||||
:return: instance of method :class:`aiogram.methods.answer_pre_checkout_query.AnswerPreCheckoutQuery`
|
||||
"""
|
||||
from ..methods import AnswerPreCheckoutQuery
|
||||
# DO NOT EDIT MANUALLY!!!
|
||||
# This method was auto-generated via `butcher`
|
||||
|
||||
from aiogram.methods import AnswerPreCheckoutQuery
|
||||
|
||||
return AnswerPreCheckoutQuery(
|
||||
pre_checkout_query_id=self.id,
|
||||
ok=ok,
|
||||
error_message=error_message,
|
||||
)
|
||||
**kwargs,
|
||||
).as_(self._bot)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, List, Optional
|
||||
from typing import TYPE_CHECKING, List, Optional, Any
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
|
|
@ -34,18 +34,32 @@ class ShippingQuery(TelegramObject):
|
|||
ok: bool,
|
||||
shipping_options: Optional[List[ShippingOption]] = None,
|
||||
error_message: Optional[str] = None,
|
||||
**kwargs: Any,
|
||||
) -> AnswerShippingQuery:
|
||||
"""
|
||||
:param ok:
|
||||
:param shipping_options:
|
||||
:param error_message:
|
||||
:return:
|
||||
Shortcut for method :class:`aiogram.methods.answer_shipping_query.AnswerShippingQuery`
|
||||
will automatically fill method attributes:
|
||||
|
||||
- :code:`shipping_query_id`
|
||||
|
||||
If you sent an invoice requesting a shipping address and the parameter *is_flexible* was specified, the Bot API will send an :class:`aiogram.types.update.Update` with a *shipping_query* field to the bot. Use this method to reply to shipping queries. On success, :code:`True` is returned.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#answershippingquery
|
||||
|
||||
:param ok: Pass :code:`True` if delivery to the specified address is possible and :code:`False` if there are any problems (for example, if delivery to the specified address is not possible)
|
||||
:param shipping_options: Required if *ok* is :code:`True`. A JSON-serialized array of available shipping options.
|
||||
:param error_message: Required if *ok* is :code:`False`. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user.
|
||||
:return: instance of method :class:`aiogram.methods.answer_shipping_query.AnswerShippingQuery`
|
||||
"""
|
||||
from ..methods import AnswerShippingQuery
|
||||
# DO NOT EDIT MANUALLY!!!
|
||||
# This method was auto-generated via `butcher`
|
||||
|
||||
from aiogram.methods import AnswerShippingQuery
|
||||
|
||||
return AnswerShippingQuery(
|
||||
shipping_query_id=self.id,
|
||||
ok=ok,
|
||||
shipping_options=shipping_options,
|
||||
error_message=error_message,
|
||||
)
|
||||
**kwargs,
|
||||
).as_(self._bot)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue