service message start with /_ to avoid clashes

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-06-29 08:14:39 +02:00
parent d24ef50fd4
commit 63b9c283a2
2 changed files with 18 additions and 13 deletions

View File

@ -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.98-pre2-13-g0e6712a
#### $$VERSION$$ v0.98-pre2-16-gd24ef50
#
# Exit Codes:
# - 0 success (hopefully)
@ -847,7 +847,8 @@ process_message() {
NEWMEMBER[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","new_chat_member","last_name"]}")"
NEWMEMBER[USERNAME]="$(JsonDecode "${UPD["result",${num},"message","new_chat_member","username"]}")"
NEWMEMBER[ISBOT]="${UPD["result",${num},"message","new_chat_member","is_bot"]}"
[ -z "${MESSAGE[0]}" ] && MESSAGE[0]="/new_chat_member ${NEWMEMBER[USERNAME]:=${NEWMEMBER[FIRST_NAME]} ${NEWMEMBER[LAST_NAME]}}"
[ -z "${MESSAGE[0]}" ] &&\
MESSAGE[0]="/_new_chat_member ${NEWMEMBER[ID]} ${NEWMEMBER[USERNAME]:=${NEWMEMBER[FIRST_NAME]} ${NEWMEMBER[LAST_NAME]}}"
fi
if grep -qs -e '\["result",'"${num}"',"message","left_chat_member' <<<"${UPDATE}"; then
SERVICE[LEFTMEMBER]="${UPD["result",${num},"message","left_chat_member","id"]}"
@ -856,15 +857,19 @@ process_message() {
LEFTMEMBER[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","left_chat_member","last_name"]}")"
LEFTMEBER[USERNAME]="$(JsonDecode "${UPD["result",${num},"message","left_chat_member","username"]}")"
LEFTMEMBER[ISBOT]="${UPD["result",${num},"message","left_chat_member","is_bot"]}"
[ -z "${MESSAGE[0]}" ] && MESSAGE[0]="/left_chat_member ${LEFTMEMBER[USERNAME]:=${LEFTMEMBER[FIRST_NAME]} ${LEFTMEMBER[LAST_NAME]}}"
[ -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
SERVICE[NEWTITLE]="$(JsonDecode "${UPD["result",${num},"message","new_chat_title"]}")"
[ -z "${MESSAGE[0]}" ] && [ -n "${SERVICE[NEWTITLE]}" ] && MESSAGE[0]="/new_chat_title ${SERVICE[NEWTITLE]}"
[ -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 ${SERVICE[NEWPHOTO]}"
[ -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]}" ] && MESSAGE[0]="/new_pinned_message ${SERVICE[PINNED]}"
[ -z "${MESSAGE[0]}" ] && [ -n "${SERVICE[PINNED]}" ] &&i\
MESSAGE[0]="/_new_pinned_message ${USER[ID]} ${SERVICE[PINNED]}"
fi
# set SSERVICE to yes if a service message was received
[[ "${SERVICE[*]}" =~ ^[[:blank:]]*$ ]] || SERVICE[0]="yes"

View File

@ -164,30 +164,30 @@ Service Messages are regular messages not itended for end users, instead they si
client, e.g. new users.
If a service message is received bashbot sets MESSAGE to the service message type as a command,
e.g. if a new user joins a chat MESSAGE is set to "/new_chat_user".
e.g. if a new user joins a chat MESSAGE is set to "/_new_chat_user".
* ```$SERVICE```: This array contains info about received service messages.
* ```${SERVICE}```: "yes" if service message is received
* ```${SERVICE[NEWMEMBER]```: New user's id
* ```${MESSAGE}```: /new_chat_member
* ```${MESSAGE}```: /_new_chat_member ID NAME
* ```${NEWMEMBER[ID]```: New user's id
* ```${NEWMEMBER[FIRST_NAME]```: New user's first name
* ```${NEWMEMBER[LAST_NAME]```: New user's last name
* ```${NEWMEMBER[USERNAME]```: New user's username
* ```${NEWMEMBER[ISBOT]```: New user is a bot
* ```${SERVICE[LEFTMEMBER]```: Id of user left
* ```${MESSAGE}```: /left_chat_member
* ```${MESSAGE}```: /_left_chat_member ID NAME
* ```${LEFTMEMBER[ID]```: Left user's id
* ```${LEFTMEMBER[FIRST_NAME]```: Left user's first name
* ```${LEFTMEMBER[LAST_NAME]```: Left user's last name
* ```${LEFTMEMBER[USERNAME]```: Left user's username
* ```${LEFTMEMBER[ISBOT]```: Left user is a bot
* ```${SERVICE[NEWTITLE]```: Text of new title
* ```${MESSAGE}```: /new_chat_title
* ```${MESSAGE}```: /_new_chat_title SENDER TEXT
* ```${SERVICE[NEWPHOTO]```: New Chat Picture URL
* ```${MESSAGE}```: /new_chat_picture
* ```${MESSAGE}```: /_new_chat_picture SENDER URL
* ```${SERVICE[PINNED]```: Pinned Message structure
* ```${MESSAGE}```: /new_pinned_message
* ```${MESSAGE}```: /_new_pinned_message SENDER ID
@ -281,5 +281,5 @@ send_action "${CHAT[ID]}" "action"
#### [Prev Create Bot](1_firstbot.md)
#### [Next Advanced Usage](3_advanced.md)
#### $$VERSION$$ v0.98-pre2-0-ga597303
#### $$VERSION$$ v0.98-pre2-16-gd24ef50