v0.70-pre2, doc for examples

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-04-29 19:34:47 +02:00
parent 7ce2c5be2c
commit 4b83377905
43 changed files with 89 additions and 53 deletions

View File

@ -70,6 +70,7 @@
<li>Bashbot testsuite</li>
</ul></li>
<li><a href="doc/8_customize.md">Customize bashbot environment</a></li>
<li><a href="examples/README.MD">Exmaples</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>
@ -96,6 +97,6 @@
<p><span class="citation">@Gnadelwartz</span></p>
<h2 id="thats-it">Thats it!</h2>
<p>If you feel that theres something missing or if you found a bug, feel free to submit a pull request!</p>
<h4 id="version-v0.70-pre1-6-g3cd6eeb"><br /><span class="math display"><em>V</em><em>E</em><em>R</em><em>S</em><em>I</em><em>O</em><em>N</em></span><br /> v0.70-pre1-6-g3cd6eeb</h4>
<h4 id="version-v0.7-pre2-0-g7ce2c5b"><br /><span class="math display"><em>V</em><em>E</em><em>R</em><em>S</em><em>I</em><em>O</em><em>N</em></span><br /> v0.7-pre2-0-g7ce2c5b</h4>
</body>
</html>

View File

@ -51,7 +51,7 @@ Bashbot [Documentation](https://github.com/topkecleon/telegram-bot-bash) and [Do
* Prepare a new version
* Bashbot testsuite
* [Customize bashbot environment](doc/8_customize.md)
* [Exmaples](examples/README.MD)
## Security Considerations
Running a Telegram Bot means it is connected to the public and you never know whats send to your Bot.
@ -93,4 +93,4 @@ Well, thats a damn good question ... may be because I'm an Unix/Linux admin from
If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
#### $$VERSION$$ v0.70-pre1-6-g3cd6eeb
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b

View File

@ -58,7 +58,7 @@ all](https://core.telegram.org/bots#3-how-do-i-create-a-bot)
* Prepare a new version
* Bashbot testsuite
* [Customize bashbot environment](doc/8_customize.md)
* [Exmaples](examples/README.MD)
## Security Considerations
Running a Telegram Bot means it is connected to the public and you never know
@ -130,4 +130,4 @@ health status
If you feel that there's something missing or if you found a bug, feel free to
submit a pull request!
#### $$VERSION$$ v0.70-pre1-6-g3cd6eeb
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b

View File

@ -1,7 +1,7 @@
#!/bin/sh
# description: Start or stop telegram-bash-bot
#
#### $$VERSION$$ v0.70-pre1-4-g0d38a67
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
# shellcheck disable=SC2009
# shellcheck disable=SC2181

View File

@ -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$$ v0.70-pre1-0-g490c472
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
#
# Exit Codes:
# - 0 sucess (hopefully)

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.70-pre1-2-g293ad08
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
#
# shellcheck disable=SC2154
# shellcheck disable=SC2034

View File

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

View File

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

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-pre1-0-g490c472
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
############
# NOTE: you MUST run install-hooks.sh again when updating this file!

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-pre1-0-g490c472
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
############
# NOTE: you MUST run install-hooks.sh again when updating this file!

View File

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

View File

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

View File

@ -1,3 +1,3 @@
# list of additional files to check from shellcheck
#### $$VERSION$$ v0.70-pre1-0-g490c472
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
bashbot.rc

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
#### $$VERSION$$ v0.70-pre1-8-gfcca139
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
# shellcheck disable=SC2016
#
# Easy Versioning in git:

View File

@ -63,5 +63,5 @@ The old format is supported for backward compatibility, but may fail for corner
#### [Next Create Bot](1_firstbot.md)
#### $$VERSION$$ v0.70-pre1-2-g293ad08
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b

View File

@ -65,5 +65,5 @@ group. This step is up to you actually.
#### [Prev Installation](0_install.md)
#### [Next Getting started](2_usage.md)
#### $$VERSION$$ v0.70-pre1-2-g293ad08
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b

View File

@ -167,5 +167,5 @@ send_action "${CHAT[ID]}" "action"
#### [Prev Create Bot](1_firstbot.md)
#### [Next Advanced Usage](3_advanced.md)
#### $$VERSION$$ v0.70-pre1-2-g293ad08
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b

View File

@ -177,5 +177,5 @@ answer_inline_query "$iQUERY_ID" "cached_sticker" "identifier for the sticker"
#### [Prev Getting started](2_usage.md)
#### [Next Expert Use](4_expert.md)
#### $$VERSION$$ v0.70-pre1-8-gfcca139
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b

View File

@ -104,5 +104,5 @@ An example crontab is provided in ```examples/bashbot.cron```.
#### [Prev Expert Use](4_expert.md)
#### [Next Best Practice](5_practice.md)
#### $$VERSION$$ v0.70-pre1-0-g490c472
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b

View File

@ -153,5 +153,5 @@ The second warning is about an unused variable, this is true because in our exam
#### [Prev Best Practice](5_practice.md)
#### [Next Functions Reference](6_reference.md)
#### $$VERSION$$ v0.70-pre1-7-g02d9afb
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b

View File

@ -489,5 +489,5 @@ Send Input from Telegram to waiting Interactive Chat.
#### [Prev Best Practice](5_practice.md)
#### [Next Notes for Developers](7_develop.md)
#### $$VERSION$$ v0.70-pre1-7-g02d9afb
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b

View File

@ -92,5 +92,5 @@ fi
#### [Prev Function Reference](6_function.md)
#### [Next Bashbot Environment](8_custom.md)
#### $$VERSION$$ v0.70-pre1-7-g02d9afb
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b

View File

@ -117,5 +117,5 @@ for every poll until the maximum of BASHBOT_SLEEP ms.
#### [Prev Notes for Developers](7_develop.md)
#### $$VERSION$$ v0.70-pre1-0-g490c472
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b

35
examples/README.md Normal file
View File

@ -0,0 +1,35 @@
#### [Home](../README.md)
## Bashbot examples
### bashbot.cron
An example crontab is provided in ```examples/bashbot.cron```, see [Expert use](../doc/4_expert.md#Scedule-bashbot-from-Cron)
### Interactive chat examples
Two examples for interactive scripts are provided as 'calc.sh' and 'question.sh', see [Advanced use](../doc/3_advanced.md#Interactive-Chats)
### Background jobs
Background jobs are an easy way to provide sceduled messages or alerts if something happens.
'notify.sh' shows you a simple exmaple to send a message ervery x seonds, e.g. actual time.
'background-scripts' contains a more complex example on how to start and kill many scripts sending messages to a chat.
```
mycommands.sh - /run_xxx and /kill-xxx wil start any script named run_xxx.sh
run_diskusage.sh - shows disk usage every 100 seconds
run_filename.sh - shown the namei of new files in a named dir
run_filecontent.sh - shown the content of new files in a named dir
run_notify.sh - same as notify.sh
```
### Use bashbot from external scripts
In 'external-use' you will find some examples on how to send messages from external scripts to send messages to Telegram chats or users.
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b

View File

@ -9,25 +9,25 @@ mycommands() {
case "$MESSAGE" in
'/run_'*)
myback="run_${MESSAGE#*_}"
if [ -x "./$myback.sh" ]; then
checkback "$myback"
if [ -x "./${myback}.sh" ]; then
checkback "${myback}"
if [ "$res" -gt 0 ] ; then
send_normal_message "${CHAT[ID]}" "Starte $myback"
background "./$myback.sh" "$myback"
send_normal_message "${CHAT[ID]}" "Start ${myback}, use /kill${myback} to stop it."
background "./${myback}.sh" "${myback}"
else
send_normal_message "${CHAT[ID]}" "Prozess $myback laeuft bereits."
send_normal_message "${CHAT[ID]}" "Background job ${myback} already running."
fi
fi
;;
'/kill_'*)
myback="run_${MESSAGE#*_}"
if [ -x "./$myback.sh" ]; then
checkback "$myback"
if [ -x "./${myback}.sh" ]; then
checkback "${myback}"
if [ "$res" -eq 0 ] ; then
killback "$myback"
send_normal_message "${CHAT[ID]}" "Beende $myback."
killback "${myback}"
send_normal_message "${CHAT[ID]}" "Stopping ${myback}, use /run_${myback} to start again."
else
send_normal_message "${CHAT[ID]}" "Prozess $myback laeuft nicht."
send_normal_message "${CHAT[ID]}" "No background job ${myback}."
fi
fi
;;

View File

@ -4,7 +4,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.70-pre1-11-g3dfa5e4
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -4,7 +4,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.70-pre1-11-g3dfa5e4
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -7,7 +7,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.70-pre1-0-g490c472
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
SHELL=/bin/sh

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.70-pre1-11-g3dfa5e4
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -4,7 +4,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.70-pre1-11-g3dfa5e4
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.70-pre1-11-g3dfa5e4
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.70-pre1-0-g490c472
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
#
# source from commands.sh to use the aliases

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.70-pre1-6-g3cd6eeb
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
# source from commands.sh if you want ro use interactive or background jobs

View File

@ -5,6 +5,6 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.70-pre1-0-g490c472
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
# source from commands.sh to use the inline functions

View File

@ -2,7 +2,7 @@
# files: mycommands.sh.dist
# copy to mycommands.sh and add all your commands and functions here ...
#
#### $$VERSION$$ v0.70-pre1-2-g293ad08
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
#
# shellcheck disable=SC2154
# shellcheck disable=SC2034

View File

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

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-pre1-0-g490c472
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
# common variables
export TESTME DIRME TESTDIR LOGFILE REFDIR TESTNAME

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-pre1-0-g490c472
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
../dev/hooks/pre-commit.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-pre1-0-g490c472
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-pre1-0-g490c472
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-pre1-0-g490c472
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-pre1-6-g3cd6eeb
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
#### $$VERSION$$ v0.70-pre1-0-g490c472
#### $$VERSION$$ v0.7-pre2-0-g7ce2c5b
# include common functions and definitions
# shellcheck source=test/ALL-tests.inc.sh