mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-16 13:05:09 +00:00
114 lines
8.3 KiB
HTML
114 lines
8.3 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
<meta http-equiv="Content-Style-Type" content="text/css" />
|
||
<meta name="generator" content="pandoc" />
|
||
<title>Bashbot README</title>
|
||
<style type="text/css">code{white-space: pre;}</style>
|
||
</head>
|
||
<body>
|
||
<div id="header">
|
||
<h1 class="title">Bashbot README</h1>
|
||
</div>
|
||
<h2>
|
||
<img align="middle" src="https://raw.githubusercontent.com/odb/official-bash-logo/master/assets/Logos/Icons/PNG/64x64.png" > Bashbot - A Telegram bot written in bash.
|
||
</h2>
|
||
<p>Written by Drew (<span class="citation">@topkecleon</span>), Daniil Gentili (<span class="citation">@danogentili</span>), and Kay M (<span class="citation">@gnadelwartz</span>).</p>
|
||
<p>Contributions by JuanPotato, BigNerd95, TiagoDanin, and iicc1.</p>
|
||
<p>Released to the public domain wherever applicable. Elsewhere, consider it released under the <a href="http://www.wtfpl.net/txt/copying/">WTFPLv2</a>.</p>
|
||
<h2 id="prerequisites">Prerequisites</h2>
|
||
<p>Uses <a href="http://github.com/dominictarr/JSON.sh">JSON.sh</a>, but no more TMUX.</p>
|
||
<p>Even bashbot is written in bash, it depends on commands typically availible in a Unix/Linux Environment. More concret on the common commands provided by <a href="https://en.wikipedia.org/wiki/List_of_GNU_Core_Utilities_commands">coreutils</a>, <a href="https://en.wikipedia.org/wiki/BusyBox#Commands">busybox</a> or <a href="https://landley.net/toybox/help.html">toybox</a>, see <a href="doc/7_develop.md#common-commands">Developer Notes</a></p>
|
||
<p>Bashbot <a href="https://github.com/topkecleon/telegram-bot-bash">Documentation</a> and <a href="https://github.com/topkecleon/telegram-bot-bash/releases">Downloads</a> are availible on www.github.com</p>
|
||
<h2 id="documentation">Documentation</h2>
|
||
<ul>
|
||
<li><a href="https://core.telegram.org/bots">Introdution to Telegram Bots</a>
|
||
<ul>
|
||
<li><a href="https://core.telegram.org/bots#3-how-do-i-create-a-bot">One Bot to rule them all</a></li>
|
||
<li><a href="https://core.telegram.org/bots#commands">Bot commands</a></li>
|
||
</ul></li>
|
||
<li><a href="doc/0_install.md">Install Bashbot</a>
|
||
<ul>
|
||
<li>Install release</li>
|
||
<li>Install from githup</li>
|
||
<li>Update Bashbot</li>
|
||
<li>Notes on Updates</li>
|
||
</ul></li>
|
||
<li><a href="doc/1_firstbot.md">Create a new Telegram Bot with botfather</a></li>
|
||
<li><a href="doc/2_usage.md">Getting Started</a>
|
||
<ul>
|
||
<li>Managing your Bot</li>
|
||
<li>Recieve data</li>
|
||
<li>Send messages</li>
|
||
<li>Send files, locations, keyboards</li>
|
||
</ul></li>
|
||
<li><a href="doc/3_advanced.md">Advanced Features</a>
|
||
<ul>
|
||
<li>Access Control</li>
|
||
<li>Interactive Chats</li>
|
||
<li>Background Jobs</li>
|
||
<li>Inline queries</li>
|
||
</ul></li>
|
||
<li><a href="doc/4_expert.md">Expert Use</a>
|
||
<ul>
|
||
<li>Handling UTF-8 character sets</li>
|
||
<li>Run as other user or system service</li>
|
||
<li>Scedule bashbot from Cron</li>
|
||
</ul></li>
|
||
<li><a href="doc/5_practice.md">Best Practices</a>
|
||
<ul>
|
||
<li>Customize commands.sh</li>
|
||
<li>Seperate logic from commands</li>
|
||
<li>Test your Bot with shellcheck</li>
|
||
</ul></li>
|
||
<li><a href="doc/6_reference.md">Function Reference</a>
|
||
<ul>
|
||
<li>Sending Messages, Files, Keyboards</li>
|
||
<li>User Access Control</li>
|
||
<li>Inline Queries</li>
|
||
<li>Background and Interactive Jobs</li>
|
||
</ul></li>
|
||
<li><a href="doc/7_develop.md">Deveoper Notess</a>
|
||
<ul>
|
||
<li>Setup your environment</li>
|
||
<li>Test, Add, Push changes</li>
|
||
<li>Prepare a new version</li>
|
||
<li>Bashbot testsuite</li>
|
||
</ul></li>
|
||
<li><a href="doc/8_custom.md">Customize bashbot environment</a></li>
|
||
<li><a href="examples/README.md">Examples</a></li>
|
||
</ul>
|
||
<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>
|
||
<p>Whenever you are processing input from from untrusted sources (messages, files, network) you must be as carefull as possible, e.g. set IFS appropriate, disable globbing (set -f) and quote everthing. In addition delete unused scripts and examples from your Bot, e.g. scripts ‘notify’, ‘calc’, ‘question’, and disable all not used commands.</p>
|
||
<p>A powerful tool to improve your scripts is <code>shellcheck</code>. You can <a href="https://www.shellcheck.net/">use it online</a> or <a href="https://github.com/koalaman/shellcheck#installing">install shellcheck locally</a>. Shellcheck is used extensive in bashbot development to enshure a high code quality, e.g. it’s not allowed to push changes without passing all shellcheck tests. In addition bashbot has a <a href="doc/7_develop.md">test suite</a> to check if important functionality is working as expected.</p>
|
||
<h3 id="run-your-bot-as-a-restricted-user">Run your Bot as a restricted user</h3>
|
||
<p><strong>I recommend to run your bot as a user, with almost no access rights.</strong> All files your Bot have write access to are in danger to be overwritten/deleted if your bot is hacked. For the same reason ervery file your Bot can read is in danger to be disclosed. Restict your Bots access rigths to the absolute minimum.</p>
|
||
<p><strong>Never run your Bot as root, this is the most dangerous you can do!</strong> Usually the user ‘nobody’ has almost no rights on Unix/Linux systems. See <a href="doc/4_expert.md">Expert use</a> on how to run your Bot as an other user.</p>
|
||
<h3 id="secure-your-bot-installation">Secure your Bot installation</h3>
|
||
<p><strong>Your Bot configuration must no be readable from other users.</strong> Everyone who can read your Bots token can act as your Bot and has access to all chats your Bot is in!</p>
|
||
<p>Everyone with read access to your Bot files can extract your Bots data. Especially your Bot Token in <code>token</code> must be protected against other users. No one exept you must have write access to the Bot files. The Bot must be restricted to have write access to <code>count</code> and <code>tmp-bot-bash</code> only, all other files must be write protected.</p>
|
||
<p>To set access rights for your bashbot installation to a reasonable default run <code>sudo ./bashbot.sh init</code> after every update or change to your installation directory.</p>
|
||
<h2 id="faq">FAQ</h2>
|
||
<h3 id="is-this-bot-insecure">Is this Bot insecure?</h3>
|
||
<p>Bashbot is not more (in)secure as any other Bot written in any other language, we have done our best to make it as secure as possible. But YOU are responsible for the bot commands you wrote and you should know about the risks …</p>
|
||
<h3 id="why-bash-and-not-the-much-better-xyz">Why Bash and not the much better xyz?</h3>
|
||
<p>Well, thats a damn good question … may be because I’m an Unix/Linux admin from stone age. Nevertheless there are more reasons from my side:</p>
|
||
<ul>
|
||
<li>bashbot will run everywhere where bash is availible, from ebedded linux to mainframe</li>
|
||
<li>easy to integrate with other shell script, e.g. for sending system message / health status</li>
|
||
<li>no need to install or learn a new programming language, library or framework</li>
|
||
<li>no database, not event driven, not OO …</li>
|
||
</ul>
|
||
<h3 id="can-i-have-the-single-bashbot.sh-file-back">Can I have the single bashbot.sh file back?</h3>
|
||
<p>At the beginning bashbot was simply the file <code>bashbot.sh</code> you can copy everywhere and run the bot. Now we have ‘commands.sh’, ‘mycommands.sh’, ’modules/*.sh’ and much more.</p>
|
||
<p>Hey no Problem, if you are finished with your cool bot run <code>dev/make-standalone.sh</code> to create a stripped down Version of your bot containing only ‘bashbot.sh’ and ‘commands.sh’! For more information see <a href="doc/7_develop.md">Create a stripped down Version of your Bot</a></p>
|
||
<p><span class="citation">@Gnadelwartz</span></p>
|
||
<h2 id="thats-it">That’s it!</h2>
|
||
<p>If you feel that there’s something missing or if you found a bug, feel free to submit a pull request!</p>
|
||
<h4 id="version-v80-rc1-0-gb096ea3"><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 /> v80-rc1-0-gb096ea3</h4>
|
||
</body>
|
||
</html>
|