add uttons to Message.edit

This commit is contained in:
apepenkov 2023-11-10 10:43:25 +03:00
parent 45e7b7a380
commit 619afe616e
3 changed files with 14 additions and 1 deletions

View File

@ -585,6 +585,7 @@ class Client:
markdown: Optional[str] = None,
html: Optional[str] = None,
link_preview: bool = False,
buttons: Optional[Union[List[btns.Button], List[List[btns.Button]]]] = None,
) -> Message:
"""
Edit a message.
@ -599,6 +600,10 @@ class Client:
:param markdown: See :ref:`formatting`.
:param html: See :ref:`formatting`.
:param link_preview: See :ref:`formatting`.
:param buttons:
The buttons to use for the message.
Only bot accounts can send buttons.
:return: The edited message.
@ -624,6 +629,7 @@ class Client:
markdown=markdown,
html=html,
link_preview=link_preview,
buttons=buttons
)
async def forward_messages(

View File

@ -115,6 +115,7 @@ async def edit_message(
markdown: Optional[str] = None,
html: Optional[str] = None,
link_preview: bool = False,
buttons: Optional[Union[List[btns.Button], List[List[btns.Button]]]] = None,
) -> Message:
peer = (await self._resolve_to_packed(chat))._to_input_peer()
message, entities = parse_message(
@ -128,7 +129,7 @@ async def edit_message(
id=message_id,
message=message,
media=None,
reply_markup=None,
reply_markup=btns.build_keyboard(buttons),
entities=entities,
schedule_date=None,
)

View File

@ -390,6 +390,7 @@ class Message(metaclass=NoPublicConstructor):
markdown: Optional[str] = None,
html: Optional[str] = None,
link_preview: bool = False,
buttons: Optional[Union[List[Button], List[List[Button]]]] = None,
) -> Message:
"""
Alias for :meth:`telethon.Client.edit_message`.
@ -398,6 +399,10 @@ class Message(metaclass=NoPublicConstructor):
:param markdown: See :ref:`formatting`.
:param html: See :ref:`formatting`.
:param link_preview: See :meth:`~telethon.Client.send_message`.
:param buttons:
The buttons to use for the message.
Only bot accounts can send buttons.
"""
return await self._client.edit_message(
self.chat,
@ -406,6 +411,7 @@ class Message(metaclass=NoPublicConstructor):
markdown=markdown,
html=html,
link_preview=link_preview,
buttons=buttons,
)
async def forward(self, target: ChatLike) -> Message: