mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-06-03 19:00:50 +00:00
detect supergroup migration
This commit is contained in:
parent
22741d9a0c
commit
da7a3f1f21
18
bashbot.sh
18
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$$ v1.2-dev2-3-gcdb63b8
|
||||
#### $$VERSION$$ v1.2-dev2-4-g22741d9
|
||||
#
|
||||
# Exit Codes:
|
||||
# - 0 success (hopefully)
|
||||
|
@ -304,7 +304,7 @@ 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
|
||||
declare -Ax SERVICE NEWMEMBER LEFTMEMBER PINNED
|
||||
declare -Ax SERVICE NEWMEMBER LEFTMEMBER PINNED MIGRATE
|
||||
export res CAPTION
|
||||
|
||||
|
||||
|
@ -828,7 +828,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=( ); PINNED=( )
|
||||
REPLYTO=( ); FORWARD=( ); URLS=(); VENUE=( ); SERVICE=( ); NEWMEMBER=( ); LEFTMEMBER=( ); PINNED=( ); MIGRATE=( )
|
||||
iQUERY[ID]="${UPD["result",${num},"inline_query","id"]}"
|
||||
CHAT[ID]="${UPD["result",${num},"message","chat","id"]}"
|
||||
USER[ID]="${UPD["result",${num},"message","from","id"]}"
|
||||
|
@ -959,12 +959,20 @@ process_message() {
|
|||
fi
|
||||
# pinned message
|
||||
if [ -n "${UPD["result",${num},"message","pinned_message","message_id"]}" ]; then
|
||||
SERVICE[PINNED]="$(JsonDecode "${UPD["result",${num},"message","pinned_message","message_id"]}")"
|
||||
SERVICE[PINNED]="${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]}" ] &&\
|
||||
[ -z "${MESSAGE[0]}" ] &&\
|
||||
MESSAGE[0]="/_new_pinned_message ${USER[ID]} ${PINNED[ID]} ${PINNED[MESSAGE]}"
|
||||
fi
|
||||
# migrate to super group
|
||||
if [ -n "${UPD["result",${num},"message","migrate_to_chat_id"]}" ]; then
|
||||
MIGRATE[TO]="${UPD["result",${num},"message","migrate_to_chat_id"]}"
|
||||
MIGRATE[FROM]="${UPD["result",${num},"message","migrate_from_chat_id"]}"
|
||||
SERVICE[MIGRATE]="${MIGRATE[FROM]} ${MIGRATE[TO]}"
|
||||
[ -z "${MESSAGE[0]}" ] &&\
|
||||
MESSAGE[0]="/_migrate_chat ${SERVICE[MIGRATE]}"
|
||||
fi
|
||||
# set SERVICE to yes if a service message was received
|
||||
[[ "${SERVICE[*]}" =~ ^[[:blank:]]*$ ]] || SERVICE[0]="yes"
|
||||
fi
|
||||
|
|
|
@ -186,10 +186,14 @@ e.g. if a new user joins a chat MESSAGE is set to "/_new_chat_user".
|
|||
* ```${MESSAGE}```: /_new_chat_title SENDER TEXT
|
||||
* ```${SERVICE[NEWPHOTO]}```: New Chat Picture
|
||||
* ```${MESSAGE}```: /_new_chat_picture SENDER URL
|
||||
* ```${SERVICE[PINNED]}```: Pinned Message structure
|
||||
* ```${SERVICE[PINNED]}```: Pinned MESSAGE ID
|
||||
* ```${MESSAGE}```: /_new_pinned_message SENDER ID
|
||||
* ```${PINNED[ID]}```: Id of pinned message
|
||||
* ```${PINNED[MESSAGE]}```: Message text of pinned message
|
||||
* ```${SERVICE[MIGRATE]}```: Old and new group id
|
||||
* ```${MESSAGE}```: /_migrate_chat MIGRATE_FROM MIGRATE_TO
|
||||
* ```${MIGRATE[FROM]}```: Old group id
|
||||
* ```${MIGRATE[TO]}```: New group id
|
||||
|
||||
|
||||
|
||||
|
@ -294,5 +298,5 @@ send_action "${CHAT[ID]}" "action"
|
|||
#### [Prev Create Bot](1_firstbot.md)
|
||||
#### [Next Advanced Usage](3_advanced.md)
|
||||
|
||||
#### $$VERSION$$ v1.2-11-g5db2ef6
|
||||
#### $$VERSION$$ v1.2-dev2-4-g22741d9
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user