From 7e0558e85dcf06161d0b9c554688d4fc4d1b3101 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 26 Nov 2020 22:21:28 +0100 Subject: global-functions: $SendTelegram: prepare to add clickable link Formatting with fixed width font stopped links from being clickable. --- global-functions | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/global-functions b/global-functions index 9c5e76e..384f438 100644 --- a/global-functions +++ b/global-functions @@ -756,6 +756,7 @@ :set SendTelegram do={ :local Subject [ :tostr $1 ]; :local Message [ :tostr $2 ]; + :local Link; :local Silent [ :tostr $3 ]; :global Identity; @@ -808,14 +809,18 @@ :return false; } + :local LenLink [ :len $Link ]; :local Text ("[" . $Identity . "] " . $Subject . "\n\n" . $Message); - :if ([ :len $Text ] > 3968) do={ - :set Text ([ $EscapeMD ([ :pick $Text 0 3840 ] . "...") "body" ] . \ + :if ([ :len $Text ] > (3968 - $LenLink)) do={ + :set Text ([ $EscapeMD ([ :pick $Text 0 (3840 - $LenLink) ] . "...") "body" ] . \ "\n" . [ $SymbolForNotification "scissors" ] . \ [ $EscapeMD "The Telegram message was too long and has been truncated!" "hint" ]); } else={ :set Text [ $EscapeMD $Text "body" ]; } + :if ($LenLink > 0) do={ + :set Text ($Text . "\n" . [ $SymbolForNotification "link" ] . [ $EscapeMD $Link "hint" ]); + } :set Text [ $UrlEncode $Text ]; :local ParseMode [ $IfThenElse ($TelegramFixedWidthFont = true) "MarkdownV2" "" ]; @@ -855,6 +860,7 @@ "floppy-disk"="\F0\9F\92\BE"; "high-voltage-sign"="\E2\9A\A1"; "incoming-envelope"="\F0\9F\93\A8"; + "link"="\F0\9F\94\97"; "lock-with-ink-pen"="\F0\9F\94\8F"; "mobile-phone"="\F0\9F\93\B1"; "pushpin"="\F0\9F\93\8C"; -- cgit v1.2.3-54-g00ecf