From eb0f87b7797826a4e861bd6b1267df072e41166d Mon Sep 17 00:00:00 2001 From: nd Date: Fri, 6 Nov 2020 03:36:26 +0100 Subject: [PATCH] add more escaping --- templates/telegram-bot.py.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/telegram-bot.py.j2 b/templates/telegram-bot.py.j2 index 44a7124..358e81e 100755 --- a/templates/telegram-bot.py.j2 +++ b/templates/telegram-bot.py.j2 @@ -37,12 +37,12 @@ def postAlertmanager(chatID): elif alert['status'] == "firing": correctDate = parser.parse(alert['startsAt']).strftime('%Y-%m-%d %H:%M:%S') message += "Started: "+correctDate+"\n" - message = message.replace('-', '\-').replace('.', '\.') + "labels: \n```\n" + message = message.replace('-', '\-').replace('.', '\.').replace('!', '\!') + "labels: \n```\n" for l in alert['labels']: message += l + " : "+alert['labels'][l] + "\n" message += "```" bot.sendMessage(chat_id=chatID, text=message, parse_mode=telegram.ParseMode.MARKDOWN_V2) - return "Alert OK", 200 + return "Alert OK", 200 except Exception as error: bot.sendMessage(chat_id=chatID, text="Error to read json: "+str(error)) app.logger.info("\t%s",error)