doc: send_file absolute path vs relative to UPLOADDIR

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-12-27 10:38:49 +01:00
parent de31231a24
commit 79402eca27
3 changed files with 28 additions and 15 deletions

View File

@ -13,7 +13,7 @@
# AUTHOR: KayM (gnadelwartz), kay@rrr.de # AUTHOR: KayM (gnadelwartz), kay@rrr.de
# CREATED: 18.12.2020 12:27 # CREATED: 18.12.2020 12:27
# #
#### $$VERSION$$ v1.20-3-g232a16b #### $$VERSION$$ v1.21-dev-2-gde31231
#=============================================================================== #===============================================================================
############ ############
@ -52,9 +52,10 @@ fi
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BASHBOT_HOME}/bashbot.sh" source "$1" source "${BASHBOT_HOME}/bashbot.sh" source "$1"
# overwrite bot FILE regex to BASHBOT_ETC # overwrite bot FILE regex to BASHBOT_VAR
# change this to the location you want to allow file uploads from # change this to the location you want to allow file uploads from
FILE_REGEX="${BASHBOT_ETC%/bin*}/.*" UPLOADDIR="${BASHBOT_VAR%/bin*}"
FILE_REGEX="${UPLOADDIR}/.*"
# get and check ADMIN and NAME # get and check ADMIN and NAME
BOT_ADMIN="$(getConfigKey "botadmin")" BOT_ADMIN="$(getConfigKey "botadmin")"

View File

@ -106,7 +106,7 @@ echo -e "Your Message: ${test}\nbye!"
#### message formatting and keyboards #### message formatting and keyboards
The output of the script will be processed by 'send_messages', so you can not only send text, but also keyboards, files, locations and more. The output of the script will be processed by 'send_messages', so you can not only send text, but also keyboards, files, locations and more.
Each newline in the output will start an new message to the userr. To have line breaks in your message you must insert ' mynewlinestartshere ' or '\n' instead. Each newline in the output will start an new message to the user. To have line breaks in your message you must insert ' mynewlinestartshere ' or '\n' instead.
To open up a keyboard in an interactive script, print out the keyboard layout in the following way: To open up a keyboard in an interactive script, print out the keyboard layout in the following way:
```bash ```bash
@ -114,8 +114,11 @@ echo "Text that will appear in chat? mykeyboardstartshere [ \"Yep, sure\" , \"No
``` ```
Same goes for files: Same goes for files:
```bash ```bash
echo "Text that will appear in chat? myfilelocationstartshere /home/user/doge.jpg" echo "Text that will appear in chat? myfilelocationstartshere /home/user/dog.jpg"
``` ```
*Note*: Use an _absolute path name_ (starting with `/`), a relative path name is relative to `data-bot-bash/upload`!
See [send_file documentation](6_reference.md#send_file) for more information.
And buttons: And buttons:
```bash ```bash
echo "Text that will appear in chat. mybtextstartshere Click me myburlstartshere https://dealz.rrr.de" echo "Text that will appear in chat. mybtextstartshere Click me myburlstartshere https://dealz.rrr.de"
@ -299,5 +302,5 @@ Note: If you disable automatic retry, se above, you disable also connection prob
#### [Prev Getting started](2_usage.md) #### [Prev Getting started](2_usage.md)
#### [Next Expert Use](4_expert.md) #### [Next Expert Use](4_expert.md)
#### $$VERSION$$ v1.20-0-g2ab00a2 #### $$VERSION$$ v1.21-dev-2-gde31231

View File

@ -114,20 +114,29 @@ The main use case for send_message is to process the output of interactive chats
##### send_file ##### send_file
send_file allows you to send different type's of files, e.g. photos, stickers, audio, media, etc. [see more](https://core.telegram.org/bots/api#sending-files) send_file allows you to send different type's of files, e.g. photos, stickers, audio, media, etc. [see more](https://core.telegram.org/bots/api#sending-files).
It's recommended to use the _absolute path name_ (starting with `/`). A relative path is threated as relative to `data-bot-bash/upload` as default UPLOADDIR.
- file names must not contain ".." For security reasons the following restrictions apply:
- file names must not start with "."
- file names not starting with "/" are relative to $TMPDIR, e.g. ./data-bot-bash - absolute path name must match the shell _regex_ FILE_REGEX (not file glob!)
- absolute filenames must match $FILE_REGEX - path must not start with "." and not contain ".."
- FILE_REGEX is a regular expression, not shell globbing, test you rexexes: http://www.softlion.com/webTools/RegExpTest/
*usage:* send_file "${CHAT[ID]}" "file" "caption" *usage:* send_file "${CHAT[ID]}" "file" "caption"
*example:* *example:*
```bash ```bash
send_file "${CHAT[ID]}" "/home/user/doge.jpg" "Lool" # recommended absolute path
send_file "${CHAT[ID]}" "https://www.domain,com/something.gif" "Something" send_file "${CHAT[ID]}" "/home/user/dog.jpg" "My Dog"
# relative to default dir: data-bot-bash/upload/dog.jpg
send_file "${CHAT[ID]}" "dog.jpg" "My Dog"
# change to personal dir
UPLOADDIR="/home/user/myuploaddir"
# relative to changed dir: /home/user/myuploaddir/dog.jpg
send_file "${CHAT[ID]}" "dog.jpg" "My Dog"
``` ```
##### send_album ##### send_album
@ -1145,5 +1154,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.20-0-g2ab00a2 #### $$VERSION$$ v1.21-dev-2-gde31231