从 shell 发送飞书(Lark)机器人消息
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |