mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-21 15:15:09 +00:00
startup: factor out bot_cleanup
This commit is contained in:
parent
fdb2b3ac7b
commit
50777ceff7
397
README.html
397
README.html
@ -1,397 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="generator" content="pandoc" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
||||
<title>Bashbot README</title>
|
||||
<style>
|
||||
html {
|
||||
line-height: 1.5;
|
||||
font-family: Georgia, serif;
|
||||
font-size: 20px;
|
||||
color: #1a1a1a;
|
||||
background-color: #fdfdfd;
|
||||
}
|
||||
body {
|
||||
margin: 0 auto;
|
||||
max-width: 36em;
|
||||
padding-left: 50px;
|
||||
padding-right: 50px;
|
||||
padding-top: 50px;
|
||||
padding-bottom: 50px;
|
||||
hyphens: auto;
|
||||
word-wrap: break-word;
|
||||
text-rendering: optimizeLegibility;
|
||||
font-kerning: normal;
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
body {
|
||||
font-size: 0.9em;
|
||||
padding: 1em;
|
||||
}
|
||||
}
|
||||
@media print {
|
||||
body {
|
||||
background-color: transparent;
|
||||
color: black;
|
||||
font-size: 12pt;
|
||||
}
|
||||
p, h2, h3 {
|
||||
orphans: 3;
|
||||
widows: 3;
|
||||
}
|
||||
h2, h3, h4 {
|
||||
page-break-after: avoid;
|
||||
}
|
||||
}
|
||||
p {
|
||||
margin: 1em 0;
|
||||
}
|
||||
a {
|
||||
color: #1a1a1a;
|
||||
}
|
||||
a:visited {
|
||||
color: #1a1a1a;
|
||||
}
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
margin-top: 1.4em;
|
||||
}
|
||||
h5, h6 {
|
||||
font-size: 1em;
|
||||
font-style: italic;
|
||||
}
|
||||
h6 {
|
||||
font-weight: normal;
|
||||
}
|
||||
ol, ul {
|
||||
padding-left: 1.7em;
|
||||
margin-top: 1em;
|
||||
}
|
||||
li > ol, li > ul {
|
||||
margin-top: 0;
|
||||
}
|
||||
blockquote {
|
||||
margin: 1em 0 1em 1.7em;
|
||||
padding-left: 1em;
|
||||
border-left: 2px solid #e6e6e6;
|
||||
color: #606060;
|
||||
}
|
||||
code {
|
||||
font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
|
||||
font-size: 85%;
|
||||
margin: 0;
|
||||
}
|
||||
pre {
|
||||
margin: 1em 0;
|
||||
overflow: auto;
|
||||
}
|
||||
pre code {
|
||||
padding: 0;
|
||||
overflow: visible;
|
||||
}
|
||||
.sourceCode {
|
||||
background-color: transparent;
|
||||
overflow: visible;
|
||||
}
|
||||
hr {
|
||||
background-color: #1a1a1a;
|
||||
border: none;
|
||||
height: 1px;
|
||||
margin: 1em 0;
|
||||
}
|
||||
table {
|
||||
margin: 1em 0;
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
display: block;
|
||||
font-variant-numeric: lining-nums tabular-nums;
|
||||
}
|
||||
table caption {
|
||||
margin-bottom: 0.75em;
|
||||
}
|
||||
tbody {
|
||||
margin-top: 0.5em;
|
||||
border-top: 1px solid #1a1a1a;
|
||||
border-bottom: 1px solid #1a1a1a;
|
||||
}
|
||||
th {
|
||||
border-top: 1px solid #1a1a1a;
|
||||
padding: 0.25em 0.5em 0.25em 0.5em;
|
||||
}
|
||||
td {
|
||||
padding: 0.125em 0.5em 0.25em 0.5em;
|
||||
}
|
||||
header {
|
||||
margin-bottom: 4em;
|
||||
text-align: center;
|
||||
}
|
||||
#TOC li {
|
||||
list-style: none;
|
||||
}
|
||||
#TOC a:not(:hover) {
|
||||
text-decoration: none;
|
||||
}
|
||||
code{white-space: pre-wrap;}
|
||||
span.smallcaps{font-variant: small-caps;}
|
||||
span.underline{text-decoration: underline;}
|
||||
div.column{display: inline-block; vertical-align: top; width: 50%;}
|
||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
||||
ul.task-list{list-style: none;}
|
||||
pre > code.sourceCode { white-space: pre; position: relative; }
|
||||
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
|
||||
pre > code.sourceCode > span:empty { height: 1.2em; }
|
||||
code.sourceCode > span { color: inherit; text-decoration: inherit; }
|
||||
div.sourceCode { margin: 1em 0; }
|
||||
pre.sourceCode { margin: 0; }
|
||||
@media screen {
|
||||
div.sourceCode { overflow: auto; }
|
||||
}
|
||||
@media print {
|
||||
pre > code.sourceCode { white-space: pre-wrap; }
|
||||
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
|
||||
}
|
||||
pre.numberSource code
|
||||
{ counter-reset: source-line 0; }
|
||||
pre.numberSource code > span
|
||||
{ position: relative; left: -4em; counter-increment: source-line; }
|
||||
pre.numberSource code > span > a:first-child::before
|
||||
{ content: counter(source-line);
|
||||
position: relative; left: -1em; text-align: right; vertical-align: baseline;
|
||||
border: none; display: inline-block;
|
||||
-webkit-touch-callout: none; -webkit-user-select: none;
|
||||
-khtml-user-select: none; -moz-user-select: none;
|
||||
-ms-user-select: none; user-select: none;
|
||||
padding: 0 4px; width: 4em;
|
||||
color: #aaaaaa;
|
||||
}
|
||||
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
|
||||
div.sourceCode
|
||||
{ }
|
||||
@media screen {
|
||||
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
|
||||
}
|
||||
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
|
||||
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
|
||||
code span.at { color: #7d9029; } /* Attribute */
|
||||
code span.bn { color: #40a070; } /* BaseN */
|
||||
code span.bu { } /* BuiltIn */
|
||||
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
|
||||
code span.ch { color: #4070a0; } /* Char */
|
||||
code span.cn { color: #880000; } /* Constant */
|
||||
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
|
||||
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
|
||||
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
|
||||
code span.dt { color: #902000; } /* DataType */
|
||||
code span.dv { color: #40a070; } /* DecVal */
|
||||
code span.er { color: #ff0000; font-weight: bold; } /* Error */
|
||||
code span.ex { } /* Extension */
|
||||
code span.fl { color: #40a070; } /* Float */
|
||||
code span.fu { color: #06287e; } /* Function */
|
||||
code span.im { } /* Import */
|
||||
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
|
||||
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
|
||||
code span.op { color: #666666; } /* Operator */
|
||||
code span.ot { color: #007020; } /* Other */
|
||||
code span.pp { color: #bc7a00; } /* Preprocessor */
|
||||
code span.sc { color: #4070a0; } /* SpecialChar */
|
||||
code span.ss { color: #bb6688; } /* SpecialString */
|
||||
code span.st { color: #4070a0; } /* String */
|
||||
code span.va { color: #19177c; } /* Variable */
|
||||
code span.vs { color: #4070a0; } /* VerbatimString */
|
||||
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
|
||||
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
|
||||
</style>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<header id="title-block-header">
|
||||
<h1 class="title">Bashbot README</h1>
|
||||
</header>
|
||||
<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>
|
||||
Written by Drew (@topkecleon) and Kay M (@gnadelwartz).
|
||||
|
||||
<p>Contributions by Daniil Gentili (@danog), JuanPotato, BigNerd95, TiagoDanin, iicc1 and dcoomber.</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>
|
||||
<p>Linted by <a href="https://github.com/koalaman/shellcheck">#ShellCheck</a></p>
|
||||
<h2>Prerequisites</h2>
|
||||
<p>Uses <a href="http://github.com/dominictarr/JSON.sh">JSON.sh</a>/<a href="https://github.com/step-/JSON.awk">JSON.awk</a> and the magic of sed.</p>
|
||||
<p>Bashbot is written in bash. It depends on commands typically available in a Linux/Unix Environment. For more information on commands provided by recent versions of <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><strong>Note for MacOS and BSD Users:</strong> Bashbot will not run without installing additional software as it uses modern bash and (gnu) grep/sed features. See <a href="doc/0_install.md">Install Bashbot</a>.</p>
|
||||
<p><strong>Note for embedded systems:</strong> You need to install a "real" bash as the vanilla installation of busybox or toybox is not sufficient. See <a href="doc/0_install.md">Install Bashbot</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 available on <a href="https://www.github.com">www.github.com</a>.</p>
|
||||
<h2>Documentation</h2>
|
||||
<ul>
|
||||
<li><a href="https://core.telegram.org/bots">Introduction to Telegram Bots</a></li>
|
||||
<li><a href="doc/0_install.md">Install Bashbot</a>
|
||||
<ul>
|
||||
<li>Install release</li>
|
||||
<li>Install from github</li>
|
||||
<li>Update Bashbot</li>
|
||||
<li>Notes on Updates</li>
|
||||
</ul></li>
|
||||
<li><a href="doc/1_firstbot.md">Get Bottoken from Botfather</a></li>
|
||||
<li><a href="doc/2_usage.md">Getting Started</a>
|
||||
<ul>
|
||||
<li>Managing your Bot</li>
|
||||
<li>Receive 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>
|
||||
<li>Send message errors</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>Schedule bashbot from Cron</li>
|
||||
<li>Use from CLI and Scripts</li>
|
||||
<li>Customize Bashbot Environment</li>
|
||||
</ul></li>
|
||||
<li><a href="doc/5_practice.md">Best Practices</a>
|
||||
<ul>
|
||||
<li>Customize mycommands.sh</li>
|
||||
<li>Overwrite/disable commands</li>
|
||||
<li>Separate 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>jsshDB Bashbot key-value storage</li>
|
||||
<li>Background and Interactive Jobs</li>
|
||||
</ul></li>
|
||||
<li><a href="doc/7_develop.md">Developer Notes</a>
|
||||
<ul>
|
||||
<li>Debug bashbot</li>
|
||||
<li>Modules, addons, events</li>
|
||||
<li>Setup your environment</li>
|
||||
<li>Bashbot test suite</li>
|
||||
</ul></li>
|
||||
<li><a href="examples">Examples Directory</a></li>
|
||||
<li><a href="examples/webhook">Webhook Example</a></li>
|
||||
</ul>
|
||||
<h3>Your very first bashbot in a nutshell</h3>
|
||||
<p>To install and run bashbot you need access to a Linux/Unix command line with bash, a <a href="https://telegram.org">Telegram client</a> and a mobile phone <a href="https://telegramguide.com/create-a-telegram-account/">with a Telegram account</a>.</p>
|
||||
<p>First you need to <a href="doc/1_firstbot.md">create a new Telegram Bot token</a> for your bot and write it down.</p>
|
||||
<p>Now open a Linux/Unix terminal with bash, create a new directory, change to it and install telegram-bot-bash:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># create bot dir</span></span>
|
||||
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">mkdir</span> mybot</span>
|
||||
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="bu">cd</span> mybot</span>
|
||||
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="co"># download latest release with wget or from https://github.com/topkecleon/telegram-bot-bash/releases/latest</span></span>
|
||||
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="fu">wget</span> <span class="st">"https://github.com/</span><span class="va">$(</span><span class="fu">wget</span> <span class="at">-q</span> <span class="st">"https://github.com/topkecleon/telegram-bot-bash/releases/latest"</span> <span class="at">-O</span> <span class="at">-</span> <span class="kw">|</span> <span class="fu">egrep</span> <span class="st">'/.*/download/.*/.*tar.gz'</span> <span class="at">-o</span><span class="va">)</span><span class="st">"</span></span>
|
||||
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="co"># Extract the tar archive and go into bot dir</span></span>
|
||||
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a><span class="fu">tar</span> <span class="at">-xzf</span> <span class="pp">*</span>.tar.gz</span>
|
||||
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="bu">cd</span> telegram-bot-bash</span>
|
||||
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a><span class="co"># initialize your bot</span></span>
|
||||
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a><span class="co"># Enter your bot token when asked, all other questions can be answered by hitting the \<Return\> key.</span></span>
|
||||
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a><span class="ex">./bashbot.sh</span> init</span>
|
||||
<span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true" tabindex="-1"></a><span class="co"># Now start your bot</span></span>
|
||||
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true" tabindex="-1"></a><span class="ex">./bashbot.sh</span> start</span>
|
||||
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb1-19"><a href="#cb1-19" aria-hidden="true" tabindex="-1"></a><span class="ex">Bottoken</span> is valid ...</span>
|
||||
<span id="cb1-20"><a href="#cb1-20" aria-hidden="true" tabindex="-1"></a><span class="ex">Bot</span> Name: yourbotname_bot</span>
|
||||
<span id="cb1-21"><a href="#cb1-21" aria-hidden="true" tabindex="-1"></a><span class="ex">Session</span> Name: yourbotname_bot-startbot</span>
|
||||
<span id="cb1-22"><a href="#cb1-22" aria-hidden="true" tabindex="-1"></a><span class="ex">Bot</span> started successfully.</span></code></pre></div>
|
||||
<p>Now open the Telegram App on your mobile phone and start a chat with your bot (<em>your bot's username is shown after 'Bot Name:'</em>):</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
|
||||
|
||||
This 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>
|
||||
<h3>Log files</h3>
|
||||
<p>Bashbot actions are logged to <code>BASHBOT.log</code>. Telegram send/receive errors are logged to <code>ERROR.log</code>. Start bashbot in debug mode to see all messages sent to / received from Telegram, as well as bash command error messages.</p>
|
||||
<p>To enable debug mode, start bashbot with debug as third argument: <code>bashbot start debug</code></p>
|
||||
<pre><code>|__ logs
|
||||
| |__ BASHBOT.log # log what your bot is doing ...
|
||||
| |__ ERROR.log # connection errors from / to Telegram API
|
||||
| |
|
||||
| |__ DEBUG.log # stdout/stderr of you bot (debug mode enabled)
|
||||
| |__ MESSAGE.log # full text of all message send/received (debug mode enabled)</code></pre>
|
||||
<hr />
|
||||
<h2>Security Considerations</h2>
|
||||
<p>Running a Telegram Bot means it is connected to the public and you never know what's send to your Bot.</p>
|
||||
<p>Bash scripts in general are not designed to be bulletproof, 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 untrusted sources (messages, files, network) you must be as careful as possible (e.g. set IFS appropriately, disable globbing with <code>set -f</code> and quote everything). In addition remove unused scripts and examples from your Bot (e.g. everything in <code>example/</code>) and disable/remove all unused bot commands.</p>
|
||||
<p>It's important to escape or remove <code>$</code> and ` in input from user, files or network (<em>as bashbot does</em>). One of the powerful features of Unix shells is variable and command substitution using <code>${var}</code>, <code>$(cmd)</code> and `cmd` can lead to remote code execution (RCE) or remote information disclosure (RID) bugs if unescaped <code>$</code> or ` is included in untrusted input (e.g. <code>$$</code> or <code>$(rm -rf /*)</code>).</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 extensively in bashbot development to ensure 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>Use printf whenever possible</h3>
|
||||
<p>If you're writing a script that accepts external input (e.g. from the user as arguments or the file system), you shouldn't use echo to display it. <a href="https://unix.stackexchange.com/a/6581">Use printf whenever possible</a>.</p>
|
||||
<h3>Run your Bot as a restricted user</h3>
|
||||
<p><strong>I recommend running your bot as a user with almost no access rights.</strong> All files your Bot has write access to are in danger of being overwritten/deleted if your bot is hacked. For the same reason every file your Bot can read is in danger of being disclosed. Restrict your Bots access rights 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 Linux/Unix systems. See <a href="doc/4_expert.md">Expert use</a> on how to run your Bot as an other user.</p>
|
||||
<h3>Secure your Bot installation</h3>
|
||||
<p><strong>Your Bot configuration must not be readable by other users.</strong> Everyone who can read your Bots token is able to act as your Bot and has access to all chats the Bot is in!</p>
|
||||
<p>Everyone with read access to your Bot files can extract your Bots data. Especially your Bot config in <code>config.jssh</code> must be protected against other users. No one except you should have write access to the Bot files. The Bot should be restricted to have write access to <code>count.jssh</code>, <code>data-bot-bash/</code> and <code>logs/</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>
|
||||
<p><em>Note</em>: Keep old log files in a safe place or even better delete them, they are GDPR relevant and <a href="https://github.com/topkecleon/telegram-bot-bash/issues/174">may contain information</a> you don't want to be public.</p>
|
||||
<h2>FAQ</h2>
|
||||
<h3>Is this Bot insecure?</h3>
|
||||
<p>Bashbot is not more (in)secure than a Bot written in another 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>
|
||||
<p><strong>Note:</strong> Up to version 0.941 (mai/22/2020) telegram-bot-bash had a remote code execution bug, please update if you use an older version!</p>
|
||||
<h3>Why Bash and not the much better xyz?</h3>
|
||||
<p>Well, that's a damn good question... maybe because I'm a Unix admin from the stone age. Nevertheless there are more reasons from my side:</p>
|
||||
<ul>
|
||||
<li>bashbot will run wherever bash and (gnu) sed is available, from embedded Linux to mainframe</li>
|
||||
<li>easy to integrate with other shell scripts, 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 object oriented ...</li>
|
||||
</ul>
|
||||
<h3>Can I have the single bashbot.sh file back?</h3>
|
||||
<p>At the beginning bashbot was simply the file <code>bashbot.sh</code> that you could 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>
|
||||
<h3>Can I send messages from CLI and scripts?</h3>
|
||||
<p>Of course you can send messages from command line and scripts! Simply install bashbot as <a href="#Your-really-first-bashbot-in-a-nutshell">described here</a>, send the message '/start' to set yourself as botadmin and then stop the bot with <code>./bashbot.sh stop</code>.</p>
|
||||
<p>Bashbot provides some ready to use scripts for sending messages from command line in <code>bin/</code> dir, e.g. <code>send_message.sh</code>.</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">bin/send_message.sh</span> BOTADMIN <span class="st">"This is my first message send from CLI"</span></span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="ex">bin/send_message.sh</span> <span class="at">--help</span></span></code></pre></div>
|
||||
<p>You can also source bashbot for use in your scripts, for more information see <a href="doc/4_expert.md">Expert Use</a>.</p>
|
||||
<h3>Blocked by telegram?</h3>
|
||||
<p>This may happen if too many or wrong requests are sent to api.telegram.org, e.g. using a invalid token or invalid API calls. If the block stay for longer time you can ask telegram service to unblock your IP-Address.</p>
|
||||
<p>You can check with curl or wget if you are blocked by Telegram:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-m</span> 10 https://api.telegram.org/bot</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="co">#curl: (28) Connection timed out after 10001 milliseconds</span></span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="fu">wget</span> <span class="at">-t</span> 1 <span class="at">-T</span> 10 https://api.telegram.org/bot</span>
|
||||
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="co">#Connecting to api.telegram.org (api.telegram.org)|46.38.243.234|:443... failed: Connection timed out.</span></span>
|
||||
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a><span class="ex">nc</span> <span class="at">-w</span> 2 api.telegram.org 443 <span class="kw">||</span> <span class="bu">echo</span> <span class="st">"your IP seems blocked by telegram"</span></span>
|
||||
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a><span class="co">#your IP seems blocked by telegram</span></span></code></pre></div>
|
||||
<p>Bashbot offers the option to recover from broken connections (blocked). Therefore you can provide a function named <code>bashbotBlockRecover()</code> in <code>mycommands.sh</code>, the function is called every time when a broken connection is detected.</p>
|
||||
<p>Possible actions are: Check if network is working, change IP-Address or simply wait some time. See <code>mycommnds.sh.dist</code> for an example.</p>
|
||||
<hr />
|
||||
<p>@Gnadelwartz</p>
|
||||
<h2>That's it all guys!</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>$$VERSION$$ v1.45-dev-37-gfdbfceb</h4>
|
||||
</body>
|
||||
</html>
|
@ -242,4 +242,4 @@ See `mycommnds.sh.dist` for an example.
|
||||
|
||||
If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
|
||||
|
||||
#### $$VERSION$$ v1.45-dev-37-gfdbfceb
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
301
README.txt
301
README.txt
@ -20,304 +20,3 @@
|
||||
******ooo*.............*
|
||||
***o*........**
|
||||
**...**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Bashbot README
|
||||
|
||||
|
||||
Bashbot - A Telegram bot written in bash.
|
||||
|
||||
Written by Drew (@topkecleon) and Kay M (@gnadelwartz).
|
||||
Contributions by Daniil Gentili (@danog), JuanPotato, BigNerd95, TiagoDanin, iicc1 and
|
||||
dcoomber.
|
||||
Released to the public domain wherever applicable. Elsewhere, consider it released under
|
||||
the WTFPLv2 [http://www.wtfpl.net/txt/copying/].
|
||||
Linted by #ShellCheck
|
||||
|
||||
Prerequisites
|
||||
|
||||
Uses JSON.sh [http://github.com/dominictarr/JSON.sh]/JSON.awk [https://github.com/step-/
|
||||
JSON.awk] and the magic of sed.
|
||||
Bashbot is written in bash. It depends on commands typically available in a Linux/Unix
|
||||
Environment. For more information on commands provided by recent versions of coreutils
|
||||
[https://en.wikipedia.org/wiki/List_of_GNU_Core_Utilities_commands], busybox [https://
|
||||
en.wikipedia.org/wiki/BusyBox#Commands] or toybox [https://landley.net/toybox/help.html],
|
||||
see Developer Notes [doc/7_develop.md#common-commands].
|
||||
Note for MacOS and BSD Users: Bashbot will not run without installing additional software
|
||||
as it uses modern bash and (gnu) grep/sed features. See Install Bashbot [doc/
|
||||
0_install.md].
|
||||
Note for embedded systems: You need to install a "real" bash as the vanilla installation
|
||||
of busybox or toybox is not sufficient. See Install Bashbot [doc/0_install.md].
|
||||
Bashbot Documentation [https://github.com/topkecleon/telegram-bot-bash] and Downloads
|
||||
[https://github.com/topkecleon/telegram-bot-bash/releases] are available on www.github.com
|
||||
[https://www.github.com].
|
||||
|
||||
Documentation
|
||||
|
||||
|
||||
* Introduction to Telegram Bots [https://core.telegram.org/bots]
|
||||
* Install Bashbot [doc/0_install.md]
|
||||
|
||||
o Install release
|
||||
o Install from github
|
||||
o Update Bashbot
|
||||
o Notes on Updates
|
||||
|
||||
* Get Bottoken from Botfather [doc/1_firstbot.md]
|
||||
* Getting Started [doc/2_usage.md]
|
||||
|
||||
o Managing your Bot
|
||||
o Receive data
|
||||
o Send messages
|
||||
o Send files, locations, keyboards
|
||||
|
||||
* Advanced Features [doc/3_advanced.md]
|
||||
|
||||
o Access Control
|
||||
o Interactive Chats
|
||||
o Background Jobs
|
||||
o Inline queries
|
||||
o Send message errors
|
||||
|
||||
* Expert Use [doc/4_expert.md]
|
||||
|
||||
o Handling UTF-8 character sets
|
||||
o Run as other user or system service
|
||||
o Schedule bashbot from Cron
|
||||
o Use from CLI and Scripts
|
||||
o Customize Bashbot Environment
|
||||
|
||||
* Best Practices [doc/5_practice.md]
|
||||
|
||||
o Customize mycommands.sh
|
||||
o Overwrite/disable commands
|
||||
o Separate logic from commands
|
||||
o Test your Bot with shellcheck
|
||||
|
||||
* Function Reference [doc/6_reference.md]
|
||||
|
||||
o Sending Messages, Files, Keyboards
|
||||
o User Access Control
|
||||
o Inline Queries
|
||||
o jsshDB Bashbot key-value storage
|
||||
o Background and Interactive Jobs
|
||||
|
||||
* Developer Notes [doc/7_develop.md]
|
||||
|
||||
o Debug bashbot
|
||||
o Modules, addons, events
|
||||
o Setup your environment
|
||||
o Bashbot test suite
|
||||
|
||||
* Examples Directory [examples]
|
||||
* Webhook Example [examples/webhook]
|
||||
|
||||
|
||||
Your very first bashbot in a nutshell
|
||||
|
||||
To install and run bashbot you need access to a Linux/Unix command line with bash, a
|
||||
Telegram client [https://telegram.org] and a mobile phone with a Telegram account [https:/
|
||||
/telegramguide.com/create-a-telegram-account/].
|
||||
First you need to create a new Telegram Bot token [doc/1_firstbot.md] for your bot and
|
||||
write it down.
|
||||
Now open a Linux/Unix terminal with bash, create a new directory, change to it and install
|
||||
telegram-bot-bash:
|
||||
|
||||
# create bot dir
|
||||
mkdir mybot
|
||||
cd mybot
|
||||
|
||||
# download latest release with wget or from https://github.com/topkecleon/telegram-bot-
|
||||
bash/releases/latest
|
||||
wget "https://github.com/$(wget -q "https://github.com/topkecleon/telegram-
|
||||
bot-bash/releases/latest" -O - | egrep '/.*/download/.*/.*tar.gz' -o)"
|
||||
|
||||
# Extract the tar archive and go into bot dir
|
||||
tar -xzf *.tar.gz
|
||||
cd telegram-bot-bash
|
||||
|
||||
# initialize your bot
|
||||
# Enter your bot token when asked, all other questions can be answered by hitting the
|
||||
\<Return\> key.
|
||||
./bashbot.sh init
|
||||
|
||||
# Now start your bot
|
||||
./bashbot.sh start
|
||||
|
||||
Bottoken is valid ...
|
||||
Bot Name: yourbotname_bot
|
||||
Session Name: yourbotname_bot-startbot
|
||||
Bot started successfully.
|
||||
|
||||
Now open the Telegram App on your mobile phone and start a chat with your bot (your bot's
|
||||
username is shown after 'Bot Name:'):
|
||||
|
||||
/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
|
||||
|
||||
This 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].
|
||||
|
||||
Log files
|
||||
|
||||
Bashbot actions are logged to BASHBOT.log. Telegram send/receive errors are logged to
|
||||
ERROR.log. Start bashbot in debug mode to see all messages sent to / received from
|
||||
Telegram, as well as bash command error messages.
|
||||
To enable debug mode, start bashbot with debug as third argument: bashbot start debug
|
||||
|
||||
|__ logs
|
||||
| |__ BASHBOT.log # log what your bot is doing ...
|
||||
| |__ ERROR.log # connection errors from / to Telegram API
|
||||
| |
|
||||
| |__ DEBUG.log # stdout/stderr of you bot (debug mode enabled)
|
||||
| |__ MESSAGE.log # full text of all message send/received (debug mode enabled)
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
Security Considerations
|
||||
|
||||
Running a Telegram Bot means it is connected to the public and you never know what's send
|
||||
to your Bot.
|
||||
Bash scripts in general are not designed to be bulletproof, so consider this Bot as a
|
||||
proof of concept. Bash programmers often struggle with 'quoting hell' and globbing, see
|
||||
Implications of wrong quoting [https://unix.stackexchange.com/questions/171346/security-
|
||||
implications-of-forgetting-to-quote-a-variable-in-bash-posix-shells].
|
||||
Whenever you are processing input from untrusted sources (messages, files, network) you
|
||||
must be as careful as possible (e.g. set IFS appropriately, disable globbing with set -
|
||||
f and quote everything). In addition remove unused scripts and examples from your Bot
|
||||
(e.g. everything in example/) and disable/remove all unused bot commands.
|
||||
It's important to escape or remove $ and ` in input from user, files or network (as
|
||||
bashbot does). One of the powerful features of Unix shells is variable and command
|
||||
substitution using ${var}, $(cmd) and `cmd` can lead to remote code execution (RCE) or
|
||||
remote information disclosure (RID) bugs if unescaped $ or ` is included in untrusted
|
||||
input (e.g. $$ or $(rm -rf /*)).
|
||||
A powerful tool to improve your scripts is shellcheck. You can use it online [https://
|
||||
www.shellcheck.net/] or install shellcheck locally [https://github.com/koalaman/
|
||||
shellcheck#installing]. Shellcheck is used extensively in bashbot development to ensure a
|
||||
high code quality (e.g. it's not allowed to push changes without passing all shellcheck
|
||||
tests). In addition bashbot has a test suite [doc/7_develop.md] to check if important
|
||||
functionality is working as expected.
|
||||
|
||||
Use printf whenever possible
|
||||
|
||||
If you're writing a script that accepts external input (e.g. from the user as arguments or
|
||||
the file system), you shouldn't use echo to display it. Use printf whenever possible
|
||||
[https://unix.stackexchange.com/a/6581].
|
||||
|
||||
Run your Bot as a restricted user
|
||||
|
||||
I recommend running your bot as a user with almost no access rights. All files your Bot
|
||||
has write access to are in danger of being overwritten/deleted if your bot is hacked. For
|
||||
the same reason every file your Bot can read is in danger of being disclosed. Restrict
|
||||
your Bots access rights to the absolute minimum.
|
||||
Never run your Bot as root, this is the most dangerous you can do! Usually the user
|
||||
'nobody' has almost no rights on Linux/Unix systems. See Expert use [doc/4_expert.md] on
|
||||
how to run your Bot as an other user.
|
||||
|
||||
Secure your Bot installation
|
||||
|
||||
Your Bot configuration must not be readable by other users. Everyone who can read your
|
||||
Bots token is able to act as your Bot and has access to all chats the Bot is in!
|
||||
Everyone with read access to your Bot files can extract your Bots data. Especially your
|
||||
Bot config in config.jssh must be protected against other users. No one except you should
|
||||
have write access to the Bot files. The Bot should be restricted to have write access to
|
||||
count.jssh, data-bot-bash/ and logs/ only, all other files must be write protected.
|
||||
To set access rights for your bashbot installation to a reasonable default run sudo ./
|
||||
bashbot.sh init after every update or change to your installation directory.
|
||||
Note: Keep old log files in a safe place or even better delete them, they are GDPR
|
||||
relevant and may contain information [https://github.com/topkecleon/telegram-bot-bash/
|
||||
issues/174] you don't want to be public.
|
||||
|
||||
FAQ
|
||||
|
||||
|
||||
Is this Bot insecure?
|
||||
|
||||
Bashbot is not more (in)secure than a Bot written in another 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 ...
|
||||
Note: Up to version 0.941 (mai/22/2020) telegram-bot-bash had a remote code execution bug,
|
||||
please update if you use an older version!
|
||||
|
||||
Why Bash and not the much better xyz?
|
||||
|
||||
Well, that's a damn good question... maybe because I'm a Unix admin from the stone age.
|
||||
Nevertheless there are more reasons from my side:
|
||||
|
||||
* bashbot will run wherever bash and (gnu) sed is available, from embedded Linux to
|
||||
mainframe
|
||||
* easy to integrate with other shell scripts, e.g. for sending system message / health
|
||||
status
|
||||
* no need to install or learn a new programming language, library or framework
|
||||
* no database, not event driven, not object oriented ...
|
||||
|
||||
|
||||
Can I have the single bashbot.sh file back?
|
||||
|
||||
At the beginning bashbot was simply the file bashbot.sh that you could copy everywhere and
|
||||
run the bot. Now we have 'commands.sh', 'mycommands.sh', 'modules/*.sh' and much more.
|
||||
Hey no problem, if you are finished with your cool bot, run dev/make-standalone.sh to
|
||||
create a stripped down version of your bot containing only 'bashbot.sh' and 'commands.sh'!
|
||||
For more information see Create a stripped down version of your Bot [doc/7_develop.md].
|
||||
|
||||
Can I send messages from CLI and scripts?
|
||||
|
||||
Of course you can send messages from command line and scripts! Simply install bashbot as
|
||||
described here [#Your-really-first-bashbot-in-a-nutshell], send the message '/start' to
|
||||
set yourself as botadmin and then stop the bot with ./bashbot.sh stop.
|
||||
Bashbot provides some ready to use scripts for sending messages from command line in bin/
|
||||
dir, e.g. send_message.sh.
|
||||
|
||||
bin/send_message.sh BOTADMIN "This is my first message send from CLI"
|
||||
|
||||
bin/send_message.sh --help
|
||||
|
||||
You can also source bashbot for use in your scripts, for more information see Expert Use
|
||||
[doc/4_expert.md].
|
||||
|
||||
Blocked by telegram?
|
||||
|
||||
This may happen if too many or wrong requests are sent to api.telegram.org, e.g. using a
|
||||
invalid token or invalid API calls. If the block stay for longer time you can ask telegram
|
||||
service to unblock your IP-Address.
|
||||
You can check with curl or wget if you are blocked by Telegram:
|
||||
|
||||
curl -m 10 https://api.telegram.org/bot
|
||||
#curl: (28) Connection timed out after 10001 milliseconds
|
||||
|
||||
wget -t 1 -T 10 https://api.telegram.org/bot
|
||||
#Connecting to api.telegram.org (api.telegram.org)|46.38.243.234|:443... failed:
|
||||
Connection timed out.
|
||||
|
||||
nc -w 2 api.telegram.org 443 || echo "your IP seems blocked by telegram"
|
||||
#your IP seems blocked by telegram
|
||||
|
||||
Bashbot offers the option to recover from broken connections (blocked). Therefore you can
|
||||
provide a function named bashbotBlockRecover() in mycommands.sh, the function is called
|
||||
every time when a broken connection is detected.
|
||||
Possible actions are: Check if network is working, change IP-Address or simply wait some
|
||||
time. See mycommnds.sh.dist for an example.
|
||||
------------------------------------------------------------------------------------------
|
||||
@Gnadelwartz
|
||||
|
||||
That's it all guys!
|
||||
|
||||
If you feel that there's something missing or if you found a bug, feel free to submit a
|
||||
pull request!
|
||||
|
||||
$$VERSION$$ v1.45-dev-37-gfdbfceb
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
# this addon counts how many files, e.g. stickers, are sent to
|
||||
# a chat and takes actions if threshold is reached
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
# used events:
|
||||
#
|
||||
|
@ -4,7 +4,7 @@
|
||||
# Addons can register to bashbot events at startup
|
||||
# by providing their name and a callback per event
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#
|
||||
# If an event occurs each registered event function is called.
|
||||
#
|
||||
|
@ -5,7 +5,7 @@
|
||||
#
|
||||
# tested on: ubuntu, opensuse, debian
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-74-g0a296ea
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
# shellcheck disable=SC2009
|
||||
# shellcheck disable=SC2181
|
||||
# shellcheck disable=SC2250
|
||||
|
12
bashbot.sh
12
bashbot.sh
@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb
|
||||
# 8 - curl/wget missing
|
||||
# 10 - not bash!
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-73-geb0c227
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
##################################################################
|
||||
|
||||
# are we running in a terminal?
|
||||
@ -747,6 +747,16 @@ event_send() {
|
||||
done
|
||||
}
|
||||
|
||||
# cleanup activities on startup, called from startbot and resume background jobs
|
||||
# $1 action, timestamp for action is saved in config
|
||||
bot_cleanup() {
|
||||
# cleanup countfile on startup
|
||||
jssh_deleteKeyDB "CLEAN_COUNTER_DATABASE_ON_STARTUP" "${COUNTFILE}"
|
||||
[ -f "${COUNTFILE}.jssh.flock" ] && rm -f "${COUNTFILE}.jssh.flock"
|
||||
# store action time and cleanup botconfig on startup
|
||||
[ -n "$1" ] && jssh_updateKeyDB "$1" "$(_date)" "${BOTCONFIG}"
|
||||
[ -f "${BOTCONFIG}.jssh.flock" ] && rm -f "${BOTCONFIG}.jssh.flock"
|
||||
}
|
||||
|
||||
# fallback version, full version is in bin/bashbot_init.in.sh
|
||||
# initialize bot environment, user and permissions
|
||||
|
@ -21,7 +21,7 @@ USAGE='any_command.sh [-h|--help] [--force|--reference] bot_command args ...'
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 30.01.2021 10:24
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
|
@ -13,7 +13,7 @@
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 18.12.2020 12:27
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
############
|
||||
|
@ -11,7 +11,7 @@
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 27.01.2021 13:42
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
# shellcheck disable=SC2059
|
||||
|
||||
|
@ -17,7 +17,7 @@ USAGE='bashbot_stats.sh [-h|--help] [debug]'
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 23.12.2020 20:34
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
# set bashbot environment
|
||||
|
@ -20,7 +20,7 @@ USAGE='delete_message.sh [-h|--help] "CHAT[ID]" "MESSAGE[ID]" [debug]'
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 03.01.2021 15:37
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
|
@ -26,7 +26,7 @@ USAGE='send_message.sh [-h|--help] "CHAT[ID]" "MESSAGE[ID]" "text|url" ...'
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 21.01.2021 08:10
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
|
@ -23,7 +23,7 @@ USAGE='send_edit_message.sh [-h|--help] [format|caption] "CHAT[ID]" "MESSAGE[ID]
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 23.12.2020 16:52
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
|
@ -20,7 +20,7 @@ USAGE='kickban_user.sh [-h|--help] [-u|--unban] "CHAT[ID]" "USER[ID]" [debug]'
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 25.01.2021 20:34
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
|
@ -21,7 +21,7 @@ USAGE='process_update.sh [-h|--help] [-s|--startbot] [-w|--watch] [-n|--lines n]
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 27.02.2021 13:14
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-72-g7500ca0
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
|
@ -15,7 +15,7 @@ USAGE='process_update.sh [-h|--help] [debug] [<file]'
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 30.01.2021 19:14
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
|
@ -25,7 +25,7 @@ USAGE='promote_user.sh [-h|--help] "CHAT[ID]" "USER[ID]" "right[:true|false]" ..
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 25.01.2021 22:34
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
|
@ -28,7 +28,7 @@ USAGE='broadcast_message.sh [-h|--help] [--doit] [--groups|--both|--db=file] [fo
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 16.12.2020 16:14
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
|
@ -26,7 +26,7 @@ USAGE='send_message.sh [-h|--help] "CHAT[ID]" "message" "text|url" ...'
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 18.01.2021 11:34
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
|
@ -21,7 +21,7 @@ USAGE='send_dice.sh [-h|--help] "CHAT[ID]" "emoji" [debug]'
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 07.02.2021 18:45
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
|
@ -25,7 +25,7 @@ USAGE='send_file.sh [-h|--help] "CHAT[ID]" "file|URL" "caption ...." [type] [deb
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 25.12.2020 20:24
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
|
@ -22,7 +22,7 @@ USAGE='send_message.sh [-h|--help] [format] "CHAT[ID]" "message ...." [debug]'
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
# CREATED: 16.12.2020 11:34
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
####
|
||||
|
@ -15,7 +15,7 @@
|
||||
# This file is public domain in the USA and all free countries.
|
||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-49-g2131911
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#
|
||||
|
||||
# bashbot locale defaults to c.UTF-8, adjust locale in mycommands.sh if needed
|
||||
|
@ -5,7 +5,7 @@
|
||||
#
|
||||
# Description: run all tests, exit after failed test
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-34-gb1e6e0f
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#############################################################
|
||||
|
||||
#shellcheck disable=SC1090
|
||||
|
@ -5,7 +5,7 @@
|
||||
#
|
||||
# Description: common stuff for all dev scripts
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#############################################################
|
||||
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
# works together with git pre-push.sh and ADD all changed files since last push
|
||||
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
#shellcheck disable=SC1090
|
||||
source "${0%/*}/dev.inc.sh"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
############
|
||||
# NOTE: you MUST run install-hooks.sh again when updating this file!
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
############
|
||||
# NOTE: you MUST run install-hooks.sh again when updating this file!
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
############
|
||||
# NOTE: you MUST run install-hooks.sh again when updating this file!
|
||||
|
@ -7,7 +7,7 @@
|
||||
#
|
||||
# Usage: source inject-json.sh
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
##############################################################
|
||||
|
||||
# download JSON.sh
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# this has to run once atfer git clone
|
||||
# and every time we create new hooks
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
#shellcheck disable=SC1090
|
||||
source "${0%/*}/dev.inc.sh"
|
||||
|
@ -7,7 +7,7 @@
|
||||
#
|
||||
# Options: --notest - skip tests
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
##############################################################
|
||||
|
||||
#shellcheck disable=SC1090
|
||||
|
@ -7,7 +7,7 @@
|
||||
#
|
||||
# Usage: source make-hmtl
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
##############################################################
|
||||
|
||||
# check for correct dir
|
||||
|
@ -11,7 +11,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$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
###################################################################
|
||||
|
||||
#shellcheck disable=SC1090
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# joke hack to obfuscate bashbot.min.sh
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
# shellcheck disable=SC2028,SC2016,SC1117
|
||||
|
||||
infile="bashbot.sh"
|
||||
|
@ -1,5 +1,5 @@
|
||||
# list of additional files to check from shellcheck
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
bashbot.rc
|
||||
mycommands.conf
|
||||
mycommands.sh.clean
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
# shellcheck disable=SC2016
|
||||
#
|
||||
# Easy Versioning in git:
|
||||
|
@ -132,5 +132,5 @@ You must update to [Version 1.20](https://github.com/topkecleon/telegram-bot-bas
|
||||
|
||||
#### [Next Create Bot](1_firstbot.md)
|
||||
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
|
@ -65,5 +65,5 @@ group. This step is up to you actually.
|
||||
#### [Prev Installation](0_install.md)
|
||||
#### [Next Getting started](2_usage.md)
|
||||
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
|
@ -377,5 +377,5 @@ send_action "${CHAT[ID]}" "action"
|
||||
#### [Prev Create Bot](1_firstbot.md)
|
||||
#### [Next Advanced Usage](3_advanced.md)
|
||||
|
||||
#### $$VERSION$$ v1.45-dev-17-ga7d85e3
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
|
@ -302,5 +302,5 @@ Note: If you disable automatic retry, se above, you disable also connection prob
|
||||
#### [Prev Getting started](2_usage.md)
|
||||
#### [Next Expert Use](4_expert.md)
|
||||
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
|
@ -434,5 +434,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms.
|
||||
#### [Prev Advanced Use](3_advanced.md)
|
||||
#### [Next Best Practice](5_practice.md)
|
||||
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
|
@ -160,5 +160,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$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
|
@ -1673,5 +1673,5 @@ The name of your bot is available as bash variable "$ME", there is no need to ca
|
||||
#### [Prev Best Practice](5_practice.md)
|
||||
#### [Next Notes for Developers](7_develop.md)
|
||||
|
||||
#### $$VERSION$$ v1.45-dev-43-gac71000
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
|
@ -387,5 +387,5 @@ fi
|
||||
|
||||
#### [Prev Function Reference](6_reference.md)
|
||||
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
|
@ -60,6 +60,6 @@ plus use of keyboards in private chats. It's an extended version of mycommands.s
|
||||
|
||||
**Webhook** contains instructions on how use webhook API to get updates from telegram instead polling Telegram server.
|
||||
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
|
||||
|
@ -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$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
######
|
||||
# parameters
|
||||
|
@ -2,7 +2,7 @@
|
||||
# file: run_filename
|
||||
# background job to display content of all new files in WATCHDIR
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
######
|
||||
# parameters
|
||||
|
@ -2,7 +2,7 @@
|
||||
# file: run_filename
|
||||
# background job to display all new files in WATCHDIR
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
######
|
||||
# parameters
|
||||
|
@ -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$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
######
|
||||
# parameters
|
||||
|
@ -6,7 +6,7 @@
|
||||
# This file is public domain in the USA and all free countries.
|
||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||
# shellcheck disable=SC1117
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
# adjust your language setting here
|
||||
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
|
||||
|
@ -2,7 +2,7 @@
|
||||
# file. multibot.sh
|
||||
# description: run multiple telegram bots from one installation
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
if [ "$2" = "" ] || [ "$2" = "-h" ]; then
|
||||
echo "Usage: $0 botname command"
|
||||
|
@ -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$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
|
||||
SHELL=/bin/sh
|
||||
|
@ -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$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
########################################################################
|
||||
|
||||
######
|
||||
|
@ -10,7 +10,7 @@
|
||||
# AUTHOR: KayM (), kay@rrr.de
|
||||
# DATE: 19.12.2020 19:03
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
# shellcheck disable=SC2154
|
||||
# shellcheck disable=SC2034
|
||||
|
@ -13,7 +13,7 @@
|
||||
# This file is public domain in the USA and all free countries.
|
||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
########################################################################
|
||||
|
||||
######
|
||||
|
@ -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$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
########################################################################
|
||||
|
||||
######
|
||||
|
@ -1,7 +1,7 @@
|
||||
# file: botacl
|
||||
# a user not listed here, will return false from 'user_is_allowed'
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
# Format:
|
||||
# user:resource:chat
|
||||
|
||||
|
@ -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$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#
|
||||
# shellcheck disable=SC2154
|
||||
# shellcheck disable=SC2034
|
||||
|
@ -98,5 +98,5 @@ webhook updates only over secure TLS connections with a valid SSL certificate ch
|
||||
`socat` looks like a tool to listen for Telegram updates from bash scripts, let's see ...
|
||||
|
||||
|
||||
#### $$VERSION$$ v1.45-dev-66-gec90ce8
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
* @license http://www.wtfpl.net/txt/copying/ WTFPLv2
|
||||
* @since 30.01.2021 20:24
|
||||
*
|
||||
#### $$VERSION$$ v1.45-dev-51-gf7842f4
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
***********************************************************/
|
||||
|
||||
// bashbot home dir
|
||||
|
@ -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$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#
|
||||
# will be automatically sourced from bashbot
|
||||
|
||||
|
@ -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$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
# will be automatically sourced from bashbot
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||
#
|
||||
# shellcheck disable=SC1117,SC2059
|
||||
#### $$VERSION$$ v1.45-dev-69-gb454827
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
# will be automatically sourced from bashbot
|
||||
|
||||
@ -124,13 +124,15 @@ inproc() {
|
||||
send_interactive "${CHAT[ID]}" "${MESSAGE[0]}"
|
||||
}
|
||||
|
||||
# start stop all jobs
|
||||
# start stop all jobs
|
||||
# $1 command # kill suspend resume restart
|
||||
job_control() {
|
||||
local BOT ADM content proc CHAT job fifo killall=""
|
||||
BOT="$(getConfigKey "botname")"
|
||||
ADM="${BOTADMIN}"
|
||||
debug_checks "Enter job_control" "$1"
|
||||
# cleanup on start
|
||||
[[ "$1" == "re"* ]] && bot_cleanup "startback"
|
||||
for FILE in "${DATADIR:-.}/"*-back.cmd; do
|
||||
[ "${FILE}" = "${DATADIR:-.}/*-back.cmd" ] && printf "${RED}No background processes.${NN}" && break
|
||||
content="$(< "${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$$ v1.45-dev-71-gac16103
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
# will be automatically sourced from bashbot
|
||||
|
||||
|
@ -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$$ v1.45-dev-41-g192fae8
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#
|
||||
# source from commands.sh to use jsonDB functions
|
||||
#
|
||||
|
@ -4,7 +4,7 @@
|
||||
# File: processUpdates.sh
|
||||
# Note: DO NOT EDIT! this file will be overwritten on update
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-73-geb0c227
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
##################################################################
|
||||
|
||||
##############
|
||||
@ -288,7 +288,7 @@ process_message() {
|
||||
}
|
||||
|
||||
#########################
|
||||
# main get updates loop, should never terminate
|
||||
# bot startup actions, call before start polling or webhook loop
|
||||
declare -A BASHBOTBLOCKED
|
||||
start_bot() {
|
||||
local DEBUGMSG
|
||||
@ -318,21 +318,15 @@ start_bot() {
|
||||
# shellcheck disable=SC2064
|
||||
trap "kill -9 $!; exit" EXIT INT HUP TERM QUIT
|
||||
fi
|
||||
# cleanup countfile on startup
|
||||
jssh_deleteKeyDB "CLEAN_COUNTER_DATABASE_ON_STARTUP" "${COUNTFILE}"
|
||||
[ -f "${COUNTFILE}.jssh.flock" ] && rm -f "${COUNTFILE}.jssh.flock"
|
||||
# store start time and cleanup botconfig on startup
|
||||
jssh_updateKeyDB "startup" "$(_date)" "${BOTCONFIG}"
|
||||
[ -f "${BOTCONFIG}.jssh.flock" ] && rm -f "${BOTCONFIG}.jssh.flock"
|
||||
# cleanup on start
|
||||
bot_cleanup "startup"
|
||||
# read blocked users
|
||||
jssh_readDB_async "BASHBOTBLOCKED" "${BLOCKEDFILE}"
|
||||
# inform botadmin about start
|
||||
send_normal_message "$(getConfigKey "botadmin")" "Bot ${ME} $2 started ..." &
|
||||
##########
|
||||
# bot is ready, start processing updates ...
|
||||
}
|
||||
|
||||
|
||||
# main polling updates loop, should never terminate
|
||||
get_updates(){
|
||||
local errsleep="200" DEBUG="$1" OFFSET=0
|
||||
# adaptive sleep defaults
|
||||
|
@ -6,7 +6,7 @@
|
||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||
#
|
||||
# shellcheck disable=SC1117
|
||||
#### $$VERSION$$ v1.45-dev-35-g473d802
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
# will be automatically sourced from bashbot
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
# Author: KayM (gnadelwartz), kay@rrr.de
|
||||
# Created: 09.01.2021 07:27
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#######################################################
|
||||
|
||||
##########
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||
# Author: KayM (gnadelwartz), kay@rrr.de
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-70-gb78431e
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#######################################################
|
||||
# shellcheck disable=SC1117
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
# License: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||
# Author: KayM (gnadelwartz), kay@rrr.de
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#######################################################
|
||||
# shellcheck disable=SC1117
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
# This file is public domain in the USA and all free countries.
|
||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
########################################################################
|
||||
|
||||
######
|
||||
|
@ -10,7 +10,7 @@
|
||||
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
# magic to ensure that we're always inside the root of our application,
|
||||
|
@ -11,7 +11,7 @@
|
||||
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-21-ge67e43d
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
# common variables
|
||||
|
@ -10,7 +10,7 @@
|
||||
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
../dev/hooks/pre-commit.sh
|
||||
|
@ -10,7 +10,7 @@
|
||||
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
# include common functions and definitions
|
||||
|
@ -10,7 +10,7 @@
|
||||
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
# include common functions and definitions
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
|
||||
# include common functions and definitions
|
||||
# shellcheck source=test/ALL-tests.inc.sh
|
||||
|
@ -10,7 +10,7 @@
|
||||
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
# include common functions and definitions
|
||||
|
@ -10,7 +10,7 @@
|
||||
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-22-g6b07242
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
# include common functions and definitions
|
||||
|
@ -10,7 +10,7 @@
|
||||
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-34-gb1e6e0f
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
# include common functions and definitions
|
||||
|
@ -10,7 +10,7 @@
|
||||
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
#
|
||||
#### $$VERSION$$ v1.45-dev-71-gac16103
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
# include common functions and definitions
|
||||
|
@ -10,7 +10,7 @@
|
||||
# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/
|
||||
# AUTHOR: KayM (gnadelwartz), kay@rrr.de
|
||||
#
|
||||
#### $$VERSION$$ v1.40-0-gf9dab50
|
||||
#### $$VERSION$$ v1.45-dev-75-gfdb2b3a
|
||||
#===============================================================================
|
||||
|
||||
# include common functions and definitions
|
||||
|
Loading…
Reference in New Issue
Block a user