mod/notification-telegram: support excluding characters from escaping...

... to support formatting in plain text.

Handle with care, this can break the request if done wrong!
This commit is contained in:
Christian Hesse 2024-04-26 08:24:06 +02:00
parent 4b6cd7ba29
commit f8856ae742

View file

@ -83,6 +83,7 @@
:local EscapeMD do={
:local Text [ :tostr $1 ];
:local Mode [ :tostr $2 ];
:local Excl [ :tostr $3 ];
:global CharacterReplace;
:global IfThenElse;
@ -93,7 +94,9 @@
"#"; "+"; "-"; "="; "|"; "{"; "}"; "."; "!" };
}
:foreach Char in=($Chars->$Mode) do={
:set Text [ $CharacterReplace $Text $Char ("\\" . $Char) ];
:if ([ :typeof [ :find $Excl $Char ] ] = "nil") do={
:set Text [ $CharacterReplace $Text $Char ("\\" . $Char) ];
}
}
:if ($Mode = "body") do={