mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-06-08 21:22:24 +00:00
doc: adjust user visible changes to URLS and download_file
This commit is contained in:
parent
bc40a3fcbb
commit
baa4e14ebc
|
@ -186,13 +186,14 @@ The following variables are set if the message contains optional parts:
|
||||||
* `${FORWARD[LAST_NAME]}`: Original user's' last name
|
* `${FORWARD[LAST_NAME]}`: Original user's' last name
|
||||||
* `${FORWARD[USERNAME]}`: Original user's username
|
* `${FORWARD[USERNAME]}`: Original user's username
|
||||||
* `$CAPTION`: Picture, Audio, Video, File Captions
|
* `$CAPTION`: Picture, Audio, Video, File Captions
|
||||||
* `$URLS`: This array contains documents, audio files, voice recordings and stickers as URL.
|
* `$URLS`: This array contains `path` to document, audio file, voice recording and sticker for download from telegram server.
|
||||||
* `${URLS[AUDIO]}`: Audio files
|
* `${URLS[AUDIO]}`: Path to audio file
|
||||||
* `${URLS[VIDEO]}`: Videos
|
* `${URLS[VIDEO]}`: Path to video
|
||||||
* `${URLS[PHOTO]}`: Photos (maximum quality)
|
* `${URLS[PHOTO]}`: Path to photo (maximum quality)
|
||||||
* `${URLS[VOICE]}`: Voice recordings
|
* `${URLS[VOICE]}`: Path to voice recording
|
||||||
* `${URLS[STICKER]}`: Stickers
|
* `${URLS[STICKER]}`: Path to sticker
|
||||||
* `${URLS[DOCUMENT]}`: Any other file
|
* `${URLS[DOCUMENT]}`: Path to any other file
|
||||||
|
**Important:** This is NO MORE a full URL, you must use `download_file` or `${URL}/${URLS[xxx]}` for manual download.
|
||||||
* `$CONTACT`: This array contains info about contacts sent in a chat.
|
* `$CONTACT`: This array contains info about contacts sent in a chat.
|
||||||
* `${CONTACT[ID]}`: User id
|
* `${CONTACT[ID]}`: User id
|
||||||
* `${CONTACT[NUMBER]}`: Phone number
|
* `${CONTACT[NUMBER]}`: Phone number
|
||||||
|
@ -238,6 +239,7 @@ e.g. if a new user joins a chat MESSAGE is set to "/_new_chat_user".
|
||||||
* `${MESSAGE}`: /_new_chat_title SENDER TEXT
|
* `${MESSAGE}`: /_new_chat_title SENDER TEXT
|
||||||
* `${SERVICE[NEWPHOTO]}`: New Chat Picture
|
* `${SERVICE[NEWPHOTO]}`: New Chat Picture
|
||||||
* `${MESSAGE}`: /_new_chat_picture SENDER URL
|
* `${MESSAGE}`: /_new_chat_picture SENDER URL
|
||||||
|
**Important:** SERVICE[NEWPHOTO] is NOT a full URL, you must use `download_file` or `${URL}/${SERVICE[NEWPHOTO]}` for manual download.
|
||||||
* `${SERVICE[PINNED]}`: Pinned MESSAGE ID
|
* `${SERVICE[PINNED]}`: Pinned MESSAGE ID
|
||||||
* `${MESSAGE}`: /_new_pinned_message SENDER ID
|
* `${MESSAGE}`: /_new_pinned_message SENDER ID
|
||||||
* `${PINNED[ID]}`: Id of pinned message
|
* `${PINNED[ID]}`: Id of pinned message
|
||||||
|
@ -372,5 +374,5 @@ send_action "${CHAT[ID]}" "action"
|
||||||
#### [Prev Create Bot](1_firstbot.md)
|
#### [Prev Create Bot](1_firstbot.md)
|
||||||
#### [Next Advanced Usage](3_advanced.md)
|
#### [Next Advanced Usage](3_advanced.md)
|
||||||
|
|
||||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
#### $$VERSION$$ v1.41-dev-3-gbc40a3f
|
||||||
|
|
||||||
|
|
|
@ -1398,18 +1398,40 @@ Do not use them in other files e.g. `bashbot.sh`, modules, addons etc.
|
||||||
|
|
||||||
### Helper functions
|
### Helper functions
|
||||||
|
|
||||||
##### download
|
##### download_file
|
||||||
Download the given URL and returns the final filename in TMPDIR. If the given filename exists,the filename is prefixed with a
|
`download_file` download a file to DATADIR and returns the PATH to the file, main use is to download files send to chats.
|
||||||
random number. Filename is not allowed to contain '/' or '..'.
|
I tried to be as compatible as possible with old function `download`.
|
||||||
|
|
||||||
*usage:* download URL filename
|
*usage:* download_file path_to_ile prosed_filename
|
||||||
|
|
||||||
|
*alias*: download
|
||||||
|
|
||||||
|
*Note:* You must use `download_file` to download `URLS[...]` or `SERVICE[NEWPHOTO]` URLs from Telegram server.
|
||||||
|
|
||||||
*example:*
|
*example:*
|
||||||
```bash
|
```bash
|
||||||
|
########
|
||||||
|
# download from Telegram server
|
||||||
|
# photo received in a chat
|
||||||
|
photo="${URLS[PHOTO]}")"
|
||||||
|
echo "$photo" -> photo/file_1234.jpg
|
||||||
|
|
||||||
|
# first download
|
||||||
|
file="$(download_file "${photo}"
|
||||||
|
echo "$file" -> ./data-bot-bash/photo-file_1234.jpg
|
||||||
|
|
||||||
|
# second, third etc. download
|
||||||
|
file="$(download_file "${photo}"
|
||||||
|
echo "$file" -> ./data-bot-bash/jkdfhihsdkf-photo-file_1234.jpg
|
||||||
|
|
||||||
|
|
||||||
|
########
|
||||||
|
# download from other sources (full URL)
|
||||||
file="$(download "https://avatars.githubusercontent.com/u/13046303" "avatar.jpg")"
|
file="$(download "https://avatars.githubusercontent.com/u/13046303" "avatar.jpg")"
|
||||||
echo "$file" -> ./data-bot-bash/avatar.jpg
|
echo "$file" -> ./data-bot-bash/avatar.jpg
|
||||||
|
|
||||||
file="$(download "https://avatars.githubusercontent.com/u/13046303" "avatar.jpg")"
|
file="$(download "https://avatars.githubusercontent.com/u/13046303" "avatar.jpg")"
|
||||||
echo "$file" -> ./data-bot-bash/12345-avatar.jpg
|
echo "$file" -> ./data-bot-bash/jhsdfjkakshdfkja-avatar.jpg
|
||||||
```
|
```
|
||||||
|
|
||||||
##### _exec_if_function
|
##### _exec_if_function
|
||||||
|
@ -1455,6 +1477,9 @@ _is_function "background" && _message "you can run background jobs!"
|
||||||
### Bashbot internal functions
|
### Bashbot internal functions
|
||||||
These functions are for internal use only and must not used in your bot commands.
|
These functions are for internal use only and must not used in your bot commands.
|
||||||
|
|
||||||
|
##### get_file
|
||||||
|
*usage:* url="$(get_file "CHAT[ID]" "message")"
|
||||||
|
|
||||||
##### procname
|
##### procname
|
||||||
Returns PrefixBotname_Postfix
|
Returns PrefixBotname_Postfix
|
||||||
|
|
||||||
|
@ -1506,11 +1531,6 @@ killallproc
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
##### get_file
|
|
||||||
*usage:* url="$(get_file "CHAT[ID]" "message")"
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
##### JsonDecode
|
##### JsonDecode
|
||||||
Outputs decoded string to STDOUT
|
Outputs decoded string to STDOUT
|
||||||
|
|
||||||
|
@ -1578,5 +1598,5 @@ The name of your bot is available as bash variable "$ME", there is no need to ca
|
||||||
#### [Prev Best Practice](5_practice.md)
|
#### [Prev Best Practice](5_practice.md)
|
||||||
#### [Next Notes for Developers](7_develop.md)
|
#### [Next Notes for Developers](7_develop.md)
|
||||||
|
|
||||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
#### $$VERSION$$ v1.41-dev-3-gbc40a3f
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user