added getreplytext and fixed gettimestamp to account for replies

This commit is contained in:
celso 2024-07-25 16:44:09 -03:00
parent 0c5b3d36c8
commit 19615186da
1 changed files with 11 additions and 1 deletions

View File

@ -113,10 +113,19 @@ getcbk_data() {
gettimestamp() { gettimestamp() {
local timestamp="$(tail -n 1 "${bot_tmpdir}${1}"\ local timestamp="$(tail -n 1 "${bot_tmpdir}${1}"\
| grep "\"date\"" | grep -om1 "\"date\":[0-9]\+,")" | grep "\"date\"" | grep -om1 "\"date\":[0-9]\+," | head -n1)"
[ ! -z "${timestamp}" ] && date "+%D %H:%M" -d "@${timestamp:7:-1}" [ ! -z "${timestamp}" ] && date "+%D %H:%M" -d "@${timestamp:7:-1}"
} }
getreplytext() {
grep reply_to_message "${bot_tmpdir}${1}" && local replytext="$(tail -n 1 "${bot_tmpdir}${1}" | grep -om1\
'{\?\("text"\|"caption"\):"\(\\"\|[^"]*\)*"\(,\|}\)' | grep -v "^{" | head -n1)"
grep "^\"text\"" <<< "${text}" >/dev/null && utf-16-surrogate-pair-decode "${replytext:8:-2}"\
|| {
grep "^\"caption\"" <<< "${text}" >/dev/null && utf-16-surrogate-pair-decode "${replytext:11:-2}"
}
}
# $1 is name of a bash array with the number of columns in every row such as ( 1 1 3 ) for a 3 row keyboard in which the first and second row have 1 column, and the third has 3 # $1 is name of a bash array with the number of columns in every row such as ( 1 1 3 ) for a 3 row keyboard in which the first and second row have 1 column, and the third has 3
# $2 is name of a bash array with as many text entries as there are columns, they are added left to right, up to down, to the rows/columns configuration passed as first arg # $2 is name of a bash array with as many text entries as there are columns, they are added left to right, up to down, to the rows/columns configuration passed as first arg
# $3 is name of a bash array with as many data entries as there are columns, they are added left to right, up to down, to the rows/columns configuration passed as first arg # $3 is name of a bash array with as many data entries as there are columns, they are added left to right, up to down, to the rows/columns configuration passed as first arg
@ -220,4 +229,5 @@ getmsg_content(){
_REF[text]="$(gettext "${2}")" _REF[text]="$(gettext "${2}")"
_REF[callback]="$(getcbk_data "${2}")" _REF[callback]="$(getcbk_data "${2}")"
_REF[timestamp]="$(gettimestamp "${2}")" _REF[timestamp]="$(gettimestamp "${2}")"
local replytext="$(getreplytext "${2}")"; [ ! -z "${replytext}" ] && _REF[replytext]="$(getreplytext "${2}")"
} }