add new commands for status endpoints
This commit is contained in:
16
mc
16
mc
@ -20,6 +20,9 @@ declare -rA commands=(
|
||||
[list-players]='GET'
|
||||
[website]='GET'
|
||||
[map]='GET'
|
||||
[status-minecraft]='GET'
|
||||
[status-bedrock]='GET'
|
||||
[status-sftp]='GET'
|
||||
[ban]='POST {"username": "%s"}'
|
||||
[unban]='POST {"username": "%s"}'
|
||||
[say]='POST {"message": "%s"}'
|
||||
@ -42,6 +45,16 @@ function rest() {
|
||||
fi
|
||||
}
|
||||
|
||||
function status_format() {
|
||||
local tmp=(${1//-/ })
|
||||
local second=${tmp[1]}
|
||||
if [[ "$second" == "sftp" ]]; then
|
||||
printf "${second^^}"
|
||||
return
|
||||
fi
|
||||
printf "${second^}"
|
||||
}
|
||||
|
||||
function usage() {
|
||||
printf "API key for my-mc must be exported using 'export MY_MC_API_KEY=<my-mc api key>'\n\n"
|
||||
printf "Positional arguments will fill the JSON objects with values from left to right.\n\n"
|
||||
@ -61,6 +74,9 @@ for command in "${!commands[@]}"; do
|
||||
if [[ "$(first "${commands[$1]}")" == "POST" ]]; then
|
||||
curl -sS "${headers[@]}" -X "$(first "${commands[$1]}")" "${base_url}${command}" -d "$(printf "$(rest ${commands[$1]})\n" "${args[@]}")"
|
||||
echo ""
|
||||
elif [[ "${command}" =~ ^"status" ]]; then
|
||||
curl -sS "${headers[@]}" -X "$(first "${commands[$1]}")" "${base_url}status/$(status_format ${command})"
|
||||
echo ""
|
||||
else
|
||||
curl -sS "${headers[@]}" -X "$(first "${commands[$1]}")" "${base_url}${command}"
|
||||
echo ""
|
||||
|
Reference in New Issue
Block a user