ai_member_xiaokui/scripts/daily_feedback_report.sh
2026-05-09 08:10:02 +08:00

58 lines
2.2 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 任务名称:每日用户反馈问题整理日报
# 执行时间每天早上9:30
# 归属 Agent小葵 xiaokui
set -e
# 1. 环境配置
export PATH=/root/.nvm/versions/node/v24.14.0/bin:$PATH
LOG_FILE="/var/log/daily_feedback_report.log"
DOC_URL="https://makee-interactive.feishu.cn/wiki/ApVZw0fxGiv48ekuRS8cIfUjnRf"
RECEIVE_USER_ID="ou_9d4df593d0419d705274947c5cec5ada"
log() {
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1" >> "$LOG_FILE"
}
log "每日用户反馈日报任务开始执行"
# 2. 拉取最新微信用户反馈近24小时
NEW_FEEDBACK=$(mysql -h bj-cdb-8frbdwju.sql.tencentcdb.com -P 25413 -u chatbot -p'xhuBx7d@uT2gUVv' vala_test -s -e "SELECT COUNT(*) FROM wechat_group_message WHERE msg_time >= DATE_SUB(NOW(), INTERVAL 24 HOUR);")
# 3. 组织消息内容
if [ "$NEW_FEEDBACK" -gt 0 ]; then
CONTENT="⏰ 【每日用户反馈问题整理】
📅 日期:$(date +'%Y-%m-%d')
✅ 昨日新增用户反馈:${NEW_FEEDBACK}
📄 最新整理文档链接:${DOC_URL}
🔍 文档已按优先级排序P0→P1→P2→P3可直接查看重点问题
👥 如需分享给其他同事,可直接在飞书文档中设置查看权限即可"
else
CONTENT="⏰ 【每日用户反馈问题整理】
📅 日期:$(date +'%Y-%m-%d')
✅ 昨日无新增用户反馈
📄 历史问题整理文档链接:${DOC_URL}
🔍 文档已按优先级排序,可随时查看历史问题"
fi
# 4. 发送飞书消息Bot身份
APP_ID=$(jq -r '.apps[0].appId' /root/.openclaw/credentials/xiaokui/config.json)
APP_SECRET=$(jq -r '.apps[0].appSecret' /root/.openclaw/credentials/xiaokui/config.json)
TOKEN=$(curl -s -X POST "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" \
-H "Content-Type: application/json" \
-d "{\"app_id\":\"$APP_ID\",\"app_secret\":\"$APP_SECRET\"}" \
| jq -r '.tenant_access_token')
curl -s -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"receive_id\": \"$RECEIVE_USER_ID\",
\"msg_type\": \"text\",
\"content\": \"{\\\"text\\\":\\\"${CONTENT}\\\"}\"
}" >> "$LOG_FILE" 2>&1
log "任务执行完成,消息已发送"
exit 0