mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-22 15:35:09 +00:00
fix keyDB_async, count cleanup only on bot start
This commit is contained in:
parent
5b2582129b
commit
f4c1657270
10
bashbot.sh
10
bashbot.sh
@ -11,7 +11,7 @@
|
|||||||
# 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.96-pre-23-geb89aee
|
#### $$VERSION$$ v0.96-pre-24-g5b25821
|
||||||
#
|
#
|
||||||
# Exit Codes:
|
# Exit Codes:
|
||||||
# - 0 sucess (hopefully)
|
# - 0 sucess (hopefully)
|
||||||
@ -247,9 +247,6 @@ if ! _is_function jssh_newDB ; then
|
|||||||
exit 6
|
exit 6
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# cleanup (remove double entries) countfile on startup
|
|
||||||
[ "${SOURCE}" != "yes" ] && jssh_deleteKeyDB_async "CLEAN_COUNTER_DATABASE_ON_STARTUP" "${COUNTFILE}"
|
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# BASHBOT COMMON functions
|
# BASHBOT COMMON functions
|
||||||
# $1 URL, $2 filename in DATADIR
|
# $1 URL, $2 filename in DATADIR
|
||||||
@ -803,6 +800,11 @@ start_bot() {
|
|||||||
# shellcheck disable=SC2064
|
# shellcheck disable=SC2064
|
||||||
trap "kill -9 $!; exit" EXIT INT HUP TERM QUIT
|
trap "kill -9 $!; exit" EXIT INT HUP TERM QUIT
|
||||||
fi
|
fi
|
||||||
|
# cleanup countfile on startup
|
||||||
|
[ "${SOURCE}" != "yes" ] && jssh_deleteKeyDB_async "CLEAN_COUNTER_DATABASE_ON_STARTUP" "${COUNTFILE}"
|
||||||
|
|
||||||
|
##########
|
||||||
|
# bot is ready, start processing updates ...
|
||||||
while true; do
|
while true; do
|
||||||
# adaptive sleep in ms rounded to next 0.1 s
|
# adaptive sleep in ms rounded to next 0.1 s
|
||||||
sleep "$(printf '%.1f' "$((nextsleep))e-3")"
|
sleep "$(printf '%.1f' "$((nextsleep))e-3")"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
# 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.96-pre-17-gdeeef7e
|
#### $$VERSION$$ v0.96-pre-24-g5b25821
|
||||||
#
|
#
|
||||||
# source from commands.sh to use jsonDB functions
|
# source from commands.sh to use jsonDB functions
|
||||||
#
|
#
|
||||||
@ -280,9 +280,9 @@ jssh_deleteKeyDB_async() {
|
|||||||
[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
|
[[ "$1" =~ ^[-a-zA-Z0-9,._]+$ ]] || return 3
|
||||||
local DB; DB="$(jssh_checkDB "$2")"
|
local DB; DB="$(jssh_checkDB "$2")"
|
||||||
declare -A oldARR
|
declare -A oldARR
|
||||||
jssh_readDB_async "oldARR" "$2" || return "$?"
|
Json2Array "oldARR" <"${DB}"
|
||||||
unset oldARR["$1"]
|
unset oldARR["$1"]
|
||||||
jssh_writeDB_async "oldARR" "$2"
|
Array2Json "oldARR" >"${DB}"
|
||||||
}
|
}
|
||||||
|
|
||||||
jssh_getKeyDB_async() {
|
jssh_getKeyDB_async() {
|
||||||
|
Loading…
Reference in New Issue
Block a user