Merge branch 'develop' into dist/ubuntu/bionic/develop
This commit is contained in:
commit
7b57394cdd
@ -4,13 +4,14 @@ set -eo pipefail
|
||||
|
||||
RC_HOST_URL=https://rocket.cadoles.com
|
||||
RC_CONFIG_DIR="$HOME/.config/rocket-send"
|
||||
RC_EMOJI=":cadoles:"
|
||||
RC_LOGIN=
|
||||
RC_PASSWORD=
|
||||
RC_CLIENT_ID=
|
||||
RC_CLIENT_TOKEN=
|
||||
RC_MESSAGE=
|
||||
RC_CHANNEL=
|
||||
RC_ALIAS=
|
||||
RC_EMOJI=
|
||||
|
||||
function help {
|
||||
cat<<EOF 1>&2
|
||||
@ -23,7 +24,7 @@ Options:
|
||||
-m, --message [Obligatoire] Message à envoyer
|
||||
-s, --server URL racine du serveur Rocket.Chat
|
||||
-e, --emoji Emoji à utiliser comme avatar pour le message
|
||||
-n, --nickname Pseudonyme à utiliser pour le message
|
||||
-a, --alias Alias à utiliser pour le message
|
||||
--config-dir Chemin vers le répertoire de configuration, par défaut $HOME/.config/rocket-send
|
||||
-h, --help Afficher l'aide
|
||||
EOF
|
||||
@ -39,6 +40,9 @@ function get_options {
|
||||
-e|--emoji)
|
||||
RC_EMOJI="$2"
|
||||
;;
|
||||
-a|--alias)
|
||||
RC_ALIAS="$2"
|
||||
;;
|
||||
--config-dir)
|
||||
RC_CONFIG_DIR="$2"
|
||||
;;
|
||||
@ -81,21 +85,23 @@ function login {
|
||||
function post_message {
|
||||
local channel=$1
|
||||
local message=$2
|
||||
local emoji=$3
|
||||
local alias=$4
|
||||
|
||||
curl --silent \
|
||||
-H "X-Auth-Token: $RC_CLIENT_TOKEN" \
|
||||
-H "X-User-Id: $RC_CLIENT_ID" \
|
||||
-H "Content-Type:application/json" \
|
||||
"$RC_HOST_URL/api/v1/chat.postMessage" \
|
||||
-d "{ \"channel\": \"$channel\", \"text\": \"$message\" }"
|
||||
-d "{ \"channel\": \"$channel\", \"text\": \"$message\", \"emoji\": \"$emoji\", \"alias\": \"$alias\" }"
|
||||
}
|
||||
|
||||
function main {
|
||||
get_config
|
||||
get_options $@
|
||||
get_options "$@"
|
||||
|
||||
login "$RC_LOGIN" "$RC_PASSWORD"
|
||||
post_message "$RC_CHANNEL" "$RC_MESSAGE"
|
||||
post_message "$RC_CHANNEL" "$RC_MESSAGE" "$RC_EMOJI" "$RC_ALIAS"
|
||||
}
|
||||
|
||||
main $@
|
||||
main "$@"
|
Loading…
Reference in New Issue
Block a user