From ec35e63f4fc3c903e179b258675693e913963941 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 9 Feb 2019 02:29:32 +0100 Subject: [PATCH] Fix diario bug --- telegrambot.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/telegrambot.py b/telegrambot.py index 510cc94c..8d21e848 100644 --- a/telegrambot.py +++ b/telegrambot.py @@ -52,16 +52,18 @@ sentry = raven.Client(config["Sentry"]["token"], hook_libraries=[]) -def reply_msg(bot: telegram.Bot, chat_id: int, string: str, **kwargs) -> telegram.Message: - return bot.send_message(chat_id, strings.safely_format_string(string, words=kwargs), +def reply_msg(bot: telegram.Bot, chat_id: int, string: str, ignore_escaping=False, **kwargs) -> telegram.Message: + if not ignore_escaping: + string = strings.safely_format_string(string, words=kwargs) + return bot.send_message(chat_id, string, parse_mode="HTML", disable_web_page_preview=True) -def reply(bot: telegram.Bot, update: telegram.Update, string: str, **kwargs) -> telegram.Message: +def reply(bot: telegram.Bot, update: telegram.Update, string: str, ignore_escaping=False, **kwargs) -> telegram.Message: while True: try: - return reply_msg(bot, update.message.chat.id, string, **kwargs) + return reply_msg(bot, update.message.chat.id, string, ignore_escaping=ignore_escaping, **kwargs) except Unauthorized: if update.message.chat.type == telegram.Chat.PRIVATE: return reply_msg(bot, main_group_id, strings.TELEGRAM.ERRORS.UNAUTHORIZED_USER, @@ -256,11 +258,10 @@ def cmd_diario(bot: telegram.Bot, update: telegram.Update): return diario = db.Diario(timestamp=datetime.datetime.now(), saver=saver, - author=author, text=text) session.add(diario) session.commit() - reply(bot, update, strings.DIARIO.SUCCESS, diario=diario.to_telegram()) + reply(bot, update, strings.DIARIO.SUCCESS, ignore_escaping=True, diario=diario.to_telegram()) except Exception: raise finally: