Version 0.60-rc3

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-04-17 09:34:02 +02:00
parent 19a0f7eac3
commit f5162e2616
16 changed files with 59 additions and 46 deletions

View File

@ -8,7 +8,7 @@ Contributions by JuanPotato, BigNerd95, TiagoDanin, and iicc1.
Released to the public domain wherever applicable. Released to the public domain wherever applicable.
Elsewhere, consider it released under the [WTFPLv2](http://www.wtfpl.net/txt/copying/). Elsewhere, consider it released under the [WTFPLv2](http://www.wtfpl.net/txt/copying/).
## Prerequsites ## Prerequisites
Depends on [tmux](http://github.com/tmux/tmux). Depends on [tmux](http://github.com/tmux/tmux).
Uses [JSON.sh](http://github.com/dominictarr/JSON.sh). Uses [JSON.sh](http://github.com/dominictarr/JSON.sh).
@ -24,14 +24,14 @@ Bashbot [Documentation](https://github.com/topkecleon/telegram-bot-bash) and [Do
``` ```
git clone --recursive https://github.com/topkecleon/telegram-bot-bash git clone --recursive https://github.com/topkecleon/telegram-bot-bash
``` ```
3. Change to directory ```telegram-bot.bash```, run ```./bashbot.sh init``` and follow the instructions. At this stage you are asked for your Bots token given by botfather. 3. Change to directory ```telegram-bot-bash```, run ```./bashbot.sh init``` and follow the instructions. At this stage you are asked for your Bots token given by botfather.
## Update bashbot ## Update bashbot
1. [Download latest update zip from github](https://github.com/topkecleon/telegram-bot-bash/releases) 1. [Download latest update zip from github](https://github.com/topkecleon/telegram-bot-bash/releases)
2. Extract all files and copy them to your bashbot dir 2. Extract all files and copy them to your bashbot dir
3. Run ```sudo ./bashbot.sh init``` to setup your environment after the update- 3. Run ```sudo ./bashbot.sh init``` to setup your environment after the update
## Bashbot Documentation ## Documentation
* [Create a new Telegram Bot with botfather](doc/1_firstbot.md) * [Create a new Telegram Bot with botfather](doc/1_firstbot.md)
* [Getting Started](doc/2_usage.md) * [Getting Started](doc/2_usage.md)
* Managing your Bot * Managing your Bot
@ -57,13 +57,13 @@ Bashbot [Documentation](https://github.com/topkecleon/telegram-bot-bash) and [Do
From Version 0.60 on keybord format for ```send_keyboard``` and ```send_message "mykeyboardstartshere ..."``` was changed. From Version 0.60 on keybord format for ```send_keyboard``` and ```send_message "mykeyboardstartshere ..."``` was changed.
Keybords are now defined in JSON Array notation e.g. "[ \\"yes\\" , \\"no\\" ]". Keybords are now defined in JSON Array notation e.g. "[ \\"yes\\" , \\"no\\" ]".
This has the advantage that you can create any type of keyboard supported by Telegram. This has the advantage that you can create any type of keyboard supported by Telegram.
**This is an incompatible change for keyboards used in older bashbot versions.** The old format is supported for backward compatibility, but may fail for strange corner cases.
*Example Keyboards*: *Example Keyboards*:
- OLD format: 'yes' 'no' (two strings) - OLD format: 'yes' 'no' (two strings)
- NEW format: '[ "yes" , "no" ]' (string containing an array) - NEW format: '[ "yes" , "no" ]' (string containing an array)
- new keybord layouts, no possible with old format: - new keybord layouts, not possible with old format:
- Yes No in two rows: '[ "yes" ] , [ "no" ]' - Yes No in two rows: '[ "yes" ] , [ "no" ]'
- numpad style keyboard: '[ "1" , "2" , "3" ] , [ "4" , "5" , "6" ] , [ "7" , "8" , "9" ] , [ "0" ]' - numpad style keyboard: '[ "1" , "2" , "3" ] , [ "4" , "5" , "6" ] , [ "7" , "8" , "9" ] , [ "0" ]'
@ -97,4 +97,4 @@ Bashbot is not more (in)secure as any other Bot written in any other language, w
If you feel that there's something missing or if you found a bug, feel free to submit a pull request! If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
#### $$VERSION$$ v0.60-rc2-6-g2e3c975 #### $$VERSION$$ v0.60-rc3-0-g19a0f7e

View File

@ -11,8 +11,8 @@ Contributions by JuanPotato, BigNerd95, TiagoDanin, and iicc1.
Released to the public domain wherever applicable. Elsewhere, consider Released to the public domain wherever applicable. Elsewhere, consider
it released under the http://www.wtfpl.net/txt/copying/[WTFPLv2]. it released under the http://www.wtfpl.net/txt/copying/[WTFPLv2].
Prerequsites Prerequisites
~~~~~~~~~~~~ ~~~~~~~~~~~~~
Depends on http://github.com/tmux/tmux[tmux]. Uses Depends on http://github.com/tmux/tmux[tmux]. Uses
http://github.com/dominictarr/JSON.sh[JSON.sh]. http://github.com/dominictarr/JSON.sh[JSON.sh].
@ -35,7 +35,7 @@ Install bashbot
.... ....
git clone --recursive https://github.com/topkecleon/telegram-bot-bash git clone --recursive https://github.com/topkecleon/telegram-bot-bash
.... ....
3. Change to directory `telegram-bot.bash`, run `./bashbot.sh init` and 3. Change to directory `telegram-bot-bash`, run `./bashbot.sh init` and
follow the instructions. At this stage you are asked for your Bots token follow the instructions. At this stage you are asked for your Bots token
given by botfather. given by botfather.
@ -46,10 +46,10 @@ Update bashbot
latest update zip from github] latest update zip from github]
2. Extract all files and copy them to your bashbot dir 2. Extract all files and copy them to your bashbot dir
3. Run `sudo ./bashbot.sh init` to setup your environment after the 3. Run `sudo ./bashbot.sh init` to setup your environment after the
update- update
Bashbot Documentation Documentation
~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
* link:doc/1_firstbot.md[Create a new Telegram Bot with botfather] * link:doc/1_firstbot.md[Create a new Telegram Bot with botfather]
* link:doc/2_usage.md[Getting Started] * link:doc/2_usage.md[Getting Started]
@ -79,14 +79,14 @@ From Version 0.60 on keybord format for `send_keyboard` and
`send_message "mykeyboardstartshere ..."` was changed. Keybords are now `send_message "mykeyboardstartshere ..."` was changed. Keybords are now
defined in JSON Array notation e.g. "[ \"yes\" , \"no\" ]". This has the defined in JSON Array notation e.g. "[ \"yes\" , \"no\" ]". This has the
advantage that you can create any type of keyboard supported by advantage that you can create any type of keyboard supported by
Telegram. *This is an incompatible change for keyboards used in older Telegram. The old format is supported for backward compatibility, but
bashbot versions.* may fail for strange corner cases.
_Example Keyboards_: _Example Keyboards_:
* OLD format: 'yes' 'no' (two strings) * OLD format: 'yes' 'no' (two strings)
* NEW format: '[ "yes" , "no" ]' (string containing an array) * NEW format: '[ "yes" , "no" ]' (string containing an array)
* new keybord layouts, no possible with old format: * new keybord layouts, not possible with old format:
** Yes No in two rows: '[ "yes" ] , [ "no" ]' ** Yes No in two rows: '[ "yes" ] , [ "no" ]'
** numpad style keyboard: '[ "1" , "2" , "3" ] , [ "4" , "5" , "6" ] , [ ** numpad style keyboard: '[ "1" , "2" , "3" ] , [ "4" , "5" , "6" ] , [
"7" , "8" , "9" ] , [ "0" ]' "7" , "8" , "9" ] , [ "0" ]'
@ -159,5 +159,5 @@ That's it!
If you feel that there's something missing or if you found a bug, feel If you feel that there's something missing or if you found a bug, feel
free to submit a pull request! free to submit a pull request!
latexmath:[\[VERSION\]] v0.60-rc2-6-g2e3c975 latexmath:[\[VERSION\]] v0.60-rc3-0-g19a0f7e
++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++

View File

@ -7,7 +7,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.60-rc2-5-g591c583 #### $$VERSION$$ v0.60-rc3-0-g19a0f7e
SHELL=/bin/sh SHELL=/bin/sh

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# description: Start or stop telegram-bash-bot # description: Start or stop telegram-bash-bot
# #
#### $$VERSION$$ v0.60-rc2-5-g591c583 #### $$VERSION$$ v0.60-rc3-0-g19a0f7e
# shellcheck disable=SC2009 # shellcheck disable=SC2009
# shellcheck disable=SC2181 # shellcheck disable=SC2181

View File

@ -10,7 +10,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.60-rc2-6-g2e3c975 #### $$VERSION$$ v0.60-rc3-0-g19a0f7e
# #
# Exit Codes: # Exit Codes:
# - 0 sucess (hopefully) # - 0 sucess (hopefully)
@ -177,7 +177,7 @@ send_message() {
fi fi
if [ "$keyboard" != "" ]; then if [ "$keyboard" != "" ]; then
if [[ "$keyboard" != *"["* ]]; then # pre 0.60 style if [[ "$keyboard" != *"["* ]]; then # pre 0.60 style
keyboard="[ ${keyboard//\" \"/\" , \"} ]" keyboard="[ ${keyboard//\" \"/\" \] , \[ \"} ]"
fi fi
send_keyboard "$chat" "$text" "$keyboard" send_keyboard "$chat" "$text" "$keyboard"
sent=y sent=y
@ -357,7 +357,22 @@ answer_inline_query() {
} }
old_send_keyboard() {
local chat="$1"
local text="$2"
shift 2
local keyboard=init
OLDIFS=$IFS
IFS=$(echo -en "\"")
for f in "$@" ;do [ "$f" != " " ] && keyboard="$keyboard, [\"$f\"]";done
IFS=$OLDIFS
keyboard=${keyboard/init, /}
res="$(curl -s "$MSG_URL" --header "content-type: multipart/form-data" -F "chat_id=$chat" -F "text=$text" -F "reply_markup={\"keyboard\": [$keyboard],\"one_time_keyboard\": true}")"
}
send_keyboard() { send_keyboard() {
if [[ "$3" != *'['* ]]; then old_send_keyboard "$@"; return; fi
local chat="$1" local chat="$1"
local text="$2" local text="$2"
local keyboard="$3" local keyboard="$3"

2
calc
View File

@ -3,7 +3,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.60-rc2-5-g591c583 #### $$VERSION$$ v0.60-rc3-0-g19a0f7e
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -4,7 +4,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v0.60-rc2-5-g591c583 #### $$VERSION$$ v0.60-rc3-0-g19a0f7e
# #
# shellcheck disable=SC2154 # shellcheck disable=SC2154
# shellcheck disable=SC2034 # shellcheck disable=SC2034

View File

@ -61,5 +61,5 @@ group. This step is up to you actually.
#### [Next Getting started](2_usage.md) #### [Next Getting started](2_usage.md)
#### $$VERSION$$ v0.60-rc2-5-g591c583 #### $$VERSION$$ v0.60-rc3-0-g19a0f7e

View File

@ -159,5 +159,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$$ v0.60-rc2-5-g591c583 #### $$VERSION$$ v0.60-rc3-0-g19a0f7e

View File

@ -156,5 +156,5 @@ answer_inline_query "$iQUERY_ID" "cached_sticker" "identifier for the sticker"
#### [Prev Advanced Usage](3_advanced.md) #### [Prev Advanced Usage](3_advanced.md)
#### [Next Expert Use](4_expert.md) #### [Next Expert Use](4_expert.md)
#### $$VERSION$$ v0.60-rc2-5-g591c583 #### $$VERSION$$ v0.60-rc3-0-g19a0f7e

View File

@ -104,5 +104,5 @@ An example crontab is provided in ```bashbot.cron```.
#### [Prev Expert Use](4_expert.md) #### [Prev Expert Use](4_expert.md)
#### [Next Best Practice](5_practice.md) #### [Next Best Practice](5_practice.md)
#### $$VERSION$$ v0.60-rc2-5-g591c583 #### $$VERSION$$ v0.60-rc3-0-g19a0f7e

View File

@ -112,5 +112,5 @@ The second warning is about an unused variable, this is true because in our exam
#### [Prev Best Practice](5_practice.md) #### [Prev Best Practice](5_practice.md)
#### [Next Functions Reference](6_reference.md) #### [Next Functions Reference](6_reference.md)
#### $$VERSION$$ v0.60-rc2-5-g591c583 #### $$VERSION$$ v0.60-rc3-0-g19a0f7e

View File

@ -90,14 +90,8 @@ answer_inline_query provide the result to a users Inline Query
---- ----
### File, Location, Venu, keyboards ### File, Location, Venue, Keyboard
##### get_file
*usage:*
*example:*
```bash
```
##### 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)
@ -125,23 +119,22 @@ Note: since version 0.6 send_keyboard was changed to use native "JSON Array" not
- OLD format: 'yes' 'no' (two strings) - OLD format: 'yes' 'no' (two strings)
- NEW format: '[ "yes" , "no" ]' (string containing an array) - NEW format: '[ "yes" , "no" ]' (string containing an array)
- new keybord layouts, no possible with old format: - new keybord layouts, not possible with old format:
- Yes No in two rows: '[ "yes" ] , [ "no" ]' - Yes No in two rows: '[ "yes" ] , [ "no" ]'
- numpad style keyboard: '[ "1" , "2" , "3" ] , [ "4" , "5" , "6" ] , [ "7" , "8" , "9" ] , [ "0" ]' - numpad style keyboard: '[ "1" , "2" , "3" ] , [ "4" , "5" , "6" ] , [ "7" , "8" , "9" ] , [ "0" ]'
*usage:* send_keyboard "chat-id" "keyboard" *usage:* send_keyboard "chat-id" "message" "keyboard"
*example:* *example:*
```bash ```bash
send_keyboard "${CHAT[ID]}" "[ \\"yes\" , \\"no\" ]"" send_keyboard "${CHAT[ID]}" "Say yes or no" "[ \\"yes\" , \\"no\" ]""
send_keyboard "${CHAT[ID]}" "[ \\"yes\\" ] , [ \\"no\\" ]" send_keyboard "${CHAT[ID]}" "Say yes or no" "[ \\"yes\\" ] , [ \\"no\\" ]"
send_keyboard "${CHAT[ID]}" "[ \\"1\\" , \\"2\\" , \\"3\\" ] , [ \\"4\\" , \\"5\\" , \\"6\\" ] , [ \\"7\\" , \\"8\\" , \\"9\\" ] , [ \\"0\\" ]" send_keyboard "${CHAT[ID]}" "Enter digit" "[ \\"1\\" , \\"2\\" , \\"3\\" ] , [ \\"4\\" , \\"5\\" , \\"6\\" ] , [ \\"7\\" , \\"8\\" , \\"9\\" ] , [ \\"0\\" ]"
``` ```
##### remove_keyboard ##### remove_keyboard
*usage:* *usage:* remove_keybord "$CHAT[ID]" "message"
### Manage users ### Manage users
@ -304,6 +297,11 @@ fi
### 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")"
----
##### send_text ##### send_text
*usage:* send_text "${CHAT[ID]}" "message" *usage:* send_text "${CHAT[ID]}" "message"
@ -348,5 +346,5 @@ Send Input from Telegram to waiting Interactive Chat.
#### [Prev Best Practice](5_practice.md) #### [Prev Best Practice](5_practice.md)
#### $$VERSION$$ v0.60-rc2-5-g591c583 #### $$VERSION$$ v0.60-rc3-0-g19a0f7e

2
notify
View File

@ -2,7 +2,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.60-rc2-5-g591c583 #### $$VERSION$$ v0.60-rc3-0-g19a0f7e
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -3,7 +3,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.60-rc2-6-g2e3c975 #### $$VERSION$$ v0.60-rc3-0-g19a0f7e
# adjust your language setting here # adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# #
#### $$VERSION$$ v0.60-rc2-5-g591c583 #### $$VERSION$$ v0.60-rc3-0-g19a0f7e
# shellcheck disable=SC2016 # shellcheck disable=SC2016
# #
# Easy Versioning in git: # Easy Versioning in git: