From a03c8773da9a41b6c2db295d7187aae323a1b4bb Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 14 Sep 2020 23:22:02 +0200 Subject: global-functions: $FlushTelegramQueue: give hint on queued message --- global-functions | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/global-functions b/global-functions index 1cacde6..21fa1f3 100644 --- a/global-functions +++ b/global-functions @@ -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"; -- cgit v1.2.3-70-g09d2