0.3.1 - Fixed telegram restricted characters

This commit is contained in:
miloszowi 2024-02-28 11:25:01 +01:00
parent 878091deae
commit e242584974
2 changed files with 13 additions and 4 deletions

View File

@ -1,6 +1,9 @@
# Change Log
All notable changes to this project will be documented in this file.
## [0.3.1] - 28.02.2023
### Changed
- fixed markdown replier to respect restricted characters provided in the [api docs](https://core.telegram.org/bots/api#markdownv2-style)
## [0.3.0] - 12.11.2021
### Added
- Dynamic mentioning by `@` character

View File

@ -8,24 +8,30 @@ from logger import Logger
class Replier:
@staticmethod
def interpolate(content: str, inbound_message: InboundMessage):
return content.format(
formatted = content.format(
mention_markdown(inbound_message.user_id, inbound_message.username),
inbound_message.group_name
)
telegramRestrictionCharacters = ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!']
for character in telegramRestrictionCharacters:
formatted.replace(character, "\\" + character)
return formatted
@staticmethod
def markdown(update: Update, message: str, reply_markup: Optional[InlineKeyboardMarkup] = None) -> None:
try:
update.effective_message.reply_markdown_v2(message, reply_markup=reply_markup)
except Exception as err:
Logger.error(str(err))
Logger.error("replier.markdown error: "str(err))
@staticmethod
def html(update: Update, html: str, reply_markup: Optional[InlineKeyboardMarkup] = None) -> None:
try:
update.effective_message.reply_html(html, reply_markup=reply_markup, disable_web_page_preview=True)
except Exception as err:
Logger.error(str(err))
Logger.error("replier.html error: " + str(err))