From f08df73ddd65c71525863b5ab7a2926f02b94369 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Wed, 6 Jan 2021 17:22:25 +0100 Subject: [PATCH] doc: send_file URL and file_id --- doc/2_usage.md | 10 ++++++---- doc/6_reference.md | 14 +++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/doc/2_usage.md b/doc/2_usage.md index 848c1b1..5e4f4e7 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -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 diff --git a/doc/6_reference.md b/doc/6_reference.md index 0c67f00..478034d 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -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