mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-25 00:34:19 +03:00
Make build_reply_markup public
This commit is contained in:
parent
7750c9ff2f
commit
3bdfd4b32c
|
@ -4,7 +4,18 @@ from .. import utils, events
|
|||
|
||||
|
||||
class ButtonMethods(UpdateMethods):
|
||||
def _build_reply_markup(self, buttons, inline_only=False):
|
||||
def build_reply_markup(self, buttons, inline_only=False):
|
||||
"""
|
||||
Builds a :tl`ReplyInlineMarkup` or :tl:`ReplyKeyboardMarkup` for
|
||||
the given buttons, or does nothing if either no buttons are
|
||||
provided or the provided argument is already a reply markup.
|
||||
|
||||
This will add any event handlers defined in the
|
||||
buttons and delete old ones not to call them twice,
|
||||
so you should probably call this method manually for
|
||||
serious bots instead re-adding handlers every time you
|
||||
send a message. Magic can only go so far.
|
||||
"""
|
||||
if buttons is None:
|
||||
return None
|
||||
|
||||
|
|
|
@ -435,7 +435,7 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
|
|||
if buttons is None:
|
||||
markup = message.reply_markup
|
||||
else:
|
||||
markup = self._build_reply_markup(buttons)
|
||||
markup = self.build_reply_markup(buttons)
|
||||
|
||||
if silent is None:
|
||||
silent = message.silent
|
||||
|
@ -463,7 +463,7 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
|
|||
reply_to_msg_id=utils.get_message_id(reply_to),
|
||||
clear_draft=clear_draft,
|
||||
silent=silent,
|
||||
reply_markup=self._build_reply_markup(buttons)
|
||||
reply_markup=self.build_reply_markup(buttons)
|
||||
)
|
||||
|
||||
result = await self(request)
|
||||
|
@ -630,7 +630,7 @@ class MessageMethods(UploadMethods, ButtonMethods, MessageParseMethods):
|
|||
no_webpage=not link_preview,
|
||||
entities=msg_entities,
|
||||
media=media,
|
||||
reply_markup=self._build_reply_markup(buttons)
|
||||
reply_markup=self.build_reply_markup(buttons)
|
||||
)
|
||||
msg = self._get_response_message(request, await self(request), entity)
|
||||
self._cache_media(msg, file, file_handle)
|
||||
|
|
|
@ -167,7 +167,7 @@ class UploadMethods(ButtonMethods, MessageParseMethods, UserMethods):
|
|||
voice_note=voice_note, video_note=video_note
|
||||
)
|
||||
|
||||
markup = self._build_reply_markup(buttons)
|
||||
markup = self.build_reply_markup(buttons)
|
||||
request = functions.messages.SendMediaRequest(
|
||||
entity, media, reply_to_msg_id=reply_to, message=caption,
|
||||
entities=msg_entities, reply_markup=markup, silent=silent
|
||||
|
|
|
@ -253,7 +253,7 @@ class InlineBuilder:
|
|||
if sum(1 for x in (text, geo, contact, game) if x) != 1:
|
||||
raise ValueError('Can only use one of text, geo, contact or game')
|
||||
|
||||
markup = self._client._build_reply_markup(buttons, inline_only=True)
|
||||
markup = self._client.build_reply_markup(buttons, inline_only=True)
|
||||
if text:
|
||||
text, msg_entities = await self._client._parse_message_text(
|
||||
text, parse_mode
|
||||
|
|
Loading…
Reference in New Issue
Block a user