SuperAPI AI Directory

serverchan

General & other

View repository

Updated 10-15 21:36

About this skill

Server Chan · WeChat Message Push

Push messages to WeChat/App via Server Chan. Logic aligned with easychen/serverchan-sdk, Compatible with both Server Chan Turbo (SCT) and Server Chan³ (SC3), automatically selecting the endpoint based on the SendKey prefix, no extra configuration needed:

  • SendKey starts with sctp → SC3:https://<num>.push.ft07.com/send/<sendkey>.send(num taken from sctp<num>t)
  • the rest (SCT…)→ Turbo:https://sctapi.ftqq.com/<sendkey>.send

This skill is self-contained; all commands are inlined in this file and do not depend on any external script files—just copy and run directly.

Security red lines (must be followed)

  • Never echo / print / log SERVERCHAN_SENDKEY—it will enter stdout and be collected and displayed by the platform. A SendKey is equivalent to push credentials; if leaked, others can send messages on your behalf.
  • Do not add -v/--verboseto curl (the endpoint URL contains the SendKey and will be written to logs). The commands below already use -sS and do not echo the URL.
  • Use --data-urlencode to pass title/desp; escaping is handled by curl, no need to manually assemble JSON.

Step 1: Self-check environment variables (must be done first)

if [ -z "${SERVERCHAN_SENDKEY:-}" ]; then
  echo "[serverchan] ✗ 缺少环境变量 SERVERCHAN_SENDKEY,已停止。"
  echo "  请在 Server 酱后台获取 SendKey 并加入当前项目环境变量 SERVERCHAN_SENDKEY:"
  echo "  · Server酱Turbo(SCT):https://sct.ftqq.com  → SendKey 形如 SCTxxxxxx"
  echo "  · Server酱³(SC3)    :https://sc3.ft07.com   → SendKey 形如 sctp<数字>t<token>"
else
  case "$SERVERCHAN_SENDKEY" in
    sctp*) echo "[serverchan] ✓ SendKey 已配置(SC3 / sctp…,长度 ${#SERVERCHAN_SENDKEY})" ;;
    SCT*)  echo "[serverchan] ✓ SendKey 已配置(SCT / SCT…,长度 ${#SERVERCHAN_SENDKEY})" ;;
    *)     echo "[serverchan] ⚠ SendKey 已配置,但前缀既非 sctp(SC3) 也非 SCT(Turbo),请确认是否正确" ;;
  esac
fi

If a missing prompt appears,do not hardcode any SendKey, ask the user for it and write it to the current project environment variable SERVERCHAN_SENDKEY before continuing.

Step 2: Send a message (inline command, run directly)

Replace title、desp with the content you want to push. The endpoint will be automatically selected based on the SendKey prefix:

KEY="$SERVERCHAN_SENDKEY"
case "$KEY" in
  sctp*)
    NUM="$(printf '%s' "$KEY" | sed -n 's/^sctp\([0-9][0-9]*\)t.*/\1/p')"
    URL="https://${NUM}.push.ft07.com/send/${KEY}.send" ;;
  *)
    URL="https://sctapi.ftqq.com/${KEY}.send" ;;
esac

curl -sS -X POST "$URL" \
  --data-urlencode "title=部署完成" \
  --data-urlencode "desp=服务已上线 ✅

版本 v1.2.3"
  • desp supports Markdown; for multiple lines just write newlines directly (the example body above contains title + blank line + version number).
  • The server returns {"code":0,...} to indicate success;code non-0 or HTTP non-2xx indicates failure; troubleshoot based on the returned content.

Optional parameters (tags / short / channel, etc.)

Server Chan supports additional fields; append --data-urlencode to pass them through:

curl -sS -X POST "$URL" \
  --data-urlencode "title=服务器告警" \
  --data-urlencode "desp=CPU **95%**,请及时处理" \
  --data-urlencode "tags=运维|告警" \
  --data-urlencode "short=CPU 95%"

Common fields:tags(| separate multiple tags),short(card summary),channel(specify channel),noip(hide calling IP).

Paradigm: Push execution results to yourself

KEY="$SERVERCHAN_SENDKEY"
case "$KEY" in
  sctp*) NUM="$(printf '%s' "$KEY" | sed -n 's/^sctp\([0-9][0-9]*\)t.*/\1/p')"; URL="https://${NUM}.push.ft07.com/send/${KEY}.send" ;;
  *)     URL="https://sctapi.ftqq.com/${KEY}.send" ;;
esac

if some_task; then
  curl -sS -X POST "$URL" --data-urlencode "title=任务成功" --data-urlencode "desp=✅ 已完成于 $(date '+%F %T')" >/dev/null
else
  curl -sS -X POST "$URL" --data-urlencode "title=任务失败" --data-urlencode "desp=❌ 请查看日志排查" --data-urlencode "short=任务失败" >/dev/null
fi

Batch/high-frequency scenarios: pleasemerge multiple results into onesummary push, respect the free quota (limited per day), and avoid spamming.