From c602c92c15193bee383bd6124cba7f9c4862859f Mon Sep 17 00:00:00 2001 From: celso Date: Wed, 22 Mar 2023 11:41:33 -0300 Subject: [PATCH] reworked functions to correctly handle sentmsgs --- bashbot-lib.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bashbot-lib.sh b/bashbot-lib.sh index 0efab6a..71afa68 100755 --- a/bashbot-lib.sh +++ b/bashbot-lib.sh @@ -38,7 +38,7 @@ getupd() { getmsg_id() { tail -n1 "${bot_tmpdir}${1}" | grep -om1\ - "\"message\":{\"message_id\":[0-9]\+" | grep -om1 "[0-9]\+" + "\"message\":{\"message_id\":[0-9]\+\|^\"message_id\":[0-9]\+" | grep -om1 "[0-9]\+" } getusr_id() { @@ -87,8 +87,11 @@ getusr_name(){ getusrname(){ local username="$(tail -n 1 "${bot_tmpdir}${1}" | grep -om1\ - '"username":"\(\\"\|[^"]*\)*","language_code"' | head -n1)" - utf-16-surrogate-pair-decode "${username:12:-17}" + '"username":"\(\\"\|[^"]*\)*"\(,"language_code"\|},"chat"\)' | head -n1)" + grep "\"language_code\"$" <<< "${username}" >/dev/null && utf-16-surrogate-pair-decode "${user_name:12:-17}"\ + || { + grep "},\"chat\"$" <<< "${username}" >/dev/null && utf-16-surrogate-pair-decode "${username:12:-9}" + } } getchat_title(){