mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-26 09:16:28 +00:00
parse VCARD and VENUE from message
This commit is contained in:
parent
ca73be8c41
commit
56a45aa883
18
bashbot.sh
18
bashbot.sh
@ -10,7 +10,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.70-dev2-12-gaa93839
|
||||
#### $$VERSION$$ v0.70-dev2-13-gca73be8
|
||||
#
|
||||
# Exit Codes:
|
||||
# - 0 sucess (hopefully)
|
||||
@ -157,8 +157,8 @@ UPD_URL=$URL'/getUpdates?offset='
|
||||
GET_URL=$URL'/getFile'
|
||||
|
||||
unset USER
|
||||
declare -A USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO
|
||||
|
||||
declare -A USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE
|
||||
export USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO VENUE
|
||||
|
||||
|
||||
send_message() {
|
||||
@ -600,10 +600,18 @@ process_message() {
|
||||
URLS[VOICE]="$(get_file "$(JsonGetString '"result",'"${num}"',"message","voice","file_id"' <"$TMP")")"
|
||||
|
||||
# Contact
|
||||
CONTACT[NUMBER]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","contact","phone_number"' <"$TMP")")"
|
||||
CONTACT[USER_ID]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","contact","user_id"' <"$TMP")")"
|
||||
CONTACT[FIRST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","contact","first_name"' <"$TMP")")"
|
||||
CONTACT[LAST_NAME]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","contact","last_name"' <"$TMP")")"
|
||||
CONTACT[USER_ID]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","contact","user_id"' <"$TMP")")"
|
||||
CONTACT[NUMBER]="$(JsonGetString '"result",'"${num}"',"message","contact","phone_number"' <"$TMP")"
|
||||
CONTACT[VCARD]="$(JsonGetString '"result",'"${num}"',"message","contact","vcard"' <"$TMP")"
|
||||
|
||||
# vunue
|
||||
VENUE[TITLE]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","venue","title"' <"$TMP")")"
|
||||
VENUE[ADDRESS]="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","venue","address"' <"$TMP")")"
|
||||
VENUE[LONGITUDE]="$(JsonGetValue '"result",'"${num}"',"message","venue","location","longitude"' <"$TMP")"
|
||||
VENUE[LATITUDE]="$(JsonGetValue '"result",'"${num}"',"message","venue","location","latitude"' <"$TMP")"
|
||||
VENUE[FOURSQUARE]="$(JsonGetString '"result",'"${num}"',"message","venue","foursquare_id"' <"$TMP")"
|
||||
|
||||
# Caption
|
||||
CAPTION="$(JsonDecode "$(JsonGetString '"result",'"${num}"',"message","caption"' <"$TMP")")"
|
||||
|
@ -74,13 +74,20 @@ Evertime a Message is recieved, you can read incoming data using the following v
|
||||
* ```${URLS[STICKER]}```: Stickers
|
||||
* ```${URLS[DOCUMENT]}```: Any other file
|
||||
* ```$CONTACT```: This array contains info about contacts sent in a chat.
|
||||
* ```${CONTACT[ID]}```: User id
|
||||
* ```${CONTACT[NUMBER]}```: Phone number
|
||||
* ```${CONTACT[FIRST_NAME]}```: First name
|
||||
* ```${CONTACT[LAST_NAME]}```: Last name
|
||||
* ```${CONTACT[ID]}```: User id
|
||||
* ```${CONTACT[VCARD]}```: User's complete Vcard
|
||||
* ```$LOCATION```: This array contains info about locations sent in a chat.
|
||||
* ```${LOCATION[LONGITUDE]}```: Longitude
|
||||
* ```${LOCATION[LATITUDE]}```: Latitude
|
||||
* ```$VENUE```: This array contains info about venue (a place) sent in a chat.
|
||||
* ```${VENUE[TITLE]}```: Name of the place
|
||||
* ```${VENUE[ADDRESS]}```: Address of the place
|
||||
* ```${VENUE[LONGITUDE]}```: Longitude
|
||||
* ```${VENUE[LATITUDE]}```: Latitude
|
||||
* ```${VENUE[FOURSQUARE]}```: Fouresquare ID
|
||||
|
||||
## Usage of bashbot functions
|
||||
|
||||
@ -159,5 +166,5 @@ send_action "${CHAT[ID]}" "action"
|
||||
#### [Prev Create Bot](1_firstbot.md)
|
||||
#### [Next Advanced Usage](3_advanced.md)
|
||||
|
||||
#### $$VERSION$$ v0.70-dev2-10-gfa9e879
|
||||
#### $$VERSION$$ v0.70-dev2-13-gca73be8
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# ADD a new test skeleton to test dir, but does not activate test
|
||||
#
|
||||
#### $$VERSION$$ v0.70-dev2-10-gfa9e879
|
||||
#### $$VERSION$$ v0.70-dev2-13-gca73be8
|
||||
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
# no matter from which directory we'll run script
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.70-dev2-10-gfa9e879
|
||||
#### $$VERSION$$ v0.70-dev2-13-gca73be8
|
||||
|
||||
# common variables
|
||||
export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# this has to run once atfer git clone
|
||||
# and every time we create new hooks
|
||||
#### $$VERSION$$ v0.70-dev2-11-g8549727
|
||||
#### $$VERSION$$ v0.70-dev2-13-gca73be8
|
||||
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
# no matter from which directory we'll run script
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.70-dev2-10-gfa9e879
|
||||
#### $$VERSION$$ v0.70-dev2-13-gca73be8
|
||||
|
||||
../dev/hooks/pre-commit.sh
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.70-dev2-10-gfa9e879
|
||||
#### $$VERSION$$ v0.70-dev2-13-gca73be8
|
||||
|
||||
../dev/hooks/pre-push.sh
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.70-dev2-10-gfa9e879
|
||||
#### $$VERSION$$ v0.70-dev2-13-gca73be8
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.70-dev2-12-gaa93839
|
||||
#### $$VERSION$$ v0.70-dev2-13-gca73be8
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.70-dev2-12-gaa93839
|
||||
#### $$VERSION$$ v0.70-dev2-13-gca73be8
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
@ -32,7 +32,7 @@ do
|
||||
{ process_message "0"; set +x; } >>"${LOGFILE}" 2>&1;
|
||||
|
||||
# output processed input
|
||||
print_array "USER" "CHAT" "REPLYTO" "FORWARD" "URLS" "CONTACT" "CAPTION" "LOCATION" "MESSAGE" >"${OUTPUTFILE}"
|
||||
print_array "USER" "CHAT" "REPLYTO" "FORWARD" "URLS" "CONTACT" "CAPTION" "LOCATION" "MESSAGE" "VENUE" >"${OUTPUTFILE}"
|
||||
diff -c "${REFFILE}" "${OUTPUTFILE}" || exit 1
|
||||
echo "${SUCCESS}"
|
||||
done
|
||||
|
@ -30,8 +30,14 @@ CONTACT: FIRST_NAME ADAC
|
||||
CONTACT: LAST_NAME Pannenhilfe
|
||||
CONTACT: NUMBER 222222
|
||||
CONTACT: USER_ID
|
||||
CONTACT: VCARD BEGIN:VCARD\nVERSION:2.1\nN:Pannenhilfe;ADAC;;;\nFN:ADAC Pannenhilfe\nTEL;CELL;PREF:+49179222222\nTEL;X-Mobil:222222\nEND:VCARD
|
||||
CAPTION: 0
|
||||
LOCATION: LATITUDE 49.631824
|
||||
LOCATION: LONGITUDE 8.377072
|
||||
MESSAGE: 0 😂😝👌☺❤😕😈#⃣🌏🎉🙊🙉☕🚀✈🚂💯✔〽🔚
|
||||
MESSAGE: ID 6541
|
||||
VENUE: ADDRESS Am Rhein 1
|
||||
VENUE: FOURSQUARE 4c4321afce54e21eee980d1a
|
||||
VENUE: LATITUDE 49.631824
|
||||
VENUE: LONGITUDE 8.377072
|
||||
VENUE: TITLE Kolb's Biergarten
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v0.70-dev2-12-gaa93839
|
||||
#### $$VERSION$$ v0.70-dev2-13-gca73be8
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
Loading…
Reference in New Issue
Block a user