Skip to content

Commit ab3093d

Browse files
authored
Merge pull request #6472 from UncleVic/master
feat: #6471 add message_thread_id to telegram notifications
2 parents 80e39eb + c21db5c commit ab3093d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

notify/telegram.sh

100644100755
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#TELEGRAM_BOT_APITOKEN=""
66
#TELEGRAM_BOT_CHATID=""
77
#TELEGRAM_BOT_URLBASE=""
8+
#TELEGRAM_BOT_THREADID=""
9+
10+
# To get TELEGRAM_BOT_THREADID, just copy the link of the message from the thread.
11+
# https://t.me/c/123456789/XXX/1520 - XXX is the TELEGRAM_BOT_THREADID
812

913
telegram_send() {
1014
_subject="$1"
@@ -28,6 +32,12 @@ telegram_send() {
2832
fi
2933
_saveaccountconf_mutable TELEGRAM_BOT_CHATID "$TELEGRAM_BOT_CHATID"
3034

35+
TELEGRAM_BOT_THREADID="${TELEGRAM_BOT_THREADID:-$(_readaccountconf_mutable TELEGRAM_BOT_THREADID)}"
36+
if [ -z "$TELEGRAM_BOT_THREADID" ]; then
37+
TELEGRAM_BOT_THREADID=""
38+
fi
39+
_saveaccountconf_mutable TELEGRAM_BOT_THREADID "$TELEGRAM_BOT_THREADID"
40+
3141
TELEGRAM_BOT_URLBASE="${TELEGRAM_BOT_URLBASE:-$(_readaccountconf_mutable TELEGRAM_BOT_URLBASE)}"
3242
if [ -z "$TELEGRAM_BOT_URLBASE" ]; then
3343
TELEGRAM_BOT_URLBASE="https://api.telegram.org"
@@ -39,6 +49,9 @@ telegram_send() {
3949
_content="$(printf "*%s*\n%s" "$_subject" "$_content" | _json_encode)"
4050
_data="{\"text\": \"$_content\", "
4151
_data="$_data\"chat_id\": \"$TELEGRAM_BOT_CHATID\", "
52+
if [ -n "$TELEGRAM_BOT_THREADID" ]; then
53+
_data="$_data\"message_thread_id\": \"$TELEGRAM_BOT_THREADID\", "
54+
fi
4255
_data="$_data\"parse_mode\": \"MarkdownV2\", "
4356
_data="$_data\"disable_web_page_preview\": \"1\"}"
4457

0 commit comments

Comments
 (0)