aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2020-11-26 22:21:28 +0100
committerGravatar Christian Hesse <mail@eworm.de>2020-11-26 22:21:28 +0100
commit7e0558e85dcf06161d0b9c554688d4fc4d1b3101 (patch)
treeb715808f1490aa96c8b7836243596ace424ad55c
parentd7725540f884bf7486274f0e002cf2ba1b41306e (diff)
global-functions: $SendTelegram: prepare to add clickable link
Formatting with fixed width font stopped links from being clickable.
-rw-r--r--global-functions10
1 files 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";