extact method

This commit is contained in:
lightme16 2020-10-10 16:56:59 +03:00
parent 4e196271ae
commit 86113c0e32

View file

@ -379,19 +379,27 @@ class MsgView:
msg = self._format_reply_msg( msg = self._format_reply_msg(
msg_proxy.chat_id, msg, reply_to, width_limit msg_proxy.chat_id, msg, reply_to, width_limit
) )
if reply_markup := self._format_reply_markup(msg_proxy):
msg += reply_markup
return msg
@staticmethod
def _format_reply_markup(msg_proxy: MsgProxy) -> str:
msg = ""
if reply_markup := msg_proxy.reply_markup: if reply_markup := msg_proxy.reply_markup:
for row in reply_markup.get("rows", []): for row in reply_markup.get("rows", []):
msg += "\n" msg += "\n"
for item in row: for item in row:
if text := item.get("text"): text = item.get("text")
if not text:
continue
_type = item.get("type", {}) _type = item.get("type", {})
if _type.get("@type") == "inlineKeyboardButtonTypeUrl": if _type.get("@type") == "inlineKeyboardButtonTypeUrl":
url = _type.get("url") if url := _type.get("url"):
if url:
text = f"{text} ({url})" text = f"{text} ({url})"
msg += f"| {text} " msg += f"| {text} "
msg += "|" msg += "|"
return msg return msg
def _collect_msgs_to_draw( def _collect_msgs_to_draw(