Skip to content

Commit 122a857

Browse files
committed
fix telegram notification on startup
1 parent f877566 commit 122a857

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

content/entrypoint.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ SEND_TG_MSG() {
1717
TELEGRAM_TITLE="$(grep ^telegram-notification-title "${SCRIPT_CONF}" | cut -d= -f2- | sed "s|^[ \t]*||g;s|\r$||")"
1818
TG_PROXY="$(grep ^telegram-proxy "${SCRIPT_CONF}" | cut -d= -f2- | sed "s|^[ \t]*||g;s|\r$||")"
1919
if [ "${TELEGRAM_CHAT_ID}" != "" ]; then
20-
if [ "${TG_PROXY}" != "" ]; then
21-
PROXY_PARAM="-x ${TG_PROXY}"
22-
fi
2320
if [ "${GLOBAL_LANGUAGE}" = "chs" ]; then
2421
msgbody="容器已启动"
2522
else
@@ -30,7 +27,12 @@ SEND_TG_MSG() {
3027
msg="$title $timestamp\n$(echo "$msgbody" | sed -e 's|\\|\\\\|g' -e 's|\n|\\n|g' -e 's|\t|\\t|g' -e 's|\"|\\"|g')"
3128
entities="[{\"offset\":0,\"length\":${#title},\"type\":\"bold\"},{\"offset\":$((${#title} + 1)),\"length\":${#timestamp},\"type\":\"italic\"}]"
3229
data="{\"chat_id\":\"$TELEGRAM_CHAT_ID\",\"text\":\"$msg\",\"entities\":$entities,\"disable_notification\": true}"
33-
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
30+
if [ "${TG_PROXY}" != "" ]; then
31+
PROXY_PARAM="-x ${TG_PROXY}"
32+
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
33+
else
34+
curl -s -o /dev/null -H 'Content-Type: application/json' -X POST -d "$data" https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage
35+
fi
3436
fi
3537
}
3638

0 commit comments

Comments
 (0)