ioBroker.telegram
ioBroker.telegram copied to clipboard
Error when using parse mode MarkdownV2
When using sentTo function for telegram with parse mode MarkdownV2
and texts containing .
the message isn't sent.
The log file shows following error message:
2022-08-14 12:56:03.782 | error | Cannot send message [chatId - xxxxxxxxx]: Error: ETELEGRAM: 400 Bad Request: can't parse entities: Character '.' is reserved and must be escaped with the preceding '\'
May it be possible to integrate a check box for auto-escape the following chars?
'_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!'
Same issue here, especially with Blocklys that originally used Markdown instead of the newer Markdown_V2. It took me some time to even find and solve it.
A checkbox, as suggested by @Standarduser, will not work in my opinion, because the desired formatting would then also be escaped.
I used a small js function for now:
return text
.replace(/\_/g, '\\_')
.replace(/\*/g, '\\*')
.replace(/\[/g, '\\[')
.replace(/\]/g, '\\]')
.replace(/\(/g, '\\(')
.replace(/\)/g, '\\)')
.replace(/\~/g, '\\~')
.replace(/\`/g, '\\`')
.replace(/\>/g, '\\>')
.replace(/\#/g, '\\#')
.replace(/\+/g, '\\+')
.replace(/\-/g, '\\-')
.replace(/\=/g, '\\=')
.replace(/\|/g, '\\|')
.replace(/\{/g, '\\{')
.replace(/\}/g, '\\}')
.replace(/\./g, '\\.')
.replace(/\!/g, '\\!');
and I wish there was a Blockly tag for that - what do you all mean?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions. Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.
Added escape option:
If someone has a good translation of "escape chars" into german, I will appreciate it. (PR is better)
"Escapezeichen verwenden" or "Escapezeichen setzen"
Sorry, not able to send a PR at the moment
I would suggest to not escape formatting chars, because that would prevent users to make text italic or bold
I would suggest to not escape formatting chars, because that would prevent users to make text italic or bold
From discussion I understand that in MarkdownV2 required it: https://core.telegram.org/bots/api#markdownv2-style And it is configurable, so the user can prepare text himself as it needed.
You are right. When I opened this issue I did not notice that escaping all chars would prevent formatting of text.
I think * _ ~ |
should not be escaped if they appear between char 1 and 126.
Maybe the best solution would be to make it configurable in instance settings?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions. Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.