Skip to content

Commit

Permalink
fix telegram notification on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
wy580477 committed Jul 19, 2024
1 parent f877566 commit 122a857
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions content/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ SEND_TG_MSG() {
TELEGRAM_TITLE="$(grep ^telegram-notification-title "${SCRIPT_CONF}" | cut -d= -f2- | sed "s|^[ \t]*||g;s|\r$||")"
TG_PROXY="$(grep ^telegram-proxy "${SCRIPT_CONF}" | cut -d= -f2- | sed "s|^[ \t]*||g;s|\r$||")"
if [ "${TELEGRAM_CHAT_ID}" != "" ]; then
if [ "${TG_PROXY}" != "" ]; then
PROXY_PARAM="-x ${TG_PROXY}"
fi
if [ "${GLOBAL_LANGUAGE}" = "chs" ]; then
msgbody="容器已启动"
else
Expand All @@ -30,7 +27,12 @@ SEND_TG_MSG() {
msg="$title $timestamp\n$(echo "$msgbody" | sed -e 's|\\|\\\\|g' -e 's|\n|\\n|g' -e 's|\t|\\t|g' -e 's|\"|\\"|g')"
entities="[{\"offset\":0,\"length\":${#title},\"type\":\"bold\"},{\"offset\":$((${#title} + 1)),\"length\":${#timestamp},\"type\":\"italic\"}]"
data="{\"chat_id\":\"$TELEGRAM_CHAT_ID\",\"text\":\"$msg\",\"entities\":$entities,\"disable_notification\": true}"
curl -s "${PROXY_PARAM}" -o /dev/null -H 'Content-Type: application/json' -X POST -d "$data" https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage
if [ "${TG_PROXY}" != "" ]; then
PROXY_PARAM="-x ${TG_PROXY}"
curl -s "${PROXY_PARAM}" -o /dev/null -H 'Content-Type: application/json' -X POST -d "$data" https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage
else
curl -s -o /dev/null -H 'Content-Type: application/json' -X POST -d "$data" https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage
fi
fi
}

Expand Down

0 comments on commit 122a857

Please sign in to comment.