mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2025-01-16 02:42:19 +00:00
Merge pull request #58 from gnadelwartz/reply-forward
Reply: Provide Information about original User and Message
This commit is contained in:
commit
12a0d4af5b
15
README.md
15
README.md
@ -81,8 +81,9 @@ Then start editing the commands.
|
|||||||
You can read incoming data using the following variables:
|
You can read incoming data using the following variables:
|
||||||
|
|
||||||
* ```$MESSAGE```: Incoming messages
|
* ```$MESSAGE```: Incoming messages
|
||||||
* ```$MESSAGE[ID]```: ID of incoming message
|
* ```${MESSAGE[ID]}```: ID of incoming message
|
||||||
* ```$CAPTION```: Captions
|
* ```$CAPTION```: Captions
|
||||||
|
* ```$REPLYTO```: Original message wich was replied to
|
||||||
* ```$USER```: This array contains the First name, last name, username and user id of the sender of the current message.
|
* ```$USER```: This array contains the First name, last name, username and user id of the sender of the current message.
|
||||||
* ```${USER[ID]}```: User id
|
* ```${USER[ID]}```: User id
|
||||||
* ```${USER[FIRST_NAME]}```: User's first name
|
* ```${USER[FIRST_NAME]}```: User's first name
|
||||||
@ -96,6 +97,18 @@ You can read incoming data using the following variables:
|
|||||||
* ```${CHAT[TITLE]}```: Title
|
* ```${CHAT[TITLE]}```: Title
|
||||||
* ```${CHAT[TYPE]}```: Type
|
* ```${CHAT[TYPE]}```: Type
|
||||||
* ```${CHAT[ALL_MEMBERS_ARE_ADMINISTRATORS]}```: All members are administrators (true if true)
|
* ```${CHAT[ALL_MEMBERS_ARE_ADMINISTRATORS]}```: All members are administrators (true if true)
|
||||||
|
* ```$REPLYTO```: This array contains the First name, last name, username and user id of the ORIGINAL sender of the REPLEYED message.
|
||||||
|
* ```${REPLYTO[ID]}```: ID of message wich was replied to
|
||||||
|
* ```${REPLYTO[UID]}```: Original user's id
|
||||||
|
* ```${REPLYTO[FIRST_NAME]}```: Original user's first name
|
||||||
|
* ```${REPLYTO[LAST_NAME]}```: Original user's' last name
|
||||||
|
* ```${REPLYTO[USERNAME]}```: Original user's username
|
||||||
|
* ```$FORWARD```: This array contains the First name, last name, username and user id of the ORIGINAL sender of the FORWARDED message.
|
||||||
|
* ```${FORWARD[ID]}```: Same as MESSAGE[ID] if message is forwarded
|
||||||
|
* ```${FORWARD[UID]}```: Original user's id
|
||||||
|
* ```${FORWARD[FIRST_NAME]}```: Original user's first name
|
||||||
|
* ```${FORWARD[LAST_NAME]}```: Original user's' last name
|
||||||
|
* ```${FORWARD[USERNAME]}```: Original user's username
|
||||||
* ```$URLS```: This array contains documents, audio files, stickers, voice recordings and stickers stored in the form of URLs.
|
* ```$URLS```: This array contains documents, audio files, stickers, voice recordings and stickers stored in the form of URLs.
|
||||||
* ```${URLS[AUDIO]}```: Audio files
|
* ```${URLS[AUDIO]}```: Audio files
|
||||||
* ```${URLS[VIDEO]}```: Videos
|
* ```${URLS[VIDEO]}```: Videos
|
||||||
|
21
bashbot.sh
21
bashbot.sh
@ -83,7 +83,7 @@ FILE_URL='https://api.telegram.org/file/bot'$TOKEN'/'
|
|||||||
UPD_URL=$URL'/getUpdates?offset='
|
UPD_URL=$URL'/getUpdates?offset='
|
||||||
GET_URL=$URL'/getFile'
|
GET_URL=$URL'/getFile'
|
||||||
OFFSET=0
|
OFFSET=0
|
||||||
declare -A USER MESSAGE URLS CONTACT LOCATION CHAT
|
declare -A USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO
|
||||||
|
|
||||||
urlencode() {
|
urlencode() {
|
||||||
echo "$*" | sed 's:%:%25:g;s: :%20:g;s:<:%3C:g;s:>:%3E:g;s:#:%23:g;s:{:%7B:g;s:}:%7D:g;s:|:%7C:g;s:\\:%5C:g;s:\^:%5E:g;s:~:%7E:g;s:\[:%5B:g;s:\]:%5D:g;s:`:%60:g;s:;:%3B:g;s:/:%2F:g;s:?:%3F:g;s^:^%3A^g;s:@:%40:g;s:=:%3D:g;s:&:%26:g;s:\$:%24:g;s:\!:%21:g;s:\*:%2A:g'
|
echo "$*" | sed 's:%:%25:g;s: :%20:g;s:<:%3C:g;s:>:%3E:g;s:#:%23:g;s:{:%7B:g;s:}:%7D:g;s:|:%7C:g;s:\\:%5C:g;s:\^:%5E:g;s:~:%7E:g;s:\[:%5B:g;s:\]:%5D:g;s:`:%60:g;s:;:%3B:g;s:/:%2F:g;s:?:%3F:g;s^:^%3A^g;s:@:%40:g;s:=:%3D:g;s:&:%26:g;s:\$:%24:g;s:\!:%21:g;s:\*:%2A:g'
|
||||||
@ -424,6 +424,25 @@ process_client() {
|
|||||||
USER[LAST_NAME]="$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","from","last_name"\]' | cut -f 2 | cut -d '"' -f 2)"
|
USER[LAST_NAME]="$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","from","last_name"\]' | cut -f 2 | cut -d '"' -f 2)"
|
||||||
USER[USERNAME]="$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","from","username"\]' | cut -f 2 | cut -d '"' -f 2)"
|
USER[USERNAME]="$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","from","username"\]' | cut -f 2 | cut -d '"' -f 2)"
|
||||||
|
|
||||||
|
# in reply to message from
|
||||||
|
REPLYTO[UID]="$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","reply_to_message","from","id"\]' | cut -f 2)"
|
||||||
|
if [ "${REPLYTO[UID]}" != "" ]; then
|
||||||
|
REPLYTO[0]="$(echo -e "$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","reply_to_message","text"\]' | cut -f 2 | cut -d '"' -f 2)" | sed 's#\\/#/#g')"
|
||||||
|
REPLYTO[ID]="$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","reply_to_message","message_id"\]' | cut -f 2 | cut -d '"' -f 2)"
|
||||||
|
REPLYTO[FIRST_NAME]="$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","reply_to_message","from","first_name"\]' | cut -f 2 | cut -d '"' -f 2)"
|
||||||
|
REPLYTO[LAST_NAME]="$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","reply_to_message","from","last_name"\]' | cut -f 2 | cut -d '"' -f 2)"
|
||||||
|
REPLYTO[USERNAME]="$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","reply_to_message","from","username"\]' | cut -f 2 | cut -d '"' -f 2)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# forwarded message from
|
||||||
|
FORWARD[UID]="$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","forward_from","id"\]' | cut -f 2)"
|
||||||
|
if [ "${FORWARD[UID]}" != "" ]; then
|
||||||
|
FORWARD[ID]="${MESSAGE[ID]}" # same as message ID
|
||||||
|
FORWARD[FIRST_NAME]="$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","forward_from","first_name"\]' | cut -f 2 | cut -d '"' -f 2)"
|
||||||
|
FORWARD[LAST_NAME]="$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","forward_from","last_name"\]' | cut -f 2 | cut -d '"' -f 2)"
|
||||||
|
FORWARD[USERNAME]="$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","forward_from","username"\]' | cut -f 2 | cut -d '"' -f 2)"
|
||||||
|
fi
|
||||||
|
|
||||||
# Audio
|
# Audio
|
||||||
URLS[AUDIO]="$(get_file $(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","audio","file_id"\]' | cut -f 2 | cut -d '"' -f 2))"
|
URLS[AUDIO]="$(get_file $(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","audio","file_id"\]' | cut -f 2 | cut -d '"' -f 2))"
|
||||||
# Document
|
# Document
|
||||||
|
Loading…
Reference in New Issue
Block a user