xiaowei-system/scripts/feishu-alert.sh

17 lines
542 B
Bash
Executable File
Raw 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
# 飞书告警(用 send_message不需 webhook
# 用法: feishu-alert.sh "消息内容"
MESSAGE="$1"
[ -z "$MESSAGE" ] && exit 1
# 用 hermes 自带的 send_message (chat_id 从 .env 拿 HOME_CHANNEL)
HOME_CHAT=$(grep "^FEISHU_HOME_CHANNEL=" /home/muc/.hermes/.env 2>/dev/null | cut -d= -f2 | sed 's/"//g')
[ -z "$HOME_CHAT" ] && {
echo "WARN: FEISHU_HOME_CHANNEL 未配置" >&2
exit 1
}
# 用 hermes 发送
timeout 30 hermes send message --platform feishu --chat-id "$HOME_CHAT" --content "$MESSAGE" 2>&1 | tail -1