diff --git a/bashbot-lib.sh b/bashbot-lib.sh index 60aee6c..361ff2d 100755 --- a/bashbot-lib.sh +++ b/bashbot-lib.sh @@ -87,10 +87,11 @@ getfirst_name(){ || { 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 "\"last_name\"$" <<< "${first_name}" >/dev/null && utf-16-surrogate-pair-decode "${first_name:14:-13}" && return 0 } || { grep "},\"chat\"$" <<< "${first_name}" >/dev/null && utf-16-surrogate-pair-decode "${first_name:14:-9}" } + return 1 } getlast_name(){ @@ -105,7 +106,7 @@ getlast_name(){ } getusr_name(){ - local user_name="$(getfirst_name ${1}) $(getlast_name ${1})" + local user_name="$({ getfirst_name ${1} && getlast_name ${1}; } | sed ":a;N;$!ba;s/\n/ /")" [ "${user_name}" != "" ] && printf "%s" "${user_name}" }