dev: preservere links for README.txt

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-01-08 15:52:07 +01:00
parent f0a2843f2a
commit 1eafc91452
4 changed files with 46 additions and 37 deletions

View File

@ -390,6 +390,6 @@ It features background tasks and interactive chats, and can serve as an interfac
<p>@Gnadelwartz</p> <p>@Gnadelwartz</p>
<h2>That's it all guys!</h2> <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> <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.25-dev-33-g04e3c18</h4> <h4>$$VERSION$$ v1.25-dev-37-gf0a2843</h4>
</body> </body>
</html> </html>

View File

@ -238,4 +238,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! If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
#### $$VERSION$$ v1.25-dev-33-g04e3c18 #### $$VERSION$$ v1.25-dev-37-gf0a2843

View File

@ -12,41 +12,44 @@ Written by Drew (@topkecleon) and Kay M (@gnadelwartz).
Contributions by Daniil Gentili (@danog), JuanPotato, BigNerd95, TiagoDanin, iicc1 and Contributions by Daniil Gentili (@danog), JuanPotato, BigNerd95, TiagoDanin, iicc1 and
dcoomber. dcoomber.
Released to the public domain wherever applicable. Elsewhere, consider it released under Released to the public domain wherever applicable. Elsewhere, consider it released under
the WTFPLv2. the WTFPLv2 [http://www.wtfpl.net/txt/copying/].
Linted by #ShellCheck Linted by #ShellCheck
Prerequisites Prerequisites
Uses JSON.sh and the magic of sed. Uses JSON.sh [http://github.com/dominictarr/JSON.sh] and the magic of sed.
Bashbot is written in bash. It depends on commands typically available in a Linux/Unix Bashbot is written in bash. It depends on commands typically available in a Linux/Unix
Environment. For more concrete information on the common commands provided by recent Environment. For more concrete information on the common commands provided by recent
versions of coreutils, busybox or toybox, see Developer_Notes. versions of coreutils [https://en.wikipedia.org/wiki/List_of_GNU_Core_Utilities_commands],
busybox or toybox, see Developer_Notes.
Note for MacOS and BSD Users: Bashbot will not run without installing additional software 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. 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 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. of busybox or toybox is not sufficient. See Install Bashbot [doc/0_install.md].
Bashbot Documentation and Downloads are available on www.github.com. Bashbot Documentation [https://github.com/topkecleon/telegram-bot-bash] and Downloads are
available on www.github.com.
Documentation Documentation
* Introduction_to_Telegram_Bots * Introduction to Telegram Bots [https://core.telegram.org/bots]
* Install_Bashbot * Install Bashbot [doc/0_install.md]
o Install release o Install release
o Install from github o Install from github
o Update Bashbot o Update Bashbot
o Notes on Updates o Notes on Updates
* Get_Bottoken_from_Botfather * Get Bottoken from Botfather [doc/1_firstbot.md]
* Getting_Started * Getting Started [doc/2_usage.md]
o Managing your Bot o Managing your Bot
o Receive data o Receive data
o Send messages o Send messages
o Send files, locations, keyboards o Send files, locations, keyboards
* Advanced_Features * Advanced Features [doc/3_advanced.md]
o Access Control o Access Control
o Interactive Chats o Interactive Chats
@ -54,7 +57,7 @@ Documentation
o Inline queries o Inline queries
o Send message errors o Send message errors
* Expert_Use * Expert Use [doc/4_expert.md]
o Handling UTF-8 character sets o Handling UTF-8 character sets
o Run as other user or system service o Run as other user or system service
@ -62,14 +65,14 @@ Documentation
o Use from CLI and Scripts o Use from CLI and Scripts
o Customize Bashbot Environment o Customize Bashbot Environment
* Best_Practices * Best Practices [doc/5_practice.md]
o Customize mycommands.sh o Customize mycommands.sh
o Overwrite/disable commands o Overwrite/disable commands
o Separate logic from commands o Separate logic from commands
o Test your Bot with shellcheck o Test your Bot with shellcheck
* Function_Reference * Function Reference [doc/6_reference.md]
o Sending Messages, Files, Keyboards o Sending Messages, Files, Keyboards
o User Access Control o User Access Control
@ -77,21 +80,22 @@ Documentation
o jsshDB Bashbot key-value storage o jsshDB Bashbot key-value storage
o Background and Interactive Jobs o Background and Interactive Jobs
* Developer_Notes * Developer Notes [doc/7_develop.md]
o Debug bashbot o Debug bashbot
o Modules, addons, events o Modules, addons, events
o Setup your environment o Setup your environment
o Bashbot test suite o Bashbot test suite
* Examples_Directory * Examples Directory [examples/README.md]
Your very first bashbot in a nutshell Your very first bashbot in a nutshell
To install and run bashbot you need access to a Linux/Unix command line with bash, a To install and run bashbot you need access to a Linux/Unix command line with bash, a
Telegram_client and a mobile phone with_a_Telegram_account. Telegram client [https://telegram.org] and a mobile phone with_a_Telegram_account.
First you need to create_a_new_Telegram_Bot_token for your bot and write it down. 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 Now open a Linux/Unix terminal with bash, create a new directory, change to it and install
telegram-bot-bash: telegram-bot-bash:
@ -139,7 +143,7 @@ username is shown after 'Bot Name:'):
CLI programs. CLI programs.
For more Information on how to install, customize and use your new bot, read the For more Information on how to install, customize and use your new bot, read the
Documentation. Documentation [#Documentation].
Log files Log files
@ -163,7 +167,8 @@ Running a Telegram Bot means it is connected to the public and you never know wh
to your Bot. to your Bot.
Bash scripts in general are not designed to be bulletproof, so consider this Bot as a 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 proof of concept. Bash programmers often struggle with 'quoting hell' and globbing, see
Implications_of_wrong_quoting. 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 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 - 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 f and quote everything). In addition remove unused scripts and examples from your Bot
@ -172,16 +177,17 @@ It's important to escape or remove $ in input from user, files or network (as ba
does). One of the powerful features of Unix shells is variable and command substitution does). One of the powerful features of Unix shells is variable and command substitution
using ${} and$() can lead to remote code execution (RCE) or remote information disclosure using ${} and$() can lead to remote code execution (RCE) or remote information disclosure
(RID) bugs if unescaped $ is included in untrusted input (e.g. $$ or $(rm -rf /*)). (RID) bugs if unescaped $ is included in untrusted input (e.g. $$ or $(rm -rf /*)).
A powerful tool to improve your scripts is shellcheck. You can use_it_online or install A powerful tool to improve your scripts is shellcheck. You can use it online [https://
shellcheck_locally. Shellcheck is used extensively in bashbot development to ensure a high www.shellcheck.net/] or install_shellcheck_locally. Shellcheck is used extensively in
code quality (e.g. it's not allowed to push changes without passing all shellcheck tests). bashbot development to ensure a high code quality (e.g. it's not allowed to push changes
In addition bashbot has a test_suite to check if important functionality is working as without passing all shellcheck tests). In addition bashbot has a test_suite to check if
expected. important functionality is working as expected.
Use printf whenever possible Use printf whenever possible
If you're writing a script that accepts external input (e.g. from the user as arguments or 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. 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 Run your Bot as a restricted user
@ -190,8 +196,8 @@ has write access to are in danger of being overwritten/deleted if your bot is ha
the same reason every file your Bot can read is in danger of being disclosed. Restrict the same reason every file your Bot can read is in danger of being disclosed. Restrict
your Bots access rights to the absolute minimum. 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 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 on how to run your Bot 'nobody' has almost no rights on Linux/Unix systems. See Expert use [doc/4_expert.md] on
as an other user. how to run your Bot as an other user.
Secure your Bot installation Secure your Bot installation
@ -234,13 +240,13 @@ At the beginning bashbot was simply the filebashbot.sh that you could copy every
run the bot. Now we have 'commands.sh', 'mycommands.sh', 'modules/*.sh' and much more. 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, rundev/make-standalone.sh to Hey no problem, if you are finished with your cool bot, rundev/make-standalone.sh to
create a stripped down version of your bot containing only 'bashbot.sh' and 'commands.sh'! 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. For more information see Create a stripped down version of your Bot [doc/7_develop.md].
Can I send messages from CLI and scripts? Can I send messages from CLI and scripts?
Of course you can send messages from command line and scripts! Simply install bashbot as Of course you can send messages from command line and scripts! Simply install bashbot as
described_here, send the message '/start' to set yourself as botadmin and then stop the described here [#Your-really-first-bashbot-in-a-nutshell], send the message '/start' to
bot with ./bashbot.sh stop. 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/ Bashbot provides some ready to use scripts for sending messages from command line in bin/
dir, e.g. send_message.sh. dir, e.g. send_message.sh.
@ -248,7 +254,8 @@ dir, e.g. send_message.sh.
bin/send_message.sh --help bin/send_message.sh --help
You can also source bashbot for use in your scripts, for more information see Expert_Use. You can also source bashbot for use in your scripts, for more information see Expert Use
[doc/4_expert.md].
Blocked by telegram? Blocked by telegram?
@ -280,5 +287,5 @@ That's it all guys!
If you feel that there's something missing or if you found a bug, feel free to submit a If you feel that there's something missing or if you found a bug, feel free to submit a
pull request! pull request!
$$VERSION$$ v1.25-dev-33-g04e3c18 $$VERSION$$ v1.25-dev-37-gf0a2843

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# #
#### $$VERSION$$ v1.25-dev-33-g04e3c18 #### $$VERSION$$ v1.25-dev-37-gf0a2843
# shellcheck disable=SC2016 # shellcheck disable=SC2016
# #
# Easy Versioning in git: # Easy Versioning in git:
@ -57,7 +57,9 @@ if [[ "${FILES}" == *"README.md"* ]]; then
FILES+=" README.html README.txt" FILES+=" README.html README.txt"
type -f pandoc >/dev/null && pandoc -s -f commonmark -M "title=Bashbot README" README.md >README.html type -f pandoc >/dev/null && pandoc -s -f commonmark -M "title=Bashbot README" README.md >README.html
if type -f html2text >/dev/null; then if type -f html2text >/dev/null; then
html2text -style pretty -width 90 README.html >README.txt # convert html links to text [link]
sed -E 's/<a href="([^>]+)">([^<#]+)<\/a>/\2 [\1]/' <README.html |\
html2text -style pretty -width 90 - >README.txt
else else
type -f fold >/dev/null && fold -s -w 90 README.md >README.txt type -f fold >/dev/null && fold -s -w 90 README.md >README.txt
fi fi