Browse Source

Merge 45c4a98f1d into 08246f7005

pull/6472/merge
UncleVic 7 hours ago
committed by GitHub
parent
commit
648e9f2c95
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 15
      notify/telegram.sh

15
notify/telegram.sh

@ -1,10 +1,14 @@
#!/usr/bin/env sh
#!/usr/bin/bash
#Support Telegram Bots
#TELEGRAM_BOT_APITOKEN=""
#TELEGRAM_BOT_CHATID=""
#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() {
_subject="$1"
@ -28,6 +32,12 @@ telegram_send() {
fi
_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)}"
if [ -z "$TELEGRAM_BOT_URLBASE" ]; then
TELEGRAM_BOT_URLBASE="https://api.telegram.org"
@ -39,6 +49,9 @@ telegram_send() {
_content="$(printf "*%s*\n%s" "$_subject" "$_content" | _json_encode)"
_data="{\"text\": \"$_content\", "
_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\"disable_web_page_preview\": \"1\"}"

Loading…
Cancel
Save