This repository has been archived on 2023-02-28. You can view files and clone it, but cannot push or open issues or pull requests.
bog-bbot-archive/src/shell/functions.sh

23 lines
620 B
Bash
Executable File

#!/bin/bash
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
[[ -n $MY_PATH/.env ]] && source $MY_PATH/.env || (echo "Please create $MY_PATH/.env as $MY_PATH/.env.example" && exit 1)
sendmsg() {
chan="$1"
msg="${@:2}"
[[ ! $chan || ! $msg ]] && echo "Please select user and message." && exit 1
curl -s -H "X-Auth-Token: $API_TOKEN" \
-H "X-User-Id: $API_ID" \
-H "Content-type:application/json" \
http://192.168.9.6:10140/api/v1/chat.postMessage \
-d "{ \"channel\": \"$chan\", \"text\": \"$msg\" }" > /dev/null 2>&1
}
$@