mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2025-01-15 18:36:48 +00:00
fix some update messages are ignored
This commit is contained in:
parent
5b94265b09
commit
85ee75705a
16
bashbot.sh
16
bashbot.sh
@ -11,7 +11,7 @@
|
||||
# This file is public domain in the USA and all free countries.
|
||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||
#
|
||||
#### $$VERSION$$ v1.2-dev2-27-g32a6ef2
|
||||
#### $$VERSION$$ v1.2-dev2-28-g5b94265
|
||||
#
|
||||
# Exit Codes:
|
||||
# - 0 success (hopefully)
|
||||
@ -85,10 +85,10 @@ check_token(){
|
||||
return 1
|
||||
}
|
||||
# log $1 to ERRORLOG with date
|
||||
log_error(){ printf "%s: %s\n" "$(date)" "$*" >>"${ERRORLOG}"; }
|
||||
log_debug(){ printf "%s: %s\n" "$(date)" "$*" >>"${DEBUGLOG}"; }
|
||||
log_message(){ printf "%s: %s\n" "$(date)" "$*" >>"${MESSAGELOG}"; }
|
||||
log_update(){ printf "%s: %s\n" "$(date)" "$*" >>"${UPDATELOG}"; }
|
||||
log_error(){ printf "%s: %b\n" "$(date)" "$*" >>"${ERRORLOG}"; }
|
||||
log_debug(){ printf "%s: %b\n" "$(date)" "$*" >>"${DEBUGLOG}"; }
|
||||
log_message(){ printf "\n%s: %b\n" "$(date)" "$*" >>"${MESSAGELOG}"; }
|
||||
log_update(){ printf "%s: %b\n" "$(date)" "$*" >>"${UPDATELOG}"; }
|
||||
# additional tests if we run in debug mode
|
||||
export BASHBOTDEBUG
|
||||
# debug should always last argument
|
||||
@ -667,7 +667,9 @@ JsonGetValue() {
|
||||
# processing of updates starts here
|
||||
process_updates() {
|
||||
local max num debug="$1"
|
||||
max="$(sed <<< "${UPDATE}" '/\["result",[0-9]*\]/!d' | tail -1 | sed 's/\["result",//g;s/\].*//g')"
|
||||
set -x
|
||||
max="$(grep -F ',"update_id"]' <<< "${UPDATE}" | tail -1 | cut -d , -f 2 )"
|
||||
set +x
|
||||
Json2Array 'UPD' <<<"${UPDATE}"
|
||||
for ((num=0; num<=max; num++)); do
|
||||
process_client "$num" "${debug}"
|
||||
@ -678,7 +680,7 @@ process_client() {
|
||||
local num="$1" debug="$2"
|
||||
pre_process_message "${num}"
|
||||
# log message on debug
|
||||
[[ -n "${debug}" ]] && log_message "New Message ==========\n${UPDATE}"
|
||||
[[ -n "${debug}" ]] && log_message "New Message ==========\n$(grep -F '["result",'"${num}" <<<"${UPDATE}")"
|
||||
|
||||
# check for users / groups to ignore
|
||||
jssh_updateArray_async "BASHBOTBLOCKED" "${BLOCKEDFILE}"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v1.2-1-gd30a700
|
||||
#### $$VERSION$$ v1.2-dev2-28-g5b94265
|
||||
|
||||
############
|
||||
# NOTE: you MUST run install-hooks.sh again when updating this file!
|
||||
@ -68,7 +68,7 @@ fi
|
||||
if command -v codespell &>/dev/null; then
|
||||
echo "Running codespell"
|
||||
echo "............................"
|
||||
codespell --skip="*.log,*.html,*.txt,.git*,jsonDB-keyboard" -L "ba"
|
||||
codespell --skip="*.zip,*gz,*.log,*.html,*.txt,.git*,jsonDB-keyboard" -L "ba"
|
||||
echo "if there are (to many) typo's shown, consider running:"
|
||||
echo "codespell -i 3 -w --skip=\"*.log,*.html,*.txt,.git*,examples\" -L \"ba\""
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user