useful-scripts/slackit.sh

13 lines
446 B
Bash
Raw Normal View History

2024-09-13 12:57:54 +00:00
#!/bin/bash -e
message=$(echo $1 | tr -d '\n' | tr -d '"')
username=$(echo $2 | tr -d '\n' | tr -d '"')
SLACK_URL=https://hooks.slack.com/services/SDS9SDID9D9SJS9SDS
if [ -z "$username" ]; then
username="Server"
fi
if [ ! -z "$message" ]; then
curl -X POST -H 'Content-type: application/json' --data "{ \"channel\": \"#notifications\", \"username\": \"${username}\", \"icon_emoji\": \":bot:\", \"text\": \"${message}\" }" $SLACK_URL
fi