Skip to content

Instantly share code, notes, and snippets.

@lideming
Last active November 11, 2022 01:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lideming/3ea6b3502c69d2f928cad5f8b7aab4d5 to your computer and use it in GitHub Desktop.
Save lideming/3ea6b3502c69d2f928cad5f8b7aab4d5 to your computer and use it in GitHub Desktop.
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