P
P
pred8or2020-09-10 11:50:53
Zabbix
pred8or, 2020-09-10 11:50:53

Zabbix 5 - what's wrong with notifications in Telegram?

The bot was set up according to the manual , the test of messages in the chat passed, even messages were sent. After that, an attempt was made to tweak the message templates, incl. insert emoji. And everything broke. And now even the message test fails.

Media type test failed.

Sending failed: Bad Request: can't parse entities: Character '{' is reserved and must be escaped with the preceding '\'.


5f59e716a24c1025841492.png

If you remove the brackets, the test passes. But in real messages, different characters, including '-', '('etc. dofiga and all these messages settle in the Action Log.

Well, so as not to get up 2 times - how, for example, to insert emoji into the subject of the message, for example, SOS with the code \xF0\x9F\x86\x97? Markdown :sos:doesn't work either. If you try to insert the symbol itself, it swears when you already save the Media Type page.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
c0rnoTa, 2021-10-11
@pred8or

Emoji can be defined as Unicode Surrogates (of the form `\u01234\uABCD` )
Then in the JS script for sending a message to telegram, the 29th line of the form should be replaced with
data = JSON.stringify(params);

var dataJSON = JSON.stringify(params);
        var re = /\\u([0-9A-F]{4})/g;
        data = dataJSON.replace(re, 'u$1');

The bottom line is that JSON.stringify escapes all slashes in Surrogates, resulting in two slashes. Therefore, after we have received JSON with data for sending, we need to return one slash, and we make this change only for Unicode Surrogates, and not in general for the text. Regulator help.

A
Andrey Barbolin, 2020-09-10
@dronmaxman

> Character '{' is reserved and must be escaped with the preceding '\'.
{ is a reserved character and must be escaped with "\"
By default, the Parsemode field is empty. Try clearing the "Parsemode" field

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question