pagermon / pagermon

Multimon-ng pager message parser and viewer
https://hrng.io/
The Unlicense
267 stars 75 forks source link

Telegram notifications break if message has odd number of certain characters #610

Open drsn0w opened 4 months ago

drsn0w commented 4 months ago

Describe the bug Telegram notifications break if message has an odd number of "_" (underscore)s. Messages are sent with parse_mode: markdown and the Telegram Bot API attempts to interpret these unescaped underscores as Markdown italics, but fails when it finds an odd number. Produces error error : Telegram: StatusCodeError: 400 - {"ok":false,"error_code":400,"description":"Bad Request: can't parse entities: Can't find end of the entity starting at byte offset ...

To Reproduce Steps to reproduce the behavior:

  1. Receive page with odd number of underscores with Telegram notifications enabled.
  2. Telegram bot API returns error due to not being able to parse the Markdown it expects.

Additional context This could be solved by escaping Markdown special characters in the message before sending to Telegram API

eopo commented 4 months ago

I wrote a fix that hopefully works. I don't run a telegram bot myself, so I'm needing someone to test it for me. 200w