doc: send_file URL and file_id

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-01-06 17:22:25 +01:00
parent c205ae528c
commit f08df73ddd
2 changed files with 15 additions and 9 deletions

View File

@ -261,7 +261,8 @@ BOTSENT is set on every send_xxx action and only valid until next send action. F
* `$BOTSENT`: This array contains the parsed results from the last transmission to telegram.
* `${BOTSENT[OK]}`: contains the string `true`: after a successful transmission
* `${BOTSENT[ID]}`: Message ID of sent message, image, file etc., if OK is true
* `${BOTSENT[FILE_ID]}`: unique identifier returned for an uploaded file or URL
* `${BOTSENT[FILE_TYPE]}`: file type: photo, audio, video, sticker, voice, document
## Usage of bashbot functions
@ -315,9 +316,10 @@ send_message "${CHAT[ID]}" "lol" "safe"
#### Send files, locations, keyboards.
To send images, videos, voice files, photos etc. use the `send_photo`function (remember to change the safety Regex @ line 14 of command.sh to allow sending files only from certain directories):
To send local files or URL's (photo, video, voice, sticker, documents) use the `send_file` function.
```bash
send_file "${CHAT[ID]}" "/home/user/doge.jpg" "Lool"
send_file "${CHAT[ID]}" "/home/user/dog.jpg" "Lool" "photo"
send_file "${CHAT[ID]}" "https://images-na.ssl-images-amazon.com/images/I/81DQ0FpoSNL._AC_SL1500_.jpg"
```
To send custom keyboards use the `send_keyboard`function:
```bash
@ -342,5 +344,5 @@ send_action "${CHAT[ID]}" "action"
#### [Prev Create Bot](1_firstbot.md)
#### [Next Advanced Usage](3_advanced.md)
#### $$VERSION$$ v1.25-dev-18-g3d9f784
#### $$VERSION$$ v1.25-dev-26-gc205ae5

View File

@ -117,25 +117,29 @@ The main use case for send_message is to process the output of interactive chats
##### send_file
send_file can send different file types using a local file or a http URL (_e.g. https://)
send_file can send local files, URL's or file_id's as different filex types (_e.g. photo video sticker_)
*usage:* send_file "${CHAT[ID]}" "file/URL" "caption" ["type"]
*usage:* send_file "${CHAT[ID]}" "file/URL/file_id" "caption" ["type"]
Argument "type" is optional, if not given `send_file` detects file type by the file extension.
if file/URL has no extension `photo` is assumed. Unknown types and extensions are send as type `document`
Supported file types are: photo (_png jpg jpeg gif pic_) audio (_mp3 flac_) sticker (_webp_) video (_mp4_) voice (_ogg_) or document.
It's recommended to use __absolute path names__ for local files (_starting with `/`_), as relative path names are threated as __relative to UPLOADDIR__ `data-bot-bash/upload`!
For security reasons the following restrictions apply to local files:
- absolute path name must match the __shell regex__ `FILE_REGEX` (_not file glob_)
- absolute path name must match the __shell regex__ `FILE_REGEX`
- relative path name is threated as relative to `UPLOADDIR` (_default: data-bot-bash/upload_)
- path must not start with `./` and not contain `../`
*example:*
```bash
# send picture from web
send_file "${CHAT[ID]}" "https://dealz.rrr.de/assets/images/rbofd-1.gif" "My Bot"
send_file "${CHAT[ID]}" "https://dealz.rrr.de/assets/images/rbofd-1.gif" "My Bot" "photo"
send_file "${CHAT[ID]}" "https://images-na.ssl-images-amazon.com/images/I/81DQ0FpoSNL._AC_SL1500_.jpg"
# local file recommended: absolute path
send_file "${CHAT[ID]}" "/home/user/dog.jpg" "My Dog"
@ -1193,5 +1197,5 @@ The name of your bot is available as bash variable "$ME", there is no need to ca
#### [Prev Best Practice](5_practice.md)
#### [Next Notes for Developers](7_develop.md)
#### $$VERSION$$ v1.25-dev-16-gdd19f0f
#### $$VERSION$$ v1.25-dev-26-gc205ae5