diff --git a/README.md b/README.md index 867706c..b9c59f5 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Bashbot [Documentation](https://github.com/topkecleon/telegram-bot-bash) and [Do * Seperate logic from commands * Test your Bot with shellcheck * [Bashbot function reference](doc/6_reference.md) +* [Notes for bashbot developers](doc/7_develop.md) ## Note on Keyboards From Version 0.60 on keybord format for ```send_keyboard``` and ```send_message "mykeyboardstartshere ..."``` was changed. @@ -98,4 +99,4 @@ Bashbot is not more (in)secure as any other Bot written in any other language, w If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ 0.70-dev-5-ga97cd69 +#### $$VERSION$$ 0.70-dev-6-g3fb7796 diff --git a/README.txt b/README.txt index 31e943d..f9e059e 100644 --- a/README.txt +++ b/README.txt @@ -30,14 +30,14 @@ Install bashbot 1. Go to the directory you want to install bashbot, e.g. * your $HOME directory (install and run with your user-ID) * /usr/local if you want to run as service -2. Clone the repository: -+ -.... -git clone --recursive https://github.com/topkecleon/telegram-bot-bash -.... -3. Change to directory `telegram-bot-bash`, run `./bashbot.sh init` and -follow the instructions. At this stage you are asked for your Bots token -given by botfather. +2. https://github.com/topkecleon/telegram-bot-bash/releases[Download +latest release archive from github] and unpack it. + +If you want the current version from github, clone the repository: +`git clone https://github.com/topkecleon/telegram-bot-bash` 3. Change +directory to `telegram-bot-bash` and run `./bashbot.sh init`. Now follow +the instructions. At one point you are asked for your Bots token given +by botfather. Update bashbot ~~~~~~~~~~~~~~ @@ -71,6 +71,7 @@ Documentation ** Seperate logic from commands ** Test your Bot with shellcheck * link:doc/6_reference.md[Bashbot function reference] +* link:doc/7_develop.md[Notes for bashbot developers] Note on Keyboards ~~~~~~~~~~~~~~~~~ @@ -161,5 +162,5 @@ That's it! If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -latexmath:[\[VERSION\]] 0.70-dev-4-g12fd839 +latexmath:[\[VERSION\]] 0.70-dev-6-g3fb7796 +++++++++++++++++++++++++++++++++++++++++++ diff --git a/bashbot.rc b/bashbot.rc index c374e39..bcb4953 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,7 +1,7 @@ #!/bin/sh # description: Start or stop telegram-bash-bot # -#### $$VERSION$$ 0.70-dev-4-g12fd839 +#### $$VERSION$$ 0.70-dev-6-g3fb7796 # shellcheck disable=SC2009 # shellcheck disable=SC2181 diff --git a/bashbot.sh b/bashbot.sh index ff9e44a..29124b8 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -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$$ 0.70-dev-5-ga97cd69 +#### $$VERSION$$ 0.70-dev-6-g3fb7796 # # Exit Codes: # - 0 sucess (hopefully) diff --git a/commands.sh b/commands.sh index 5bd6d2d..94c7506 100755 --- a/commands.sh +++ b/commands.sh @@ -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$$ 0.70-dev-4-g12fd839 +#### $$VERSION$$ 0.70-dev-6-g3fb7796 # # shellcheck disable=SC2154 # shellcheck disable=SC2034 diff --git a/dev/hooks/pre-commit.sh b/dev/hooks/pre-commit.sh index 88fdecd..95cbde0 100755 --- a/dev/hooks/pre-commit.sh +++ b/dev/hooks/pre-commit.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash -#### $$VERSION$$ 0.70-dev-0-g209c4b3 +#### $$VERSION$$ 0.70-dev-6-g3fb7796 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script GIT_DIR=$(git rev-parse --git-dir) cd "$GIT_DIR/.." || exit 1 -HOOKDIR="dev/hooks" +export HOOKDIR="dev/hooks" echo "Running pre-commit hook" @@ -28,6 +28,7 @@ else fi # run shellcheck before commit +echo "read files from ${HOOKDIR}/shellcheck.files ..." FILES=$(sed '/^#/d' <"${HOOKDIR}/shellcheck.files") if [ "$FILES" != "" ]; then # shellcheck disable=SC2086 diff --git a/dev/hooks/pre-push.sh b/dev/hooks/pre-push.sh index 956de18..70aa37a 100755 --- a/dev/hooks/pre-push.sh +++ b/dev/hooks/pre-push.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash -#### $$VERSION$$ 0.70-dev-0-g209c4b3 +#### $$VERSION$$ 0.70-dev-6-g3fb7796 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script GIT_DIR=$(git rev-parse --git-dir) cd "$GIT_DIR/.." || exit 1 -HOOKDIR="dev/hooks" +export HOOKDIR="dev/hooks" REMOTEVER="$(git ls-remote -t --refs 2>/dev/null | tail -1 | sed 's/.*\/v//')" VERSION="$(git describe --tags | sed -e 's/-.*//' -e 's/v//')" diff --git a/dev/hooks/shellcheck.files b/dev/hooks/shellcheck.files index 57acc37..7f8f037 100644 --- a/dev/hooks/shellcheck.files +++ b/dev/hooks/shellcheck.files @@ -1,5 +1,5 @@ # list of files to run shellscheck against -#### $$VERSION$$ 0.70-dev-0-g209c4b3 +#### $$VERSION$$ 0.70-dev-6-g3fb7796 # main files bashbot.sh commands.sh @@ -10,5 +10,6 @@ examples/notify examples/question # dev files dev/version.sh -dev/hooks/install-hooks.sh +dev/install-hooks.sh dev/hooks/pre-commit.sh +dev/hooks/pre-push.sh diff --git a/dev/hooks/install-hooks.sh b/dev/install-hooks.sh similarity index 87% rename from dev/hooks/install-hooks.sh rename to dev/install-hooks.sh index d088ac2..d09b6f4 100755 --- a/dev/hooks/install-hooks.sh +++ b/dev/install-hooks.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$$ 0.70-dev-0-g209c4b3 +#### $$VERSION$$ 0.70-dev-6-g3fb7796 # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script @@ -13,7 +13,7 @@ HOOKDIR="dev/hooks" echo -n "Installing hooks..." for hook in pre-commit pre-push do - rm -f ".git/hooks/${hook}" + rm -f "${GIT_DIR}/hooks/${hook}" if [ -f "${HOOKDIR}/${hook}.sh" ]; then echo -n " $hook" ln -s "../../${HOOKDIR}/${hook}.sh" "${GIT_DIR}/hooks/${hook}" diff --git a/dev/version.sh b/dev/version.sh index 45e2e17..c4f5793 100755 --- a/dev/version.sh +++ b/dev/version.sh @@ -1,6 +1,6 @@ #!/bin/bash # -#### $$VERSION$$ 0.70-dev-4-g12fd839 +#### $$VERSION$$ 0.70-dev-6-g3fb7796 # shellcheck disable=SC2016 # # Easy Versioning in git: @@ -45,7 +45,7 @@ unset IFS VERSION="$(git describe --tags --long)" echo "Update to version $VERSION ..." -FILES="* doc/* test/*" +FILES="* doc/* dev/* dev/*/*" [ "$1" != "" ] && FILES="$*" for file in $FILES diff --git a/doc/1_firstbot.md b/doc/1_firstbot.md index daec160..b0489f6 100644 --- a/doc/1_firstbot.md +++ b/doc/1_firstbot.md @@ -61,5 +61,5 @@ group. This step is up to you actually. #### [Next Getting started](2_usage.md) -#### $$VERSION$$ 0.70-dev-5-ga97cd69 +#### $$VERSION$$ 0.70-dev-6-g3fb7796 diff --git a/doc/2_usage.md b/doc/2_usage.md index a7e7064..338190e 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -159,5 +159,5 @@ send_action "${CHAT[ID]}" "action" #### [Prev Create Bot](1_firstbot.md) #### [Next Advanced Usage](3_advanced.md) -#### $$VERSION$$ 0.70-dev-5-ga97cd69 +#### $$VERSION$$ 0.70-dev-6-g3fb7796 diff --git a/doc/3_advanced.md b/doc/3_advanced.md index cef13ae..2588974 100644 --- a/doc/3_advanced.md +++ b/doc/3_advanced.md @@ -156,5 +156,5 @@ answer_inline_query "$iQUERY_ID" "cached_sticker" "identifier for the sticker" #### [Prev Advanced Usage](3_advanced.md) #### [Next Expert Use](4_expert.md) -#### $$VERSION$$ 0.70-dev-5-ga97cd69 +#### $$VERSION$$ 0.70-dev-6-g3fb7796 diff --git a/doc/4_expert.md b/doc/4_expert.md index 62f1dc8..11a5df7 100644 --- a/doc/4_expert.md +++ b/doc/4_expert.md @@ -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$$ 0.70-dev-5-ga97cd69 +#### $$VERSION$$ 0.70-dev-6-g3fb7796 diff --git a/doc/5_practice.md b/doc/5_practice.md index ea839e0..9e5ce00 100644 --- a/doc/5_practice.md +++ b/doc/5_practice.md @@ -112,5 +112,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$$ 0.70-dev-5-ga97cd69 +#### $$VERSION$$ 0.70-dev-6-g3fb7796 diff --git a/doc/6_reference.md b/doc/6_reference.md index 05c0d1c..1861fd2 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -346,6 +346,7 @@ The name of your bot is availible as bash variable "$ME", there is no need to ca Send Input from Telegram to waiting Interactive Chat. #### [Prev Best Practice](5_practice.md) +#### [Next Developer Rules](7_develop.md) -#### $$VERSION$$ 0.70-dev-5-ga97cd69 +#### $$VERSION$$ 0.70-dev-6-g3fb7796 diff --git a/doc/7_develop.md b/doc/7_develop.md new file mode 100644 index 0000000..7f51c26 --- /dev/null +++ b/doc/7_develop.md @@ -0,0 +1,37 @@ +#### [Home](../README.md) +## Notes for bashbot developers +This section is about help and best pratices for new bashbot developers. The main focus on creating new versions of bashbot, not on develop an individual bot. Nevertheless rules and tools described can also applied to your bot development. + +Bashbot development is done on gitbub. If you want to provide fixes or new features fork bashbot on githup and provide changes as pull request. + +### Setup your develop environment + +1. install git, install [shellcheck](5_practice.md#Test-your-Bot-with-shellcheck) +2. setup your [environment for UTF-8](4_expert.md#Setting-up-your-Environment) +3. clone your bashbot fork to a new directory ```git clone https://github.com//telegram-bot-bash.git```, replace with your username on github +4. create and change to your develop branch ```git checkout -b ```, replace with the name you want to name it, e.g. 'develop' +5. give your (dev) fork a new version tag: ```git tag vx.xx```, version must be higher than current version +6. setup github hooks by running ```dev/install-hooks.sh``` (optional) + +### Versioning + +Bashbot is tagged with version numbers. If you start new development you must tag your fork with a new version higher than the current version. +If you fork 'v0.60' the next develop version should tagged as e.g. ```git tag "v0.61-dev"``` for fixes or ```git tag "v0.70-dev"``` for new features. + +To get the current version name of your dev fork run ```git describe --tags```. The output will something like '0.70-dev-6-g3fb7796', where your version tag is followed by the number of commits since you tag your version and the latest commit hash. see also [comments in version.sh](../dev/version.sh) + +To update the Version Number in your scripts run ```dev/version.sh```, it will update the line '#### $$VERSION$$ ###' in all files to the current version name. + +If you actived git hooks in Setup step 6, 'version.sh' updates the version name on every push + +### Shellchecking + +For a shell script running as a service it's important to be paranoid about quoting, globbing and ohter common problems. So it's a must to run shellchek on all shell scripts before you commit a change. this is done by a git hook activated in Setup step 6. + +You can run shellcheck manually on every file or run ```dev/hooks/pre-commit.sh``` to run shellcheck for all files given in 'dev/hooks/shellcheck.files'. + + +#### [Prev Function Reference](6_function.md) + +#### $$VERSION$$ 0.70-dev-6-g3fb7796 +