39 lines
1.0 KiB
Bash
39 lines
1.0 KiB
Bash
#!/bin/bash
|
|
# 检测 GitHub API 限额状态,触发限额时发送 Telegram 通知
|
|
|
|
FLAG_FILE="/root/.openclaw/workspace/seo/logs/rate_limit_flag.json"
|
|
TELEGRAM_TOKEN=$(grep -o '"token":"[^"]*"' /root/.openclaw/config.yml 2>/dev/null | head -1 | cut -d'"' -f4)
|
|
CHAT_ID="5117446326"
|
|
|
|
if [ ! -f "$FLAG_FILE" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
# 读取限额信息
|
|
if command -v python3 &> /dev/null; then
|
|
INFO=$(python3 -c "
|
|
import json
|
|
with open('$FLAG_FILE') as f:
|
|
d = json.load(f)
|
|
print(f\"剩余: {d.get('remaining', '?')}/{d.get('limit', '?')}, 检测时间: {d.get('detected_at', '?')}\")
|
|
\" 2>/dev/null)
|
|
else
|
|
INFO=$(cat "$FLAG_FILE")
|
|
fi
|
|
|
|
# 发送 Telegram 消息
|
|
if [ -n "$TELEGRAM_TOKEN" ] && [ -n "$CHAT_ID" ]; then
|
|
MSG="⚠️ SEO进化猎手检测到 GitHub API 限额触发!
|
|
|
|
$INFO
|
|
|
|
请手动检查后恢复任务。"
|
|
|
|
curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_TOKEN/sendMessage" \
|
|
-d "chat_id=$CHAT_ID" \
|
|
-d "text=$MSG" \
|
|
> /dev/null 2>&1
|
|
fi
|
|
|
|
# 保留标志文件,等待人工干预
|