mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-21 23:25:08 +00:00
finalise service pinned message, fix new/left member ARRAY
This commit is contained in:
parent
12b4696e80
commit
9e3d301d37
19
bashbot.sh
19
bashbot.sh
@ -11,7 +11,7 @@
|
||||
# This file is public domain in the USA and all free countries.
|
||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||
#
|
||||
#### $$VERSION$$ v0.962-110-g4883c18
|
||||
#### $$VERSION$$ v0.962-112-g12b4696
|
||||
#
|
||||
# Exit Codes:
|
||||
# - 0 success (hopefully)
|
||||
@ -274,7 +274,8 @@ declare -rx SCRIPT SCRIPTDIR MODULEDIR RUNDIR ADDONDIR TOKENFILE BOTADMIN BOTACL
|
||||
declare -rx BOTTOKEN URL ME_URL UPD_URL GETFILE_URL
|
||||
|
||||
declare -ax CMD
|
||||
declare -Ax UPD BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY SERVICE NEWMEMBER
|
||||
declare -Ax UPD BOTSENT USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE iQUERY
|
||||
declare -Ax SERVICE NEWMEMBER LEFTMEMBER PINNED
|
||||
export res CAPTION
|
||||
|
||||
|
||||
@ -747,7 +748,7 @@ pre_process_message(){
|
||||
local num="${1}"
|
||||
# unset everything to not have old values
|
||||
CMD=( ); iQUERY=( ); MESSAGE=(); CHAT=(); USER=(); CONTACT=(); LOCATION=(); unset CAPTION
|
||||
REPLYTO=( ); FORWARD=( ); URLS=(); VENUE=( ); SERVICE=( ); NEWMEMBER=( ); LEFTMEMBER=( )
|
||||
REPLYTO=( ); FORWARD=( ); URLS=(); VENUE=( ); SERVICE=( ); NEWMEMBER=( ); LEFTMEMBER=( ); PINNED=( )
|
||||
iQUERY[ID]="${UPD["result",${num},"inline_query","id"]}"
|
||||
CHAT[ID]="${UPD["result",${num},"message","chat","id"]}"
|
||||
USER[ID]="${UPD["result",${num},"message","from","id"]}"
|
||||
@ -864,16 +865,20 @@ process_message() {
|
||||
[ -z "${MESSAGE[0]}" ] &&\
|
||||
MESSAGE[0]="/_left_chat_member ${NEWMEMBER[ID]} ${LEFTMEMBER[USERNAME]:=${LEFTMEMBER[FIRST_NAME]} ${LEFTMEMBER[LAST_NAME]}}"
|
||||
fi
|
||||
if grep -qs -e '\["result",'"${num}"',"message","\(new_chat_[tp]\)\|\(pinned_message\)' <<<"${UPDATE}"; then
|
||||
if grep -qs -e '\["result",'"${num}"',"message","new_chat_[tp]' <<<"${UPDATE}"; then
|
||||
SERVICE[NEWTITLE]="$(JsonDecode "${UPD["result",${num},"message","new_chat_title"]}")"
|
||||
[ -z "${MESSAGE[0]}" ] && [ -n "${SERVICE[NEWTITLE]}" ] &&\
|
||||
MESSAGE[0]="/_new_chat_title ${USER[ID]} ${SERVICE[NEWTITLE]}"
|
||||
SERVICE[NEWPHOTO]="$(get_file "${UPD["result",${num},"message","new_chat_photo",0,"file_id"]}")"
|
||||
[ -z "${MESSAGE[0]}" ] && [ -n "${SERVICE[NEWPHOTO]}" ] &&\
|
||||
MESSAGE[0]="/_new_chat_photo ${USER[ID]} ${SERVICE[NEWPHOTO]}"
|
||||
SERVICE[PINNED]="$(JsonDecode "${UPD["result",${num},"message","pinned_message"]}")"
|
||||
[ -z "${MESSAGE[0]}" ] && [ -n "${SERVICE[PINNED]}" ] &&i\
|
||||
MESSAGE[0]="/_new_pinned_message ${USER[ID]} ${SERVICE[PINNED]}"
|
||||
fi
|
||||
if grep -qs -e '\["result",'"${num}"',"message","pinned_message' <<<"${UPDATE}"; then
|
||||
SERVICE[PINNED]="$(JsonDecode "${UPD["result",${num},"message","pinned_message","message_id"]}")"
|
||||
PINNED[ID]="${SERVICE[PINNED]}"
|
||||
PINNED[MESSAGE]="$(JsonDecode "${UPD["result",${num},"message","pinned_message","text"]}")"
|
||||
[ -z "${MESSAGE[0]}" ] && [ -n "${SERVICE[PINNED]}" ] &&\
|
||||
MESSAGE[0]="/_new_pinned_message ${USER[ID]} ${PINNED[ID]} ${PINNED[MESSAGE]}"
|
||||
fi
|
||||
# set SSERVICE to yes if a service message was received
|
||||
[[ "${SERVICE[*]}" =~ ^[[:blank:]]*$ ]] || SERVICE[0]="yes"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.98-pre2-18-g3a51b51
|
||||
#### $$VERSION$$ v0.962-112-g12b4696
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
@ -24,7 +24,7 @@ export UPDATE
|
||||
declare -Ax UPD
|
||||
|
||||
# run process_message --------------
|
||||
ARRAYS="USER CHAT REPLYTO FORWARD URLS CONTACT CAPTION LOCATION MESSAGE VENUE SERVICE"
|
||||
ARRAYS="USER CHAT REPLYTO FORWARD URLS CONTACT CAPTION LOCATION MESSAGE VENUE SERVICE NEWMEMBER LEFTMEMBER PINNED"
|
||||
|
||||
echo "Check process_message regular message..."
|
||||
|
||||
|
@ -60,6 +60,6 @@
|
||||
["result",0,"message","pinned_message","chat","title"] "Testgruppe bot only test"
|
||||
["result",0,"message","pinned_message","chat","type"] "supergroup"
|
||||
["result",0,"message","pinned_message","date"] 1593121152
|
||||
["result",0,"message","pinned_message","text"] "Pinned Message"
|
||||
["result",0,"message","pinned_message","text"] "new pinned Message"
|
||||
|
||||
["result",0,"message","new_chat_title"] "Testgruppe bot only"
|
||||
["result",0,"message","new_chat_title"] "new Testgruppe bot only"
|
||||
|
@ -18,5 +18,16 @@ SERVICE: 0 yes
|
||||
SERVICE: LEFTMEMBER 123456789
|
||||
SERVICE: NEWMEMBER 123456789
|
||||
SERVICE: NEWPHOTO AgACAgIAAxkBAAEBFute6a3vIpB99vim811hxeu2tyQWfwACrKwxG0TMUUtDBH10RqlzGCukupIuAAMBAAMCAANhAAM3SAMAARoE
|
||||
SERVICE: NEWTITLE Testgruppe bot only
|
||||
SERVICE: PINNED
|
||||
SERVICE: NEWTITLE new Testgruppe bot only
|
||||
SERVICE: PINNED 3022
|
||||
NEWMEMBER: FIRST_NAME Kay
|
||||
NEWMEMBER: ID 123456789
|
||||
NEWMEMBER: ISBOT false
|
||||
NEWMEMBER: LAST_NAME M
|
||||
NEWMEMBER: USERNAME Gnadelwartz
|
||||
LEFTMEMBER: FIRST_NAME Kay
|
||||
LEFTMEMBER: ID
|
||||
LEFTMEMBER: ISBOT false
|
||||
LEFTMEMBER: LAST_NAME M
|
||||
PINNED: ID 3022
|
||||
PINNED: MESSAGE new pinned Message
|
||||
|
1
test/e-env-test/botacl
Normal file
1
test/e-env-test/botacl
Normal file
@ -0,0 +1 @@
|
||||
|
Loading…
Reference in New Issue
Block a user