Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
MusclePr committed Apr 23, 2024
1 parent b617c5e commit b6ee8af
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions scripts/rest_api.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/bash
ORGDIR=$(dirname $(readlink -fn ${0}))
source ${ORGDIR}/helper_functions.sh
SCRIPT=$(basename "${0}")
ORGPATH=$(readlink -fn "${0}")
ORGDIR=$(dirname "${ORGPATH}")
#shellcheck source=scripts/helper_functions.sh
source "${ORGDIR}/helper_functions.sh"
help="-h|--help"
if [ $# -lt 1 ] || [[ ${1} =~ ${help} ]]; then
cat << EOF
Usage: $(basename ${0}) <api> [options]
Usage: ${SCRIPT} <api> [options]
api:
announce <json> ... announce message.
ban <json> ... ban player.
Expand Down Expand Up @@ -41,33 +44,34 @@ if [[ ${api} =~ ${api_required_json} ]]; then
if [ "${json}" = "-" ]; then
json="$(cat -)"
elif [[ ! ${json} =~ ^\{ ]]; then
usage="Usage: ${SCRIPT} ${api}"
case ${api} in
"announce")
if [[ ${json} =~ ${help} ]]; then
echo "Usage: $(basename ${0}) ${api} <message>"
echo "${usage} <message>"
exit 1
fi
json="{\"message\":\"${2}\"}"
;;
"ban")
if [[ ${json} =~ ${help} ]]; then
echo "Usage: $(basename ${0}) ${api} <steam_00000000000000000> [message]"
echo "${usage} <steam_00000000000000000> [message]"
exit 1
fi
msg=${3:-You are banned.}
json="{\"userid\":\"${2}\",\"message\":\"${msg}\"}"
;;
"kick")
if [[ ${json} =~ ${help} ]]; then
echo "Usage: $(basename ${0}) ${api} <steam_00000000000000000> [message]"
echo "${usage} <steam_00000000000000000> [message]"
exit 1
fi
msg=${3:-You are kicked.}
json="{\"userid\":\"${2}\",\"message\":\"${msg}\"}"
;;
"shutdown")
if [[ ${json} =~ ${help} ]]; then
echo "Usage: $(basename ${0}) ${api} <sec> [message]"
echo "${usage} <sec> [message]"
exit 1
fi
sec=${2}
Expand All @@ -76,7 +80,7 @@ if [[ ${api} =~ ${api_required_json} ]]; then
;;
"unban")
if [[ ${json} =~ ${help} ]]; then
echo "Usage: $(basename ${0}) ${api} <steam_00000000000000000>"
echo "${usage} <steam_00000000000000000>"
exit 1
fi
json="{\"userid\":\"${2}\"}"
Expand Down

0 comments on commit b6ee8af

Please sign in to comment.