changed msginfo functions to work with sentmsgs.txt too
This commit is contained in:
parent
28255be349
commit
108dbc1125
|
@ -37,17 +37,17 @@ getupd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
getmsg_id() {
|
getmsg_id() {
|
||||||
tail -n1 "${bot_tmpdir}updates.txt" | grep -om1\
|
tail -n1 "${bot_tmpdir}${1}" | grep -om1\
|
||||||
"\"message\":{\"message_id\":[0-9]\+" | grep -om1 "[0-9]\+"
|
"\"message\":{\"message_id\":[0-9]\+" | grep -om1 "[0-9]\+"
|
||||||
}
|
}
|
||||||
|
|
||||||
getusr_id() {
|
getusr_id() {
|
||||||
tail -n1 "${bot_tmpdir}updates.txt" | grep -om1\
|
tail -n1 "${bot_tmpdir}${1}" | grep -om1\
|
||||||
"\"from\":{\"id\":[0-9]\+" | grep -om1 "[0-9]\+"
|
"\"from\":{\"id\":[0-9]\+" | grep -om1 "[0-9]\+"
|
||||||
}
|
}
|
||||||
|
|
||||||
getchat_id() {
|
getchat_id() {
|
||||||
tail -n1 "${bot_tmpdir}updates.txt" | grep -om1\
|
tail -n1 "${bot_tmpdir}${1}" | grep -om1\
|
||||||
"\"chat\":{\"id\":-\?[0-9]\+" | grep -om1 "\-\?[0-9]\+"
|
"\"chat\":{\"id\":-\?[0-9]\+" | grep -om1 "\-\?[0-9]\+"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ utf-16-surrogate-pair-decode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
gettext() {
|
gettext() {
|
||||||
local text="$(tail -n 1 "${bot_tmpdir}updates.txt" | grep -om1\
|
local text="$(tail -n 1 "${bot_tmpdir}${1}" | grep -om1\
|
||||||
'\("text"\|"caption"\):"\(\\"\|[^"]*\)*"\(,\|}\)' | tail -n1)"
|
'\("text"\|"caption"\):"\(\\"\|[^"]*\)*"\(,\|}\)' | tail -n1)"
|
||||||
grep "^\"text\"" <<< "${text}" >/dev/null && utf-16-surrogate-pair-decode "${text:8:-2}"\
|
grep "^\"text\"" <<< "${text}" >/dev/null && utf-16-surrogate-pair-decode "${text:8:-2}"\
|
||||||
|| {
|
|| {
|
||||||
|
@ -77,7 +77,7 @@ gettext() {
|
||||||
}
|
}
|
||||||
|
|
||||||
getusr_name(){
|
getusr_name(){
|
||||||
local user_name="$(tail -n 1 "${bot_tmpdir}updates.txt" | grep -om1\
|
local user_name="$(tail -n 1 "${bot_tmpdir}${1}" | grep -om1\
|
||||||
'"first_name":"\(\\"\|[^"]*\)*",\("username"\|"language_code"\)' | head -n1)"
|
'"first_name":"\(\\"\|[^"]*\)*",\("username"\|"language_code"\)' | head -n1)"
|
||||||
grep "\"username\"$" <<< "${user_name}" >/dev/null && utf-16-surrogate-pair-decode "${user_name:14:-12}"\
|
grep "\"username\"$" <<< "${user_name}" >/dev/null && utf-16-surrogate-pair-decode "${user_name:14:-12}"\
|
||||||
|| {
|
|| {
|
||||||
|
@ -86,20 +86,20 @@ getusr_name(){
|
||||||
}
|
}
|
||||||
|
|
||||||
getusrname(){
|
getusrname(){
|
||||||
local username="$(tail -n 1 "${bot_tmpdir}updates.txt" | grep -om1\
|
local username="$(tail -n 1 "${bot_tmpdir}${1}" | grep -om1\
|
||||||
'"username":"\(\\"\|[^"]*\)*","language_code"' | head -n1)"
|
'"username":"\(\\"\|[^"]*\)*","language_code"' | head -n1)"
|
||||||
utf-16-surrogate-pair-decode "${username:12:-17}"
|
utf-16-surrogate-pair-decode "${username:12:-17}"
|
||||||
}
|
}
|
||||||
|
|
||||||
getchat_title(){
|
getchat_title(){
|
||||||
local chat_title="$(tail -n 1 "${bot_tmpdir}updates.txt" | grep -om1\
|
local chat_title="$(tail -n 1 "${bot_tmpdir}${1}" | grep -om1\
|
||||||
'"title":"\(\\"\|[^"]*\)*","type":"group"' | head -n1)"
|
'"title":"\(\\"\|[^"]*\)*","type":"group"' | head -n1)"
|
||||||
[ ! -z "${chat_title}" ] && utf-16-surrogate-pair-decode "${chat_title:9:-16}"\
|
[ ! -z "${chat_title}" ] && utf-16-surrogate-pair-decode "${chat_title:9:-16}"\
|
||||||
|| getusr_name
|
|| getusr_name
|
||||||
}
|
}
|
||||||
|
|
||||||
get_cbks() {
|
get_cbks() {
|
||||||
local callbacks="$(tail -n 1 "${bot_tmpdir}updates.txt"\
|
local callbacks="$(tail -n 1 "${bot_tmpdir}${1}"\
|
||||||
| grep "\"callback_query\"" | grep "\"callback_data\":\"recheck\"")"
|
| grep "\"callback_query\"" | grep "\"callback_data\":\"recheck\"")"
|
||||||
[ ! -z "${callbacks}" ] && is_callback=0 && printf "%s\n" "${callbacks}"\
|
[ ! -z "${callbacks}" ] && is_callback=0 && printf "%s\n" "${callbacks}"\
|
||||||
>> "${bot_tmpdir}callbacks.txt"
|
>> "${bot_tmpdir}callbacks.txt"
|
||||||
|
@ -135,11 +135,11 @@ replymsg() {
|
||||||
|
|
||||||
getmsg_content(){
|
getmsg_content(){
|
||||||
local -n _REF="${1}"
|
local -n _REF="${1}"
|
||||||
_REF[user_id]="$(getusr_id)"
|
_REF[user_id]="$(getusr_id "${2}")"
|
||||||
_REF[user_name]="$(getusr_name)"
|
_REF[user_name]="$(getusr_name "${2}")"
|
||||||
_REF[username]="$(getusrname)"
|
_REF[username]="$(getusrname "${2}")"
|
||||||
_REF[chat_id]="$(getchat_id)"
|
_REF[chat_id]="$(getchat_id "${2}")"
|
||||||
_REF[chat_title]="$(getchat_title)"
|
_REF[chat_title]="$(getchat_title "${2}")"
|
||||||
_REF[msg_id]="$(getmsg_id)"
|
_REF[msg_id]="$(getmsg_id "${2}")"
|
||||||
_REF[text]="$(gettext)"
|
_REF[text]="$(gettext "${2}")"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue