2021-10-11 17:20:39 +02:00
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
|
|
from telegram import InlineKeyboardMarkup, Update
|
2021-10-08 15:25:47 +02:00
|
|
|
from telegram.utils.helpers import mention_markdown
|
|
|
|
|
|
2021-10-11 17:20:39 +02:00
|
|
|
from bot.message.inboundMessage import InboundMessage
|
2021-10-08 15:25:47 +02:00
|
|
|
from logger import Logger
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Replier:
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
2021-10-11 17:20:39 +02:00
|
|
|
def interpolate(content: str, inbound_message: InboundMessage):
|
2021-10-08 15:25:47 +02:00
|
|
|
return content.format(
|
2021-10-11 17:20:39 +02:00
|
|
|
mention_markdown(inbound_message.user_id, inbound_message.username),
|
|
|
|
|
inbound_message.group_name
|
2021-10-08 15:25:47 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
2021-10-11 17:20:39 +02:00
|
|
|
def markdown(update: Update, message: str, reply_markup: Optional[InlineKeyboardMarkup] = None) -> None:
|
2021-10-08 15:25:47 +02:00
|
|
|
try:
|
2021-10-11 17:20:39 +02:00
|
|
|
update.effective_message.reply_markdown_v2(message, reply_markup=reply_markup)
|
2021-10-08 15:25:47 +02:00
|
|
|
except Exception as err:
|
|
|
|
|
Logger.error(str(err))
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
2021-10-11 17:20:39 +02:00
|
|
|
def html(update: Update, html: str, reply_markup: Optional[InlineKeyboardMarkup] = None) -> None:
|
2021-10-08 15:25:47 +02:00
|
|
|
try:
|
2021-10-11 17:20:39 +02:00
|
|
|
update.effective_message.reply_html(html, reply_markup=reply_markup, disable_web_page_preview=True)
|
2021-10-08 15:25:47 +02:00
|
|
|
except Exception as err:
|
|
|
|
|
Logger.error(str(err))
|