mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2026-05-18 20:03:55 +08:00
Merge pull request #6472 from UncleVic/master
feat: #6471 add message_thread_id to telegram notifications
This commit is contained in:
13
notify/telegram.sh
Normal file → Executable file
13
notify/telegram.sh
Normal file → Executable file
@@ -5,6 +5,10 @@
|
|||||||
#TELEGRAM_BOT_APITOKEN=""
|
#TELEGRAM_BOT_APITOKEN=""
|
||||||
#TELEGRAM_BOT_CHATID=""
|
#TELEGRAM_BOT_CHATID=""
|
||||||
#TELEGRAM_BOT_URLBASE=""
|
#TELEGRAM_BOT_URLBASE=""
|
||||||
|
#TELEGRAM_BOT_THREADID=""
|
||||||
|
|
||||||
|
# To get TELEGRAM_BOT_THREADID, just copy the link of the message from the thread.
|
||||||
|
# https://t.me/c/123456789/XXX/1520 - XXX is the TELEGRAM_BOT_THREADID
|
||||||
|
|
||||||
telegram_send() {
|
telegram_send() {
|
||||||
_subject="$1"
|
_subject="$1"
|
||||||
@@ -28,6 +32,12 @@ telegram_send() {
|
|||||||
fi
|
fi
|
||||||
_saveaccountconf_mutable TELEGRAM_BOT_CHATID "$TELEGRAM_BOT_CHATID"
|
_saveaccountconf_mutable TELEGRAM_BOT_CHATID "$TELEGRAM_BOT_CHATID"
|
||||||
|
|
||||||
|
TELEGRAM_BOT_THREADID="${TELEGRAM_BOT_THREADID:-$(_readaccountconf_mutable TELEGRAM_BOT_THREADID)}"
|
||||||
|
if [ -z "$TELEGRAM_BOT_THREADID" ]; then
|
||||||
|
TELEGRAM_BOT_THREADID=""
|
||||||
|
fi
|
||||||
|
_saveaccountconf_mutable TELEGRAM_BOT_THREADID "$TELEGRAM_BOT_THREADID"
|
||||||
|
|
||||||
TELEGRAM_BOT_URLBASE="${TELEGRAM_BOT_URLBASE:-$(_readaccountconf_mutable TELEGRAM_BOT_URLBASE)}"
|
TELEGRAM_BOT_URLBASE="${TELEGRAM_BOT_URLBASE:-$(_readaccountconf_mutable TELEGRAM_BOT_URLBASE)}"
|
||||||
if [ -z "$TELEGRAM_BOT_URLBASE" ]; then
|
if [ -z "$TELEGRAM_BOT_URLBASE" ]; then
|
||||||
TELEGRAM_BOT_URLBASE="https://api.telegram.org"
|
TELEGRAM_BOT_URLBASE="https://api.telegram.org"
|
||||||
@@ -39,6 +49,9 @@ telegram_send() {
|
|||||||
_content="$(printf "*%s*\n%s" "$_subject" "$_content" | _json_encode)"
|
_content="$(printf "*%s*\n%s" "$_subject" "$_content" | _json_encode)"
|
||||||
_data="{\"text\": \"$_content\", "
|
_data="{\"text\": \"$_content\", "
|
||||||
_data="$_data\"chat_id\": \"$TELEGRAM_BOT_CHATID\", "
|
_data="$_data\"chat_id\": \"$TELEGRAM_BOT_CHATID\", "
|
||||||
|
if [ -n "$TELEGRAM_BOT_THREADID" ]; then
|
||||||
|
_data="$_data\"message_thread_id\": \"$TELEGRAM_BOT_THREADID\", "
|
||||||
|
fi
|
||||||
_data="$_data\"parse_mode\": \"MarkdownV2\", "
|
_data="$_data\"parse_mode\": \"MarkdownV2\", "
|
||||||
_data="$_data\"disable_web_page_preview\": \"1\"}"
|
_data="$_data\"disable_web_page_preview\": \"1\"}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user