mod/notification-telegram: use proper variable naming...

... in local escaping function.
This commit is contained in:
Christian Hesse 2024-04-26 08:15:56 +02:00
parent d6e315580b
commit 4b6cd7ba29

View file

@ -81,24 +81,26 @@
:global UrlEncode; :global UrlEncode;
:local EscapeMD do={ :local EscapeMD do={
:local Text [ :tostr $1 ];
:local Mode [ :tostr $2 ];
:global CharacterReplace; :global CharacterReplace;
:global IfThenElse; :global IfThenElse;
:local Return $1;
:local Chars { :local Chars {
"body"={ "\\"; "`" }; "body"={ "\\"; "`" };
"plain"={ "_"; "*"; "["; "]"; "("; ")"; "~"; "`"; ">"; "plain"={ "_"; "*"; "["; "]"; "("; ")"; "~"; "`"; ">";
"#"; "+"; "-"; "="; "|"; "{"; "}"; "."; "!" }; "#"; "+"; "-"; "="; "|"; "{"; "}"; "."; "!" };
} }
:foreach Char in=($Chars->$2) do={ :foreach Char in=($Chars->$Mode) do={
:set Return [ $CharacterReplace $Return $Char ("\\" . $Char) ]; :set Text [ $CharacterReplace $Text $Char ("\\" . $Char) ];
} }
:if ($2 = "body") do={ :if ($Mode = "body") do={
:return ("```\n" . $Return . "\n```"); :return ("```\n" . $Text . "\n```");
} }
:return $Return; :return $Text;
} }
:local ChatId [ $EitherOr ($Notification->"chatid") \ :local ChatId [ $EitherOr ($Notification->"chatid") \