Skip to content

Instantly share code, notes, and snippets.

@lideming
Last active Nov 11, 2022
Embed
What would you like to do?
Send lark/feishu bot message from shell
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment