mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2025-01-30 17:18:26 +00:00
add simple check for correct JSON.sh and commands.sh file
This commit is contained in:
parent
f412a2921a
commit
63ef6781a2
12
bashbot.sh
12
bashbot.sh
@ -10,13 +10,13 @@
|
|||||||
# This file is public domain in the USA and all free countries.
|
# This file is public domain in the USA and all free countries.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.70-dev2-7-g1957133
|
#### $$VERSION$$ v0.70-dev2-8-gf412a29
|
||||||
#
|
#
|
||||||
# Exit Codes:
|
# Exit Codes:
|
||||||
# - 0 sucess (hopefully)
|
# - 0 sucess (hopefully)
|
||||||
# - 1 can't change to dir
|
# - 1 can't change to dir
|
||||||
# - 2 can't write to tmp, count or token
|
# - 2 can't write to tmp, count or token
|
||||||
# - 3 user / command not found
|
# - 3 user / command / file not found
|
||||||
# - 4 unkown command
|
# - 4 unkown command
|
||||||
# - 5 cannot connect to telegram bot
|
# - 5 cannot connect to telegram bot
|
||||||
|
|
||||||
@ -62,7 +62,9 @@ if [ ! -f "${TOKENFILE}" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
JSONSHFILE="${BASHBOT_JSONSH:-${RUNDIR}}/JSON.sh/JSON.sh"
|
JSONSHFILE="${BASHBOT_JSONSH:-${RUNDIR}/JSON.sh/JSON.sh}"
|
||||||
|
[[ "${JSONSHFILE}" != *"/JSON.sh" ]] && echo -e "${RED}ERROR: \"${JSONSHFILE}\" ends not with \"JSONS.sh\".${NC}" && exit 3
|
||||||
|
|
||||||
if [ ! -f "${JSONSHFILE}" ]; then
|
if [ ! -f "${JSONSHFILE}" ]; then
|
||||||
echo "Seems to be first run, Downloading ${JSONSHFILE}..."
|
echo "Seems to be first run, Downloading ${JSONSHFILE}..."
|
||||||
mkdir "JSON.sh" 2>/dev/null;
|
mkdir "JSON.sh" 2>/dev/null;
|
||||||
@ -111,7 +113,9 @@ elif [ ! -w "${COUNTFILE}" ]; then
|
|||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
COMMANDS="${BASHBOT_COMMANDS:-${RUNDIR}}/commands.sh"
|
COMMANDS="${BASHBOT_COMMANDS:-${RUNDIR}/commands.sh}"
|
||||||
|
[[ "${COMMANDS}" != *".sh" ]] && echo -e "${RED}ERROR: \"${COMMANDS}\" ends not with \".sh\".${NC}" && exit 3
|
||||||
|
|
||||||
if [ "$1" != "source" ]; then
|
if [ "$1" != "source" ]; then
|
||||||
if [ ! -f "${COMMANDS}" ] || [ ! -r "${COMMANDS}" ]; then
|
if [ ! -f "${COMMANDS}" ] || [ ! -r "${COMMANDS}" ]; then
|
||||||
${CLEAR}
|
${CLEAR}
|
||||||
|
@ -47,6 +47,15 @@ Full path to bash script containing your commands, default: './commands.sh'
|
|||||||
export BASHBOT_COMMANDS "/etc/bashbot/bot1/commands.sh" # multibot configuration bot 1
|
export BASHBOT_COMMANDS "/etc/bashbot/bot1/commands.sh" # multibot configuration bot 1
|
||||||
export BASHBOT_COMMANDS "/etc/bashbot/bot2/commands.sh" # multibot configuration bot 2
|
export BASHBOT_COMMANDS "/etc/bashbot/bot2/commands.sh" # multibot configuration bot 2
|
||||||
```
|
```
|
||||||
|
#### BASHBOT_JSONSH
|
||||||
|
Full path to JSON.sh script, default: './JSON.sh/JSON.sh'
|
||||||
|
```bash
|
||||||
|
unset BASHBOT_JSONSH # telegram-bot-bash/JSON.sh/JSON.sh (default)
|
||||||
|
export BASHBOT_JSONSH "" # telegram-bot-bash/JSON.sh/JSON.sh
|
||||||
|
|
||||||
|
export BASHBOT_JSONSH "/usr/local/bin/JSON.sh" # installed in /usr/local/bin
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
### Change config values
|
### Change config values
|
||||||
|
|
||||||
@ -122,5 +131,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms.
|
|||||||
|
|
||||||
#### [Prev Notes for Developers](7_develop.md)
|
#### [Prev Notes for Developers](7_develop.md)
|
||||||
|
|
||||||
#### $$VERSION$$ v0.70-dev2-5-gfe5840d
|
#### $$VERSION$$ v0.70-dev2-8-gf412a29
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user