diff --git a/README.md b/README.md index 2337969..800e8d1 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Most complete [UTF-8 support for bashbot](doc/4_expert.md#Bashbot-UTF-8-Support) Bashbot [Documentation](https://github.com/topkecleon/telegram-bot-bash) and [Downloads](https://github.com/topkecleon/telegram-bot-bash/releases) are availible on www.github.com ## Documentation -* [Bots: Introduction for developers] (https://core.telegram.org/bots) +* [Bots: Introduction for developers](https://core.telegram.org/bots) * [The one to rule them all](https://core.telegram.org/bots#3-how-do-i-create-a-bot) * [Bot commands](https://core.telegram.org/bots#commands) * [Install Bashbot](doc/0_install.md) @@ -79,4 +79,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.70-pre1-1-gbd4a116 +#### $$VERSION$$ v0.70-pre1-2-g293ad08 diff --git a/README.txt b/README.txt index 2aae368..1eeefaf 100644 --- a/README.txt +++ b/README.txt @@ -27,7 +27,7 @@ are availible on www.github.com Documentation ~~~~~~~~~~~~~ -* [Bots: Introduction for developers] (https://core.telegram.org/bots) +* https://core.telegram.org/bots[Bots: Introduction for developers] ** https://core.telegram.org/bots#3-how-do-i-create-a-bot[The one to rule them all] ** https://core.telegram.org/bots#commands[Bot commands] @@ -127,5 +127,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.70-pre1-1-gbd4a116 +latexmath:[\[VERSION\]] v0.70-pre1-2-g293ad08 +++++++++++++++++++++++++++++++++++++++++++++ diff --git a/commands.sh b/commands.sh index de71c7c..c4d9000 100644 --- a/commands.sh +++ b/commands.sh @@ -5,7 +5,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.70-pre1-0-g490c472 +#### $$VERSION$$ v0.70-pre1-2-g293ad08 # # shellcheck disable=SC2154 # shellcheck disable=SC2034 @@ -31,6 +31,7 @@ It currently can send, recieve and forward messages, custom keyboards, photos, a # to change the default help messages overwrite in mycommands.sh bashbot_help='*Available commands*: *• /start*: _Start bot and get this message_. +*• /help*: _Get this message_. *• /info*: _Get shorter info message about this bot_. *• /question*: _Start interactive chat_. *• /cancel*: _Cancel any currently running interactive chats_. @@ -97,11 +98,11 @@ else fi case "$MESSAGE" in ################################################ - # DEFAULT commands start here, edit messages only - '/info') + # GLOBAL commands start here, edit messages only + '/info'*) _markdown_message "${bashbot_info}" ;; - '/start') + '/start'*) send_action "${CHAT[ID]}" "typing" _is_botadmin && _markdown_message "You are *BOTADMIN*." if _is_allowed "start" ; then @@ -111,19 +112,22 @@ else fi ;; - '/leavechat') # bot leave chat if user is admin in chat + '/help'*) + _markdown_message "${bot_help}" + ;; + '/leavechat'*) # bot leave chat if user is admin in chat if _is_admin ; then _markdown_message "*LEAVING CHAT...*" _leave fi ;; - '/kickme') + '/kickme'*) _kick_user "${USER[ID]}" _unban_user "${USER[ID]}" ;; - '/cancel') + '/cancel'*) checkprog if [ "$res" -eq 0 ] ; then killproc && _message "Command canceled.";else _message "No command is currently running.";fi ;; diff --git a/doc/0_install.md b/doc/0_install.md index 5a4b6d6..fd14b20 100644 --- a/doc/0_install.md +++ b/doc/0_install.md @@ -12,7 +12,7 @@ Now your Bot is ready to start ... -If you are new to Bot development read [Bots: An introduction for developers](https://core.telegram.org/bots) +**If you are new to Bot development read [Bots: An introduction for developers](https://core.telegram.org/bots)** ### Install from Github @@ -63,5 +63,5 @@ The old format is supported for backward compatibility, but may fail for corner #### [Next Create Bot](1_firstbot.md) -#### $$VERSION$$ v0.70-pre1-1-gbd4a116 +#### $$VERSION$$ v0.70-pre1-2-g293ad08 diff --git a/doc/1_firstbot.md b/doc/1_firstbot.md index dbc8744..819be0a 100644 --- a/doc/1_firstbot.md +++ b/doc/1_firstbot.md @@ -1,8 +1,6 @@ #### [Home](../README.md) ## Create a Telegram Bot with botfather -[BotFather is the one bot to rule them all](https://core.telegram.org/bots#3-how-do-i-create-a-bot). It will help you create new bots and change settings for existing ones. - -[Commands known by Botfather](https://core.telegram.org/bots#generating-an-authorization-token) +**[BotFather is the one bot to rule them all](https://core.telegram.org/bots#3-how-do-i-create-a-bot). It will help you create new bots and change settings for existing ones.** [Commands known by Botfather](https://core.telegram.org/bots#generating-an-authorization-token) ### Creating a new Bot @@ -67,5 +65,5 @@ group. This step is up to you actually. #### [Prev Installation](0_install.md) #### [Next Getting started](2_usage.md) -#### $$VERSION$$ v0.70-pre1-1-gbd4a116 +#### $$VERSION$$ v0.70-pre1-2-g293ad08 diff --git a/doc/2_usage.md b/doc/2_usage.md index 513d2d8..b4706cc 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -37,7 +37,7 @@ To send a broadcast to all of users that ever used the bot run the following com ## Recieve data Evertime a Message is recieved, you can read incoming data using the following variables: -* ```${MESSAGE}```: Current incoming messages +* ```${MESSAGE}```: Current message * ```${MESSAGE[ID]}```: ID of current message * ```$CAPTION```: Captions * ```$REPLYTO```: Original message wich was replied to @@ -66,7 +66,7 @@ Evertime a Message is recieved, you can read incoming data using the following v * ```${FORWARD[FIRST_NAME]}```: Original user's first name * ```${FORWARD[LAST_NAME]}```: Original user's' last name * ```${FORWARD[USERNAME]}```: Original user's username -* ```$URLS```: This array contains documents, audio files, stickers, voice recordings and stickers stored in the form of URLs. +* ```$URLS```: This array contains documents, audio files, voice recordings and stickers as URL. * ```${URLS[AUDIO]}```: Audio files * ```${URLS[VIDEO]}```: Videos * ```${URLS[PHOTO]}```: Photos (maximum quality) @@ -136,7 +136,7 @@ This function also allows a third parameter that disables additional function pa ```bash send_message "${CHAT[ID]}" "lol" "safe" ``` -More examples boutsend_message strings can be found in [Advanced Usage](3_advanced.md#Interactive-Chats) +**See also [Interactive chats](3_advanced.md#Interactive-Chats)** #### Send files, locations, keyboards. @@ -162,10 +162,10 @@ Allowed values: typing for text messages, upload_photo for photos, record_video ```bash send_action "${CHAT[ID]}" "action" ``` -See also [Bashbot function reference](6_reference.md) +**See also [Bashbot function reference](6_reference.md#Interactive_Chats)** #### [Prev Create Bot](1_firstbot.md) #### [Next Advanced Usage](3_advanced.md) -#### $$VERSION$$ v0.70-pre1-1-gbd4a116 +#### $$VERSION$$ v0.70-pre1-2-g293ad08 diff --git a/doc/3_advanced.md b/doc/3_advanced.md index ecef80a..f9a187b 100644 --- a/doc/3_advanced.md +++ b/doc/3_advanced.md @@ -47,7 +47,9 @@ In addition you can check individual capabilities of users as you must define in You must use the function ```user_is_allowed``` to check if a user has the capability to do something. Example: Check if user has capability to start bot. ```bash case "$MESSAGE" in - '/start') + ################################################ + # GLOBAL commands start here, only edit messages + '/start'*) user_is_botadmin "${USER[ID]}" && send_markdown_message "${CHAT[ID]}" "You are *BOTADMIN*." if user_is_allowed "${USER[ID]}" "start" "${CHAT[ID]}" ; then bot_help "${CHAT[ID]}" @@ -56,7 +58,7 @@ You must use the function ```user_is_allowed``` to check if a user has the capab ;; esac ``` -See also [Bashbot User Access Control functions](6_functions.md#User_Access_Control) +**See also [Bashbot User Access Control functions](6_functions.md#User_Access_Control)** ### Interactive Chats To create interactive chats, write *(or edit the 'exmaples/question.sh' script)* a bash *(or C or python)* script, make it executable @@ -167,5 +169,5 @@ answer_inline_query "$iQUERY_ID" "cached_sticker" "identifier for the sticker" #### [Prev Getting started](2_usage.md) #### [Next Expert Use](4_expert.md) -#### $$VERSION$$ v0.70-pre1-1-gbd4a116 +#### $$VERSION$$ v0.70-pre1-2-g293ad08 diff --git a/doc/5_practice.md b/doc/5_practice.md index a673976..6ed4b47 100644 --- a/doc/5_practice.md +++ b/doc/5_practice.md @@ -1,6 +1,14 @@ #### [Home](../README.md) ## Best Practices +### New to bot development? + +If you are new to Bot development read [Bots: An introduction for developers](https://core.telegram.org/bots) and consult [Telegram Bot API Documentaion](https://core.telegram.org/bots/api/). + +In addition you should know about [BotFatheri, the one bot to rule them all](https://core.telegram.org/bots#3-how-do-i-create-a-bot). It will help you create new bots and change settings for existing ones. [Commands known by Botfather](https://core.telegram.org/bots#generating-an-authorization-token) + +If you dont't have a gibtup account, it may time to [sepup a free account now](https://github.com/pricing) + ### Add commands to mycommands.sh only To ease updates never change ```bashbot.sh```, instead your commands and functions must go to ```mycommands.sh``` . Insert your Bot commands in the ```case ... esac``` block of the 'mycommands()' function: ```bash @@ -15,6 +23,7 @@ To ease updates never change ```bashbot.sh```, instead your commands and functio /echo message - _echo the given messsage_ ' +# NOTE: command can have @botname attached, you must add * in case tests... mycommands() { case "$MESSAGE" in @@ -26,19 +35,22 @@ mycommands() { } ``` -### Reuse or disable standard commands -If you want to disable or reuse a standard bashbot command comment it out in 'commands.sh' by placing a '#' in front of +### Reuse or disable global commands + +If you want to disable or reuse a global bashbot command comment it out in 'commands.sh' by placing a '#' in front of every line from ```'/command')``` to ```;;```. +**Learn more about [Bot (global) commands](https://core.telegram.org/bots#commands).** + **Note: Never disable the catchall command ```*)``` in 'commands.sh'!!** ```bash # file: commands.sh case "$MESSAGE" in ################################################ - # DEFAULT commands start here, edit messages only + # GLOBAL commands start here, edit messages only - #'/start') + #'/start'*) # send_action "${CHAT[ID]}" "typing" # _is_botadmin && _markdown_message "You are *BOTADMIN*." # if _is_allowed "start" ; then @@ -66,7 +78,7 @@ If a command need more than 2-3 lines of code, you should use a function to sepe mycommands() { case "$MESSAGE" in - '/process') # logic for /process is done in process_message + '/process'*) # logic for /process is done in process_message result="$(process_message "$MESSAGE")" send_normal_message "${CHAT[ID]}" "$result" ;; @@ -141,5 +153,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.70-pre1-0-g490c472 +#### $$VERSION$$ v0.70-pre1-2-g293ad08 diff --git a/doc/6_reference.md b/doc/6_reference.md index 8b847bb..7736238 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -194,7 +194,7 @@ if _is_admin ; then fi ``` -See also [kicki Chat Member](https://core.telegram.org/bots/api/#kickchatmember) +See also [kick Chat Member](https://core.telegram.org/bots/api/#kickchatmember) ---- @@ -234,7 +234,7 @@ if _is_admin ; then fi ``` -See also [ChatMember](https://core.telegram.org/bots/api/#chatmember) +See also [Chat Member](https://core.telegram.org/bots/api/#chatmember) ##### user_is_allowed Bahsbot supports User Access Control, see [Advanced Usage](4_advanced.md) @@ -488,5 +488,5 @@ Send Input from Telegram to waiting Interactive Chat. #### [Prev Best Practice](5_practice.md) #### [Next Notes for Developers](7_develop.md) -#### $$VERSION$$ v0.70-pre1-1-gbd4a116 +#### $$VERSION$$ v0.70-pre1-2-g293ad08 diff --git a/mycommands.sh b/mycommands.sh index 6c355fe..3bfe217 100644 --- a/mycommands.sh +++ b/mycommands.sh @@ -2,7 +2,7 @@ # files: mycommands.sh.dist # copy to mycommands.sh and add all your commands and functions here ... # -#### $$VERSION$$ v0.70-pre1-0-g490c472 +#### $$VERSION$$ v0.70-pre1-2-g293ad08 # # shellcheck disable=SC2154 # shellcheck disable=SC2034 @@ -16,13 +16,14 @@ # your additional bahsbot commands +# NOTE: command can have @botname attached, you must add * in case tests... mycommands() { case "$MESSAGE" in '/echo'*) # example echo command send_normal_message "${CHAT[ID]}" "$MESSAGE" ;; - '/question') # start interactive questions + '/question'*) # start interactive questions checkproc if [ "$res" -gt 0 ] ; then startproc "example/question" @@ -31,7 +32,7 @@ mycommands() { fi ;; - '/run-notify') # start notify background job + '/run-notify'*) # start notify background job myback="notify"; checkback "$myback" if [ "$res" -gt 0 ] ; then background "example/notify 60" "$myback" # notify every 60 seconds @@ -39,7 +40,7 @@ mycommands() { send_normal_message "${CHAT[ID]}" "Background command $myback already running ..." fi ;; - '/stop-notify') # kill notify background job + '/stop-notify'*) # kill notify background job myback="notify"; checkback "$myback" if [ "$res" -eq 0 ] ; then killback "$myback"