Skip to content

Instantly share code, notes, and snippets.

@musaprg
Last active November 29, 2021 09:34
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 musaprg/04cc3c985bdf44c433258e7b17cb4d36 to your computer and use it in GitHub Desktop.
Save musaprg/04cc3c985bdf44c433258e7b17cb4d36 to your computer and use it in GitHub Desktop.
stdinの内容をDiscordに通知するくん
#!/bin/bash
set -euo pipefail
if [ -z "$DISCORD_WEBHOOK_URL" ]; then
echo '$DISCORD_WEBHOOK_URL is not set. Please set and try again.'
exit 1
fi
if [ -t 0 ]; then
echo 'Usage: echo "<message>" | notify_discord'
exit 1
fi
cat - | curl -H 'Content-Type: application/json' \
-X POST \
-d "{\"content\": \"$(cat)\"}" "$DISCORD_WEBHOOK_URL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment