Slackme - quick send to slack hook
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/bash | |
function slackme { | |
local MESSAGE=${1} | |
if [ "${MESSAGE}" == "" ]; then | |
echo "Missing first param: slackme {message}" | |
return | |
fi | |
if [ "${SLACK_HOOK_URL}" == "" ]; then | |
echo "Missing env var: SLACK_HOOK_URL" | |
return | |
fi | |
local CHANNEL=${2:-"general"} | |
local USERNAME=${3:-"slackme"} | |
local ICON_EMOJI=${4:-":robot_face:"} | |
local JSON_DATA='{"channel":"#'${CHANNEL}'", "username":"'${USERNAME}'", "icon_emoji":"'${ICON_EMOJI}'", "text": "'${MESSAGE}'"}' | |
curl -s -XPOST -H 'Content-type: application/json' --data "${JSON_DATA}" "${SLACK_HOOK_URL}" >/dev/null | |
} | |
# params | |
SLACK_URL=${SLACK_HOOK_URL:-"https://hooks.slack.com/services/......"} | |
# main | |
slackme "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Download:
curl -LO https://gist.githubusercontent.com/josue/3b83a78cd99016dd828cada2de7c4c3a/raw/slackme.sh && chmod +x slackme.sh
Usage: