mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: $FlushTelegramQueue: give hint on queued message
This commit is contained in:
parent
1b68e42bc6
commit
a03c8773da
1 changed files with 8 additions and 2 deletions
|
@ -287,6 +287,8 @@
|
|||
:global TelegramTokenId;
|
||||
|
||||
:global LogPrintExit;
|
||||
:global SymbolForNotification;
|
||||
:global UrlEncode;
|
||||
|
||||
:local AllDone true;
|
||||
:local QueueLen [ :len $TelegramQueue ];
|
||||
|
@ -297,7 +299,9 @@
|
|||
("https://api.telegram.org/bot" . $TelegramTokenId . "/sendMessage") \
|
||||
http-data=("chat_id=" . ($Message->"chatid") . \
|
||||
"&disable_notification=" . ($Message->"silent") . \
|
||||
"&text=" . ($Message->"text"));
|
||||
"&text=" . ($Message->"text") . "\n\n" . \
|
||||
[ $UrlEncode ([ $SymbolForNotification "alarm-clock" ] . "This message was " . \
|
||||
"queued since " . ($Message->"since") . " and may be obsolete.") ]);
|
||||
:set ($TelegramQueue->$Id);
|
||||
} on-error={
|
||||
$LogPrintExit debug ("Sending queued Telegram message failed.") false;
|
||||
|
@ -765,7 +769,8 @@
|
|||
:if ([ :typeof $TelegramQueue ] = "nothing") do={
|
||||
:set TelegramQueue [ :toarray "" ];
|
||||
}
|
||||
:set ($TelegramQueue->[ :len $TelegramQueue ]) { chatid=$ChatId; text=$Text; silent=$Silent };
|
||||
:set ($TelegramQueue->[ :len $TelegramQueue ]) { chatid=$ChatId; text=$Text; \
|
||||
silent=$Silent; since=([ / system clock get date ] . " " . [ / system clock get time ]) };
|
||||
: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;";
|
||||
|
@ -776,6 +781,7 @@
|
|||
# return UTF-8 symbol for unicode name
|
||||
:set SymbolByUnicodeName do={
|
||||
:local Symbols {
|
||||
"alarm-clock"="\E2\8F\B0";
|
||||
"cross-mark"="\E2\9D\8C";
|
||||
"fire"="\F0\9F\94\A5";
|
||||
"floppy-disk"="\F0\9F\92\BE";
|
||||
|
|
Loading…
Reference in a new issue