sync with master

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-05-24 16:21:51 +02:00
parent 0f6864f763
commit 6b886562f7
53 changed files with 132 additions and 53 deletions

View File

@ -120,6 +120,29 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
</ul></li>
<li><a href="examples/README.md">Examples</a></li>
</ul>
<h3 id="your-really-first-bashbot-in-a-nutshell">Your really first bashbot in a nutshell</h3>
<p>To install and run bashbot you need acess to a linux/unix/bsd command line. If you dont know how to get accces to a linux/unix/bsd like command line you should stop reading here :-(</p>
<p>In addition you need a <a href="https://telegram.org">Telegram client</a> and a mobile phone to <a href="https://telegramguide.com/create-a-telegram-account/">register an account</a>. If you dont want to register for Telegram you should stop reading here ;-)</p>
<p>After youre registered to Telegram send a message to <span class="citation">[@botfather]</span>(https://telegram.me/botfather), <a href="doc/1_firstbot.md">create a new Telegram Bot token</a> and write it down. You need the token to install the bot.</p>
<p>Now open a linux/unix/bsd terminal and check if bash is installed: <code>which bash &amp;&amp; echo &quot;bash installed!&quot;</code>. If you get an error message bash is not installed.</p>
<p>Create a new directory and change to it: <code>mkdir tbb; cd tbb</code> and download the latest *.tar.gz file from <a href="https://github.com/topkecleon/telegram-bot-bash/releases" class="uri">https://github.com/topkecleon/telegram-bot-bash/releases</a>. This can be done with the commands:</p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="fu">wget</span> -q https://github.com/<span class="va">$(</span><span class="fu">wget</span> -q https://github.com/topkecleon/telegram-bot-bash/releases/latest -O - <span class="kw">|</span> <span class="fu">egrep</span> <span class="st">&#39;/.*/.*/.*tar.gz&#39;</span> -o<span class="va">)</span></code></pre></div>
<p>Extract the *.tar.gz file and change to bashbot directory: <code>tar -xzf *.tar.gz; cd telegram-bot-bash</code>, install bashbot: <code>./bashbot.sh init</code> and enter your bot token when asked. All other questions can be answered by hitting the &lt;Return&gt; key.</p>
<p>Thats all, now you can start your bot with <code>./bashbot.sh start</code> and send him messages:</p>
<pre><code>/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.</code></pre>
<p>For more Information on how to install, customize and use your new bot, read the <a href="#Documentation">Documentation</a></p>
<hr />
<h2 id="security-considerations">Security Considerations</h2>
<p>Running a Telegram Bot means it is connected to the public and you never know whats send to your Bot.</p>
<p>Bash scripts in general are not designed to be bullet proof, so consider this Bot as a proof of concept. Bash programmers often struggle with quoting hell and globbing, see <a href="https://unix.stackexchange.com/questions/171346/security-implications-of-forgetting-to-quote-a-variable-in-bash-posix-shells">Implications of wrong quoting</a></p>
@ -157,6 +180,6 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
<p><span class="citation">@Gnadelwartz</span></p>
<h2 id="thats-it">Thats it!</h2>
<p>If you feel that theres something missing or if you found a bug, feel free to submit a pull request!</p>
<h4 id="version-v0.90-dev-8-gf74e95d"><br /><span class="math display"><em>V</em><em>E</em><em>R</em><em>S</em><em>I</em><em>O</em><em>N</em></span><br /> v0.90-dev-8-gf74e95d</h4>
<h4 id="version-v0.90-dev-18-g0f6864f"><br /><span class="math display"><em>V</em><em>E</em><em>R</em><em>S</em><em>I</em><em>O</em><em>N</em></span><br /> v0.90-dev-18-g0f6864f</h4>
</body>
</html>

View File

@ -162,4 +162,4 @@ This may happen if to many wrong requests are sent to api.telegram.org, e.g. usi
If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
#### $$VERSION$$ v0.90-dev-8-gf74e95d
#### $$VERSION$$ v0.90-dev-18-g0f6864f

View File

@ -72,6 +72,62 @@ all](https://core.telegram.org/bots#3-how-do-i-create-a-bot)
* Customize Bashbot Environment
* [Examples](examples/README.md)
### Your really first bashbot in a nutshell
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'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](https://github.com/to
pkecleon/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)
```
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 \<Return\> 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
@ -177,4 +233,4 @@ tor proxy on your server you may uncomment the ```BASHBOT_CURL_ARGS``` line in
If you feel that there's something missing or if you found a bug, feel free to
submit a pull request!
#### $$VERSION$$ v0.90-dev-8-gf74e95d
#### $$VERSION$$ v0.90-dev-18-g0f6864f

View File

@ -1,7 +1,7 @@
#!/bin/sh
# description: Start or stop telegram-bash-bot
#
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# shellcheck disable=SC2009
# shellcheck disable=SC2181

View File

@ -11,7 +11,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.90-dev-8-gf74e95d
#### $$VERSION$$ v0.90-dev-18-g0f6864f
#
# Exit Codes:
# - 0 sucess (hopefully)

View File

@ -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.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
#
# adjust your language setting here, e.g.when run from other user or cron.

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# this has to run once atfer git clone
# and every time we create new hooks
#### $$VERSION$$ v0.90-dev-5-gb1fb35d
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script

View File

@ -3,7 +3,7 @@
#
# works together with git pre-push.sh and ADD all changed files since last push
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
############
# NOTE: you MUST run install-hooks.sh again when updating this file!

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
############
# NOTE: you MUST run install-hooks.sh again when updating this file!

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# this has to run once atfer git clone
# and every time we create new hooks
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script

View File

@ -2,7 +2,7 @@
# file: make-distribution.sh
# creates files and arcchives to dirtribute bashbot
#
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script

View File

@ -5,7 +5,7 @@
# If you your bot is finished you can use make-standalone.sh to create the
# the old all-in-one bashbot: bashbot.sh and commands.sh only!
#
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script

View File

@ -1,3 +1,3 @@
# list of additional files to check from shellcheck
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
bashbot.rc

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# shellcheck disable=SC2016
#
# Easy Versioning in git:

View File

@ -87,5 +87,5 @@ The old format is supported for backward compatibility, but may fail for corner
#### [Next Create Bot](1_firstbot.md)
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f

View File

@ -65,5 +65,5 @@ group. This step is up to you actually.
#### [Prev Installation](0_install.md)
#### [Next Getting started](2_usage.md)
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f

View File

@ -182,5 +182,5 @@ send_action "${CHAT[ID]}" "action"
#### [Prev Create Bot](1_firstbot.md)
#### [Next Advanced Usage](3_advanced.md)
#### $$VERSION$$ v0.90-dev-3-g80a4778
#### $$VERSION$$ v0.90-dev-18-g0f6864f

View File

@ -180,5 +180,5 @@ See also [answer_inline_multi, answer_inline_compose](6_reference.md#answer_inli
#### [Prev Getting started](2_usage.md)
#### [Next Expert Use](4_expert.md)
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f

View File

@ -104,5 +104,5 @@ An example crontab is provided in ```examples/bashbot.cron```.
#### [Prev Expert Use](4_expert.md)
#### [Next Best Practice](5_practice.md)
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f

View File

@ -153,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.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f

View File

@ -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.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f

View File

@ -188,5 +188,5 @@ fi
#### [Prev Function Reference](6_reference.md)
#### [Next Expert Use](8_custom.md)
#### $$VERSION$$ v0.90-dev-3-g80a4778
#### $$VERSION$$ v0.90-dev-18-g0f6864f

View File

@ -247,5 +247,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms.
#### [Prev Notes for Developers](7_develop.md)
#### $$VERSION$$ v0.90-dev-5-gb1fb35d
#### $$VERSION$$ v0.90-dev-18-g0f6864f

View File

@ -55,6 +55,6 @@ convert existing bots.
**external-use** will contain some examples on how to send messages from external scripts to Telegram chats or users.
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f

View File

@ -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.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -2,7 +2,7 @@
# file: run_filename
# background job to display content of all new files in WATCHDIR
#
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -2,7 +2,7 @@
# file: run_filename
# background job to display all new files in WATCHDIR
#
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# adjust your language setting here
# 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.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -2,7 +2,7 @@
# file. multibot.sh
# description: run multiple telegram bots from one installation
#
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then
echo "Usage: $0 botname command"

View File

@ -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.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
SHELL=/bin/sh

View File

@ -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.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# adjust your language setting here
# 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.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -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.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -1,7 +1,7 @@
# file: botacl
# a user not listed here, will return false from 'user_is_allowed'
#
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# Format:
# user:ressource:chat

View File

@ -5,7 +5,7 @@
# to show how you can customize bashbot by only editing mycommands.sh
# NOTE: this is not tested, simply copied from original source and reworked!
#
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
#
# shellcheck disable=SC2154
# shellcheck disable=SC2034

View File

@ -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.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
#
# source from commands.sh to use the aliases

View File

@ -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.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# source from commands.sh to use the inline functions

View File

@ -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.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# source from commands.sh if you want ro use interactive or background jobs

View File

@ -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.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# source from commands.sh to use the member functions

View File

@ -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.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# source from commands.sh to use the sendMessage functions

View File

@ -2,7 +2,7 @@
# files: mycommands.sh.dist
# copy to mycommands.sh and add all your commands and functions here ...
#
#### $$VERSION$$ v0.90-dev-5-gb1fb35d
#### $$VERSION$$ v0.90-dev-18-g0f6864f
#
# uncomment the following lines to overwrite info and help messages

View File

@ -2,7 +2,7 @@
#
# ADD a new test skeleton to test dir, but does not activate test
#
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.90-dev-8-gf74e95d
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# common variables
export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
../dev/hooks/pre-commit.sh

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# file: b-example-test.sh
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.90-dev-5-gb1fb35d
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.90-dev-0-g75691dc
#### $$VERSION$$ v0.90-dev-18-g0f6864f
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh