diff --git a/README.md b/README.md index 9e003ba..01d4187 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Contributions by JuanPotato, BigNerd95, TiagoDanin, and iicc1. Released to the public domain wherever applicable. Elsewhere, consider it released under the [WTFPLv2](http://www.wtfpl.net/txt/copying/). -## Prerequsites +## Prerequisites Depends on [tmux](http://github.com/tmux/tmux). 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 ``` -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 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 -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) * [Getting Started](doc/2_usage.md) * 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. 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 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*: - OLD format: 'yes' 'no' (two strings) - 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" ]' - 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! -#### $$VERSION$$ v0.60-rc2-6-g2e3c975 +#### $$VERSION$$ v0.60-rc3-0-g19a0f7e diff --git a/README.txt b/README.txt index 2366bdd..1dc7eaa 100644 --- a/README.txt +++ b/README.txt @@ -11,8 +11,8 @@ Contributions by JuanPotato, BigNerd95, TiagoDanin, and iicc1. Released to the public domain wherever applicable. Elsewhere, consider it released under the http://www.wtfpl.net/txt/copying/[WTFPLv2]. -Prerequsites -~~~~~~~~~~~~ +Prerequisites +~~~~~~~~~~~~~ Depends on http://github.com/tmux/tmux[tmux]. Uses http://github.com/dominictarr/JSON.sh[JSON.sh]. @@ -35,7 +35,7 @@ Install bashbot .... 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 given by botfather. @@ -46,10 +46,10 @@ Update bashbot latest update zip from github] 2. Extract all files and copy them to your bashbot dir 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/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 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 is an incompatible change for keyboards used in older -bashbot versions.* +Telegram. The old format is supported for backward compatibility, but +may fail for strange corner cases. _Example Keyboards_: * OLD format: 'yes' 'no' (two strings) * 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" ]' ** numpad style keyboard: '[ "1" , "2" , "3" ] , [ "4" , "5" , "6" ] , [ "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 free to submit a pull request! -latexmath:[\[VERSION\]] v0.60-rc2-6-g2e3c975 +latexmath:[\[VERSION\]] v0.60-rc3-0-g19a0f7e ++++++++++++++++++++++++++++++++++++++++++++ diff --git a/bashbot.cron b/bashbot.cron index bffec6d..502c7b6 100644 --- a/bashbot.cron +++ b/bashbot.cron @@ -7,7 +7,7 @@ # This file is public domain in the USA and all free countries. # 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 diff --git a/bashbot.rc b/bashbot.rc index 0da76e8..5361ac4 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,7 +1,7 @@ #!/bin/sh # description: Start or stop telegram-bash-bot # -#### $$VERSION$$ v0.60-rc2-5-g591c583 +#### $$VERSION$$ v0.60-rc3-0-g19a0f7e # shellcheck disable=SC2009 # shellcheck disable=SC2181 diff --git a/bashbot.sh b/bashbot.sh index c3fcc5a..b84c82f 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -10,7 +10,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.60-rc2-6-g2e3c975 +#### $$VERSION$$ v0.60-rc3-0-g19a0f7e # # Exit Codes: # - 0 sucess (hopefully) @@ -177,7 +177,7 @@ send_message() { fi if [ "$keyboard" != "" ]; then if [[ "$keyboard" != *"["* ]]; then # pre 0.60 style - keyboard="[ ${keyboard//\" \"/\" , \"} ]" + keyboard="[ ${keyboard//\" \"/\" \] , \[ \"} ]" fi send_keyboard "$chat" "$text" "$keyboard" 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() { + if [[ "$3" != *'['* ]]; then old_send_keyboard "$@"; return; fi local chat="$1" local text="$2" local keyboard="$3" diff --git a/calc b/calc index e4cb9d0..c5e9135 100755 --- a/calc +++ b/calc @@ -3,7 +3,7 @@ # This file is public domain in the USA and all free countries. # 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 # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/commands.sh b/commands.sh index 7d4c402..c70a39d 100755 --- a/commands.sh +++ b/commands.sh @@ -4,7 +4,7 @@ # This file is public domain in the USA and all free countries. # 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=SC2034 diff --git a/doc/1_firstbot.md b/doc/1_firstbot.md index 004132f..7c92642 100644 --- a/doc/1_firstbot.md +++ b/doc/1_firstbot.md @@ -61,5 +61,5 @@ group. This step is up to you actually. #### [Next Getting started](2_usage.md) -#### $$VERSION$$ v0.60-rc2-5-g591c583 +#### $$VERSION$$ v0.60-rc3-0-g19a0f7e diff --git a/doc/2_usage.md b/doc/2_usage.md index 23250f6..e04b367 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -159,5 +159,5 @@ send_action "${CHAT[ID]}" "action" #### [Prev Create Bot](1_firstbot.md) #### [Next Advanced Usage](3_advanced.md) -#### $$VERSION$$ v0.60-rc2-5-g591c583 +#### $$VERSION$$ v0.60-rc3-0-g19a0f7e diff --git a/doc/3_advanced.md b/doc/3_advanced.md index be7de82..6bc50bc 100644 --- a/doc/3_advanced.md +++ b/doc/3_advanced.md @@ -156,5 +156,5 @@ answer_inline_query "$iQUERY_ID" "cached_sticker" "identifier for the sticker" #### [Prev Advanced Usage](3_advanced.md) #### [Next Expert Use](4_expert.md) -#### $$VERSION$$ v0.60-rc2-5-g591c583 +#### $$VERSION$$ v0.60-rc3-0-g19a0f7e diff --git a/doc/4_expert.md b/doc/4_expert.md index a7786f5..26d7b74 100644 --- a/doc/4_expert.md +++ b/doc/4_expert.md @@ -104,5 +104,5 @@ An example crontab is provided in ```bashbot.cron```. #### [Prev Expert Use](4_expert.md) #### [Next Best Practice](5_practice.md) -#### $$VERSION$$ v0.60-rc2-5-g591c583 +#### $$VERSION$$ v0.60-rc3-0-g19a0f7e diff --git a/doc/5_practice.md b/doc/5_practice.md index 56bb5af..6b640ab 100644 --- a/doc/5_practice.md +++ b/doc/5_practice.md @@ -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) #### [Next Functions Reference](6_reference.md) -#### $$VERSION$$ v0.60-rc2-5-g591c583 +#### $$VERSION$$ v0.60-rc3-0-g19a0f7e diff --git a/doc/6_reference.md b/doc/6_reference.md index c596ff2..a84ec9d 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -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 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) - 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" ]' - 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:* ```bash -send_keyboard "${CHAT[ID]}" "[ \\"yes\" , \\"no\" ]"" -send_keyboard "${CHAT[ID]}" "[ \\"yes\\" ] , [ \\"no\\" ]" -send_keyboard "${CHAT[ID]}" "[ \\"1\\" , \\"2\\" , \\"3\\" ] , [ \\"4\\" , \\"5\\" , \\"6\\" ] , [ \\"7\\" , \\"8\\" , \\"9\\" ] , [ \\"0\\" ]" +send_keyboard "${CHAT[ID]}" "Say yes or no" "[ \\"yes\" , \\"no\" ]"" +send_keyboard "${CHAT[ID]}" "Say yes or no" "[ \\"yes\\" ] , [ \\"no\\" ]" +send_keyboard "${CHAT[ID]}" "Enter digit" "[ \\"1\\" , \\"2\\" , \\"3\\" ] , [ \\"4\\" , \\"5\\" , \\"6\\" ] , [ \\"7\\" , \\"8\\" , \\"9\\" ] , [ \\"0\\" ]" ``` ##### remove_keyboard -*usage:* - +*usage:* remove_keybord "$CHAT[ID]" "message" ### Manage users @@ -304,6 +297,11 @@ fi ### Bashbot internal functions 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 *usage:* send_text "${CHAT[ID]}" "message" @@ -348,5 +346,5 @@ Send Input from Telegram to waiting Interactive Chat. #### [Prev Best Practice](5_practice.md) -#### $$VERSION$$ v0.60-rc2-5-g591c583 +#### $$VERSION$$ v0.60-rc3-0-g19a0f7e diff --git a/notify b/notify index 09b392e..c2010e5 100755 --- a/notify +++ b/notify @@ -2,7 +2,7 @@ # This file is public domain in the USA and all free countries. # 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 # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/question b/question index 2c969a9..5b51f26 100755 --- a/question +++ b/question @@ -3,7 +3,7 @@ # This file is public domain in the USA and all free countries. # 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 # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/version b/version index ea4636d..bd6b524 100755 --- a/version +++ b/version @@ -1,6 +1,6 @@ #!/bin/bash # -#### $$VERSION$$ v0.60-rc2-5-g591c583 +#### $$VERSION$$ v0.60-rc3-0-g19a0f7e # shellcheck disable=SC2016 # # Easy Versioning in git: