NEMSLinux / legacy-nems-www

NEMS Web Interface
https://nemslinux.com/
3 stars 5 forks source link

Telegram: issue with underscore in message, wrong arg[5] and arg[7] passed to script #7

Open baggins1us opened 1 year ago

baggins1us commented 1 year ago

When upgrading from NEMS 1.4 to 1.6 several issues came up with the notify-by-telegram.lua script:

1) The format of the bot id has changed. This was easy to fix in the configuration by dropping the 'bot' from the id .

2) The script now expects the new format of the chat id. As I have a legacy chat id, I commented out the line: local chat_id = '-' .. arg[2]:gsub('%g', '')

3) Since parsemode MarkDown is used, the message must not contain an underscore. This is one of the reserved characters for Telegram. Strangely enough the other reserved characters " ().-" cause no problems. I solved this by adding the following line after the message is composed, changing the underscore to hyphen: message = message:gsub('_','-')

4) In the notify-service-by telegram procedure, arguments 5 and 7 (State and Info) are not passed correctly to the script. Only '$' is passed. This does not happen with notify-host-by telegram.