diff --git a/content/entrypoint.sh b/content/entrypoint.sh index 12eef2c..0dc4cb4 100644 --- a/content/entrypoint.sh +++ b/content/entrypoint.sh @@ -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 @@ -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 }