refactored getusr_name to take last_name into account
This commit is contained in:
parent
7610913f38
commit
2faa8b1b4b
|
@ -80,15 +80,35 @@ gettext() {
|
|||
}
|
||||
}
|
||||
|
||||
getusr_name(){
|
||||
local user_name="$(tail -n 1 "${bot_tmpdir}${1}" | grep -om1\
|
||||
'"first_name":"\(\\"\|[^"]*\)*",\("username"\|"language_code"\)' | head -n1)"
|
||||
grep "\"username\"$" <<< "${user_name}" >/dev/null && utf-16-surrogate-pair-decode "${user_name:14:-12}"\
|
||||
getfirst_name(){
|
||||
local first_name="$(tail -n 1 "${bot_tmpdir}${1}" | grep -om1\
|
||||
'"first_name":"\(\\"\|[^"]*\)*"\(,\("username"\|"language_code"\|"last_name"\)\|},"chat"\)' | head -n1)"
|
||||
grep "\"username\"$" <<< "${first_name}" >/dev/null && utf-16-surrogate-pair-decode "${first_name:14:-12}"\
|
||||
|| {
|
||||
grep "\"language_code\"$" <<< "${user_name}" >/dev/null && utf-16-surrogate-pair-decode "${user_name:14:-17}"
|
||||
grep "\"language_code\"$" <<< "${first_name}" >/dev/null && utf-16-surrogate-pair-decode "${first_name:14:-17}"
|
||||
} || {
|
||||
grep "\"last_name\"$" <<< "${first_name}" >/dev/null && utf-16-surrogate-pair-decode "${first_name:14:-13}"
|
||||
} || {
|
||||
grep "},\"chat\"$" <<< "${first_name}" >/dev/null && utf-16-surrogate-pair-decode "${first_name:14:-9}"
|
||||
}
|
||||
}
|
||||
|
||||
getlast_name(){
|
||||
local last_name="$(tail -n 1 "${bot_tmpdir}${1}" | grep -om1\
|
||||
'"last_name":"\(\\"\|[^"]*\)*"\(,\("username"\|"language_code"\)\|},"chat"\)' | head -n1)"
|
||||
grep "\"username\"$" <<< "${last_name}" >/dev/null && utf-16-surrogate-pair-decode "${last_name:13:-12}"\
|
||||
|| {
|
||||
grep "\"language_code\"$" <<< "${last_name}" >/dev/null && utf-16-surrogate-pair-decode "${last_name:13:-17}"
|
||||
} || {
|
||||
grep "},\"chat\"$" <<< "${last_name}" >/dev/null && utf-16-surrogate-pair-decode "${last_name:13:-9}"
|
||||
}
|
||||
}
|
||||
|
||||
getusr_name(){
|
||||
local user_name="$(getfirst_name ${1}) $(getlast_name ${1})"
|
||||
[ "${user_name}" != "" ] && printf "%s" "${user_name}"
|
||||
}
|
||||
|
||||
getusrname(){
|
||||
local username="$(tail -n 1 "${bot_tmpdir}${1}" | grep -om1\
|
||||
'"username":"\(\\"\|[^"]*\)*"\(,"language_code"\|},"chat"\)' | head -n1)"
|
||||
|
|
Loading…
Reference in New Issue