fix telegram escaping

This commit is contained in:
nd 2020-11-13 22:12:51 +01:00
parent b5ed1037b0
commit c1636d0afe
No known key found for this signature in database
GPG key ID: 21B5CD4DEE3670E9

View file

@ -37,11 +37,13 @@ def postAlertmanager(chatID):
elif alert['status'] == "firing":
correctDate = parser.parse(alert['startsAt']).strftime('%Y-%m-%d %H:%M:%S')
message += "Started: "+correctDate+"\n"
message += "labels: \n```\n"
message += "labels: \n"
message = telegram.utils.helpers.escape_markdown(message, version=2) + "```\n"
labels = ""
for l in alert['labels']:
message += l + " : "+alert['labels'][l] + "\n"
message += "```"
bot.sendMessage(chat_id=chatID, text=telegram.utils.helpers.escape_markdown(message, version=2), parse_mode=telegram.ParseMode.MARKDOWN_V2)
labels += l + " : "+alert['labels'][l] + "\n"
message += telegram.utils.helpers.escape_markdown(labels, version=2) + "```"
bot.sendMessage(chat_id=chatID, text=message, parse_mode=telegram.ParseMode.MARKDOWN_V2)
return "Alert OK", 200
except Exception as error:
bot.sendMessage(chat_id=chatID, text="Error to read json: "+str(error))