mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-22 15:35:09 +00:00
no more convert old config
This commit is contained in:
parent
21afd4e62e
commit
0d7fee3bd2
19
bashbot.sh
19
bashbot.sh
@ -26,7 +26,7 @@
|
|||||||
# 8 - curl/wget missing
|
# 8 - curl/wget missing
|
||||||
# 10 - not bash!
|
# 10 - not bash!
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v1.21-dev-11-ge817328
|
#### $$VERSION$$ v1.21-dev-12-g21afd4e
|
||||||
##################################################################
|
##################################################################
|
||||||
# shellcheck disable=SC2140,SC2031,SC2120,SC1091,SC1117,SC2059
|
# shellcheck disable=SC2140,SC2031,SC2120,SC1091,SC1117,SC2059
|
||||||
|
|
||||||
@ -203,11 +203,8 @@ LOGDIR="${RUNDIR:-.}/logs"
|
|||||||
if [[ -z "${BOTTOKEN}" && ! -f "${BOTCONFIG}.jssh" ]]; then
|
if [[ -z "${BOTTOKEN}" && ! -f "${BOTCONFIG}.jssh" ]]; then
|
||||||
# BOTCONFIG does not exist, create
|
# BOTCONFIG does not exist, create
|
||||||
printf '["bot_config_key"]\t"config_key_value"\n' >>"${BOTCONFIG}.jssh"
|
printf '["bot_config_key"]\t"config_key_value"\n' >>"${BOTCONFIG}.jssh"
|
||||||
# convert old token
|
# ask user for bot token
|
||||||
if [ -r "${TOKENFILE}" ]; then
|
if [ -z "${INTERACTIVE}" ] && [ "$1" != "init" ]; then
|
||||||
token="$(< "${TOKENFILE}")"
|
|
||||||
# no old token, ask user
|
|
||||||
elif [ -z "${INTERACTIVE}" ] && [ "$1" != "init" ]; then
|
|
||||||
printf "Running headless, set BOTTOKEN or run ${SCRIPT} init first!\n"
|
printf "Running headless, set BOTTOKEN or run ${SCRIPT} init first!\n"
|
||||||
exit 2
|
exit 2
|
||||||
else
|
else
|
||||||
@ -220,10 +217,8 @@ if [[ -z "${BOTTOKEN}" && ! -f "${BOTCONFIG}.jssh" ]]; then
|
|||||||
|
|
||||||
# no botadmin, setup botadmin
|
# no botadmin, setup botadmin
|
||||||
if [ -z "$(getConfigKey "botadmin")" ]; then
|
if [ -z "$(getConfigKey "botadmin")" ]; then
|
||||||
# convert old admin
|
# ask user for bot admin
|
||||||
if [ -r "${BOTADMIN}" ]; then
|
if [ -z "${INTERACTIVE}" ]; then
|
||||||
admin="$(< "${BOTADMIN}")"
|
|
||||||
elif [ -z "${INTERACTIVE}" ]; then
|
|
||||||
printf "Running headless, set botadmin to AUTO MODE!\n"
|
printf "Running headless, set botadmin to AUTO MODE!\n"
|
||||||
else
|
else
|
||||||
printf "${RED}ENTER BOT ADMIN...${NN}"
|
printf "${RED}ENTER BOT ADMIN...${NN}"
|
||||||
@ -250,10 +245,6 @@ if [[ -z "${BOTTOKEN}" && ! -f "${BOTCONFIG}.jssh" ]]; then
|
|||||||
# setup count file
|
# setup count file
|
||||||
if [ ! -f "${COUNTFILE}.jssh" ]; then
|
if [ ! -f "${COUNTFILE}.jssh" ]; then
|
||||||
printf '["counted_user_chat_id"]\t"num_messages_seen"\n' >> "${COUNTFILE}.jssh"
|
printf '["counted_user_chat_id"]\t"num_messages_seen"\n' >> "${COUNTFILE}.jssh"
|
||||||
# convert old file on creation
|
|
||||||
if [ -r "${COUNTFILE}" ];then
|
|
||||||
sed 's/COUNT/\[\"/;s/$/\"\]\t\"1\"/' < "${COUNTFILE}" >> "${COUNTFILE}.jssh"
|
|
||||||
fi
|
|
||||||
elif [ ! -w "${COUNTFILE}.jssh" ]; then
|
elif [ ! -w "${COUNTFILE}.jssh" ]; then
|
||||||
printf "${RED}ERROR: Can't write to ${COUNTFILE}!.${NN}"
|
printf "${RED}ERROR: Can't write to ${COUNTFILE}!.${NN}"
|
||||||
ls -l "${COUNTFILE}.jssh"
|
ls -l "${COUNTFILE}.jssh"
|
||||||
|
Loading…
Reference in New Issue
Block a user