从 shell 发送飞书(Lark)机器人消息

#!/bin/sh
WEBHOOK=YOUR_WEBHOOK_HERE
if [ "$*" == "--help" ] ; then
echo "Usage: lark_msg <msg>..."
exit 0
fi
msg="$*"
echo "sending:" "$*" | systemd-cat -t lark_msg -p info
json=$(jq -n --arg msg "$msg" '{"msg_type":"text","content":{"text": $msg}}')
ret=$(curl -s -X POST -H "Content-Type: application/json" -d "$json" "$WEBHOOK" )
if [ "$( echo "$ret" | jq .StatusCode )" != "0" ] ; then
echo "failed:" "$ret" | systemd-cat -t lark_msg -p warning
fi
view raw lark_msg hosted with ❤ by GitHub