From 58cf9017ea5f4bdb18009284f787ba5b187e03ba Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Wed, 22 May 2019 23:22:11 +0200 Subject: [PATCH 1/8] Bashbot Version 0.80 --- doc/6_reference.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/6_reference.md b/doc/6_reference.md index ca88808..79ad072 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -101,6 +101,13 @@ The main use case for send_message is to process the output of interactive chats ##### 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) +Starting with version 0.80 send_file implements the following rules: + +- file names must not contain ".." +- file names must not start with "." +- file names not starting wit "/" are realtive to $TMPDIR, e.g. ./data-bot-bash +- abolute filenames must match $FILE_REGEX + *usage:* send_file "${CHAT[ID]}" "file" "caption" *example:* From 856b831736f17da7415ed5ff8d8a533627f9c9dd Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Fri, 24 May 2019 10:01:47 +0200 Subject: [PATCH 2/8] add json test db for using my-json-server.typicode.com --- db.json | 23 +++++++++++++++++++++++ doc/6_reference.md | 2 +- doc/8_custom.md | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 db.json diff --git a/db.json b/db.json new file mode 100644 index 0000000..ece3b47 --- /dev/null +++ b/db.json @@ -0,0 +1,23 @@ +{ + "false": [ + { + "ok":false, + "error_code":404, + "description":"Not Found" + } + ], + "ok": [ + { + "ok": true, + "description": "test for ok" + } + ], + "getMe": [ + { + "ok": true, + "result": [ + "username": "TestBotBash" + ] + } + ] +} diff --git a/doc/6_reference.md b/doc/6_reference.md index 79ad072..b1ec16d 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -688,5 +688,5 @@ The name of your bot is availible as bash variable "$ME", there is no need to ca #### [Prev Best Practice](5_practice.md) #### [Next Notes for Developers](7_develop.md) -#### $$VERSION$$ v0.80-0-g5bce3f7 +#### $$VERSION$$ v0.80-1-g75691dc diff --git a/doc/8_custom.md b/doc/8_custom.md index e0a3649..53d2af4 100644 --- a/doc/8_custom.md +++ b/doc/8_custom.md @@ -131,5 +131,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms. #### [Prev Notes for Developers](7_develop.md) -#### $$VERSION$$ v0.80-0-g5bce3f7 +#### $$VERSION$$ v0.90-dev-0-g75691dc From abcc410c9acd0ae4a3a5fc5f84074e0d8c97ab76 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Fri, 24 May 2019 10:08:20 +0200 Subject: [PATCH 3/8] add json test db for using my-json-server.typicode.com --- db.json | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/db.json b/db.json index ece3b47..3d11676 100644 --- a/db.json +++ b/db.json @@ -8,16 +8,20 @@ ], "ok": [ { - "ok": true, - "description": "test for ok" + "ok":true, + "description":"Ttest for ok" } ], "getMe": [ { - "ok": true, - "result": [ - "username": "TestBotBash" - ] + "ok":true, + "result": + { + "id":123456789, + "is_bot":true, + "first_name":"bashbot", + "username":"TestBotBash" + } } ] } From 5d57e2bbddce707e81d92f40dc8910db36089c8b Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Fri, 24 May 2019 10:12:50 +0200 Subject: [PATCH 4/8] add json test db for using my-json-server.typicode.com --- db.json | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/db.json b/db.json index 3d11676..12c1d86 100644 --- a/db.json +++ b/db.json @@ -1,18 +1,16 @@ { - "false": [ + "false": { "ok":false, "error_code":404, "description":"Not Found" - } - ], - "ok": [ + } , + "ok": { "ok":true, "description":"Ttest for ok" - } - ], - "getMe": [ + } , + "getMe": { "ok":true, "result": @@ -23,5 +21,5 @@ "username":"TestBotBash" } } - ] + } From 5fa7b2e15ca2fb3c78fb601d4f52b7b9fcd12f88 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Fri, 24 May 2019 10:53:20 +0200 Subject: [PATCH 5/8] add descripting and URL to db.json --- db.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/db.json b/db.json index 12c1d86..a3df871 100644 --- a/db.json +++ b/db.json @@ -1,4 +1,10 @@ { + "usage": + { + "ok":true, + "url":"https://my-json-server.typicode.com/topkecleon/telegram-bot-bash/", + "description":"Testing of JSON reponses for github.com/topkecleon/telegram-bot-bash" + } , "false": { "ok":false, From ad98a6c9088c2758f78e2ccf9624b1ca452b3b74 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Fri, 24 May 2019 14:42:25 +0200 Subject: [PATCH 6/8] bashbot in a nutshell --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/README.md b/README.md index 2aa45d3..57d1f5c 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,46 @@ Bashbot [Documentation](https://github.com/topkecleon/telegram-bot-bash) and [Do * [Customize bashbot environment](doc/8_custom.md) * [Examples](examples/README.md) +### Your really first bashbot in a nutshell +To install an run bashbot you need acess to a linux/unix/bsd etc. command line. All linux/unix/bsd systems has the comamnds to run bashbot installed if bash is availible. If you don't know how to get accces to a linux/unix/bsd like command line you should stop reading here :-( + +In addition you need a [Telegram client](https://telegram.org) and an a mobile phone to [register an account](https://telegramguide.com/create-a-telegram-account/). +If you don't want to install and register for Telegram you should stop reading here ;-) + +After you are registered to telegram open a chat with [@botfather](https://telegram.me/botfather) to +[create a new Telegram Bot token](doc/1_firstbot.md). Write down the bot token you get from botfather, you need it while installing the bot. + +Now open the linux/unix/bsd command line and check if bash is installed by running ```which bash && echo "bash installed!"```. +If you get an error message conatct you system administrator to install bash. + +Create a new, empty drirectory and change to it, e.g. ```mkdir tbb; cd tbb```, and download the '*.tar.gz' file from the lastest bashbot release from +```https://github.com/topkecleon/telegram-bot-bash/releases``` an copy it to the new directory. This can be done with the following command: +```bash +wget -q https://github.com/$(wget -q https://github.com/topkecleon/telegram-bot-bash/releases/latest -O - | egrep '/.*/.*/.*tar.gz' -o) +``` + +To install bashbot extract thew archive an change to bashbot directory by running ```tar -xzf *.tar.gz; cd telegram-bot-bash```, +install bashbot with the command ```./bashbot.sh init``` and enter your bot token when asked. All other questions can be answered +by hitting the key. + +Thats all, now you can start your bot with ```./bashbot.sh start``` and send him messages: +``` +/start + +You are Botadmin +*Available commands*: +*• /start*: _Start bot and get this message_. +*• /help*: _Get this message_. +*• /info*: _Get shorter info message about this bot_.... + +/info + +his is bashbot, the Telegram bot written entirely in bash. +It features background tasks and interactive chats, and can serve as an interface for CLI programs. +``` +For more Information on how to install, customize and use your new bot, read the [Documentation](Documentation) + +---- ## Security Considerations Running a Telegram Bot means it is connected to the public and you never know whats send to your Bot. From 52968207531d78836a2f9dbe2b16436a443ba68c Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Fri, 24 May 2019 14:55:05 +0200 Subject: [PATCH 7/8] fix bashbot in a nutshell --- README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 57d1f5c..79d374b 100644 --- a/README.md +++ b/README.md @@ -59,26 +59,26 @@ Bashbot [Documentation](https://github.com/topkecleon/telegram-bot-bash) and [Do * [Examples](examples/README.md) ### Your really first bashbot in a nutshell -To install an run bashbot you need acess to a linux/unix/bsd etc. command line. All linux/unix/bsd systems has the comamnds to run bashbot installed if bash is availible. If you don't know how to get accces to a linux/unix/bsd like command line you should stop reading here :-( +To install an run bashbot you need acess to a linux/unix/bsd command line. If you don't know how to get accces to a linux/unix/bsd like command line you should stop reading here :-( -In addition you need a [Telegram client](https://telegram.org) and an a mobile phone to [register an account](https://telegramguide.com/create-a-telegram-account/). -If you don't want to install and register for Telegram you should stop reading here ;-) +In addition you need a [Telegram client](https://telegram.org) and a mobile phone to [register an account](https://telegramguide.com/create-a-telegram-account/). +If you don't want to register for Telegram you should stop reading here ;-) -After you are registered to telegram open a chat with [@botfather](https://telegram.me/botfather) to -[create a new Telegram Bot token](doc/1_firstbot.md). Write down the bot token you get from botfather, you need it while installing the bot. +After you are registered to Telegram send a message to [@botfather](https://telegram.me/botfather) to +[create a new Telegram Bot token](doc/1_firstbot.md) and write it down. You need it later to install the bot. -Now open the linux/unix/bsd command line and check if bash is installed by running ```which bash && echo "bash installed!"```. -If you get an error message conatct you system administrator to install bash. +Now open a linux/unix/bsd terminal and check if bash is installed: ```which bash && echo "bash installed!"```. +If you get an error message bash is not installed. -Create a new, empty drirectory and change to it, e.g. ```mkdir tbb; cd tbb```, and download the '*.tar.gz' file from the lastest bashbot release from -```https://github.com/topkecleon/telegram-bot-bash/releases``` an copy it to the new directory. This can be done with the following command: +Create a new directory and change to it: ```mkdir tbb; cd tbb``` and download the latest '*.tar.gz' file from +```https://github.com/topkecleon/telegram-bot-bash/releases```. This can be done with the commands: ```bash wget -q https://github.com/$(wget -q https://github.com/topkecleon/telegram-bot-bash/releases/latest -O - | egrep '/.*/.*/.*tar.gz' -o) ``` -To install bashbot extract thew archive an change to bashbot directory by running ```tar -xzf *.tar.gz; cd telegram-bot-bash```, -install bashbot with the command ```./bashbot.sh init``` and enter your bot token when asked. All other questions can be answered -by hitting the key. +Extract the '*.tar.gz' file and change to bashbot directory: ```tar -xzf *.tar.gz; cd telegram-bot-bash```, +install bashbot: ```./bashbot.sh init``` and enter your bot token when asked. All other questions can be answered +by hitting the \ key. Thats all, now you can start your bot with ```./bashbot.sh start``` and send him messages: ``` @@ -95,7 +95,7 @@ You are Botadmin his is bashbot, the Telegram bot written entirely in bash. It features background tasks and interactive chats, and can serve as an interface for CLI programs. ``` -For more Information on how to install, customize and use your new bot, read the [Documentation](Documentation) +For more Information on how to install, customize and use your new bot, read the [Documentation](#Documentation) ---- @@ -149,4 +149,4 @@ Hey no Problem, if you are finished with your cool bot run ```dev/make-standalon If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.80-0-g5bce3f7 +#### $$VERSION$$ v0.80-6-g5fa7b2e From 83892b7924d1ae6dafe91d3fc3528e25b8f9d60c Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Fri, 24 May 2019 15:01:44 +0200 Subject: [PATCH 8/8] bashbot in a nutshell --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 79d374b..379638f 100644 --- a/README.md +++ b/README.md @@ -59,19 +59,19 @@ Bashbot [Documentation](https://github.com/topkecleon/telegram-bot-bash) and [Do * [Examples](examples/README.md) ### Your really first bashbot in a nutshell -To install an run bashbot you need acess to a linux/unix/bsd command line. If you don't know how to get accces to a linux/unix/bsd like command line you should stop reading here :-( +To install and run bashbot you need acess to a linux/unix/bsd command line. If you don't know how to get accces to a linux/unix/bsd like command line you should stop reading here :-( In addition you need a [Telegram client](https://telegram.org) and a mobile phone to [register an account](https://telegramguide.com/create-a-telegram-account/). If you don't want to register for Telegram you should stop reading here ;-) -After you are registered to Telegram send a message to [@botfather](https://telegram.me/botfather) to -[create a new Telegram Bot token](doc/1_firstbot.md) and write it down. You need it later to install the bot. +After you're registered to Telegram send a message to [@botfather](https://telegram.me/botfather), +[create a new Telegram Bot token](doc/1_firstbot.md) and write it down. You need the token to install the bot. Now open a linux/unix/bsd terminal and check if bash is installed: ```which bash && echo "bash installed!"```. If you get an error message bash is not installed. Create a new directory and change to it: ```mkdir tbb; cd tbb``` and download the latest '*.tar.gz' file from -```https://github.com/topkecleon/telegram-bot-bash/releases```. This can be done with the commands: +[https://github.com/topkecleon/telegram-bot-bash/releases](https://github.com/topkecleon/telegram-bot-bash/releases). This can be done with the commands: ```bash wget -q https://github.com/$(wget -q https://github.com/topkecleon/telegram-bot-bash/releases/latest -O - | egrep '/.*/.*/.*tar.gz' -o) ``` @@ -149,4 +149,4 @@ Hey no Problem, if you are finished with your cool bot run ```dev/make-standalon If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.80-6-g5fa7b2e +#### $$VERSION$$ v0.80-7-gad98a6c