mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
mod/notification-telegram: drop support for non-fixed width font
This commit is contained in:
parent
c9233773b3
commit
fed7f2da46
|
@ -41,8 +41,6 @@
|
|||
#};
|
||||
:global TelegramChatGroups "(all)";
|
||||
#:global TelegramChatGroups "(all|home|office)";
|
||||
# This is whether or not to send Telegram messages with fixed-width font.
|
||||
:global TelegramFixedWidthFont true;
|
||||
|
||||
# You can send Matrix notifications. Configure these settings and
|
||||
# install the module:
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
:local 0 "global-functions";
|
||||
|
||||
# expected configuration version
|
||||
:global ExpectedConfigVersion 106;
|
||||
:global ExpectedConfigVersion 107;
|
||||
|
||||
# global variables not to be changed by user
|
||||
:global GlobalFunctionsReady false;
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
("https://api.telegram.org/bot" . ($Message->"tokenid") . "/sendMessage") \
|
||||
http-data=("chat_id=" . ($Message->"chatid") . "&disable_notification=" . ($Message->"silent") . \
|
||||
"&reply_to_message_id=" . ($Message->"replyto") . "&disable_web_page_preview=true" . \
|
||||
"&parse_mode=" . ($Message->"parsemode") . "&text=" . ($Message->"text")) as-value ]->"data");
|
||||
"&parse_mode=MarkdownV2&text=" . ($Message->"text")) as-value ]->"data");
|
||||
:set ($TelegramQueue->$Id);
|
||||
:set ($TelegramMessageIDs->([ $ParseJson ([ $ParseJson $Data ]->"result") ]->"message_id")) 1;
|
||||
} on-error={
|
||||
|
@ -64,7 +64,6 @@
|
|||
:global IdentityExtra;
|
||||
:global TelegramChatId;
|
||||
:global TelegramChatIdOverride;
|
||||
:global TelegramFixedWidthFont;
|
||||
:global TelegramMessageIDs;
|
||||
:global TelegramQueue;
|
||||
:global TelegramTokenId;
|
||||
|
@ -80,15 +79,9 @@
|
|||
:global UrlEncode;
|
||||
|
||||
:local EscapeMD do={
|
||||
:global TelegramFixedWidthFont;
|
||||
|
||||
:global CharacterReplace;
|
||||
:global IfThenElse;
|
||||
|
||||
:if ($TelegramFixedWidthFont != true) do={
|
||||
:return ($1 . [ $IfThenElse ($2 = "body") ("\n") "" ]);
|
||||
}
|
||||
|
||||
:local Return $1;
|
||||
:local Chars {
|
||||
"body"={ "\\"; "`" };
|
||||
|
@ -140,7 +133,6 @@
|
|||
(($LenSum - [ :len $Text ]) * 100 / $LenSum) . "%!") "plain" ]);
|
||||
}
|
||||
:set Text [ $UrlEncode $Text ];
|
||||
:local ParseMode [ $IfThenElse ($TelegramFixedWidthFont = true) "MarkdownV2" "" ];
|
||||
|
||||
:do {
|
||||
:if ([ $CertificateAvailable "Go Daddy Secure Certificate Authority - G2" ] = false) do={
|
||||
|
@ -150,7 +142,7 @@
|
|||
("https://api.telegram.org/bot" . $TokenId . "/sendMessage") \
|
||||
http-data=("chat_id=" . $ChatId . "&disable_notification=" . ($Notification->"silent") . \
|
||||
"&reply_to_message_id=" . ($Notification->"replyto") . "&disable_web_page_preview=true" . \
|
||||
"&parse_mode=" . $ParseMode . "&text=" . $Text) as-value ]->"data");
|
||||
"&parse_mode=MarkdownV2&text=" . $Text) as-value ]->"data");
|
||||
:set ($TelegramMessageIDs->([ $ParseJson ([ $ParseJson $Data ]->"result") ]->"message_id")) 1;
|
||||
} on-error={
|
||||
$LogPrintExit2 info $0 ("Failed sending telegram notification! Queuing...") false;
|
||||
|
@ -162,8 +154,7 @@
|
|||
[ $EscapeMD ("This message was queued since " . [ /system/clock/get date ] . \
|
||||
" " . [ /system/clock/get time ] . " and may be obsolete.") "plain" ]) ]);
|
||||
:set ($TelegramQueue->[ :len $TelegramQueue ]) { chatid=$ChatId; tokenid=$TokenId;
|
||||
parsemode=$ParseMode; text=$Text; silent=($Notification->"silent");
|
||||
replyto=($Notification->"replyto") };
|
||||
text=$Text; silent=($Notification->"silent"); replyto=($Notification->"replyto") };
|
||||
:if ([ :len [ /system/scheduler/find where name="\$FlushTelegramQueue" ] ] = 0) do={
|
||||
/system/scheduler/add name="\$FlushTelegramQueue" interval=1m start-time=startup \
|
||||
on-event=(":global FlushTelegramQueue; \$FlushTelegramQueue;");
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
104="All relevant scripts were ported to new wifiwave2 and are available for AX devices now!";
|
||||
105="Extended 'check-routeros-update' to support automatic update from specific neighbor(s).";
|
||||
106="Modified 'telegram-chat' to make it act on message replies, without activation. Also made it answer a single question mark with a short notice.";
|
||||
107="Dropped support for non-fixed width font in Telegram notifications.";
|
||||
};
|
||||
|
||||
# Migration steps to be applied on script updates
|
||||
|
|
Loading…
Reference in a new issue