diff --git a/README.md b/README.md index 1837bbc..556bd4c 100644 --- a/README.md +++ b/README.md @@ -99,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-2-gebd9e6f +#### $$VERSION$$ 0.70-dev-4-g12fd839 diff --git a/README.txt b/README.txt index 847a550..31e943d 100644 --- a/README.txt +++ b/README.txt @@ -161,5 +161,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-2-gebd9e6f +latexmath:[\[VERSION\]] 0.70-dev-4-g12fd839 +++++++++++++++++++++++++++++++++++++++++++ diff --git a/bashbot.rc b/bashbot.rc index 4712ff0..c374e39 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,7 +1,7 @@ #!/bin/sh # description: Start or stop telegram-bash-bot # -#### $$VERSION$$ 0.70-dev-2-gebd9e6f +#### $$VERSION$$ 0.70-dev-4-g12fd839 # shellcheck disable=SC2009 # shellcheck disable=SC2181 diff --git a/bashbot.sh b/bashbot.sh index 59e15ea..6b9dd00 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-2-gebd9e6f +#### $$VERSION$$ 0.70-dev-4-g12fd839 # # Exit Codes: # - 0 sucess (hopefully) diff --git a/commands.sh b/commands.sh index 34dc980..5bd6d2d 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-2-gebd9e6f +#### $$VERSION$$ 0.70-dev-4-g12fd839 # # shellcheck disable=SC2154 # shellcheck disable=SC2034 @@ -100,7 +100,7 @@ else '/question') checkproc if [ "$res" -gt 0 ] ; then - startproc "./question" + startproc "example/question" else send_normal_message "${CHAT[ID]}" "$MESSAGE already running ..." fi @@ -109,7 +109,7 @@ else '/run-notify') myback="notify"; checkback "$myback" if [ "$res" -gt 0 ] ; then - background "./notify 60" "$myback" # notify every 60 seconds + background "example/notify 60" "$myback" # notify every 60 seconds else send_normal_message "${CHAT[ID]}" "Background command $myback already running ..." fi diff --git a/hooks/install-hooks.sh b/dev/hooks/install-hooks.sh similarity index 72% rename from hooks/install-hooks.sh rename to dev/hooks/install-hooks.sh index d3dc2c2..d088ac2 100755 --- a/hooks/install-hooks.sh +++ b/dev/hooks/install-hooks.sh @@ -8,13 +8,15 @@ GIT_DIR=$(git rev-parse --git-dir) cd "$GIT_DIR/.." || exit 1 +HOOKDIR="dev/hooks" + echo -n "Installing hooks..." for hook in pre-commit pre-push do - rm -f "$GIT_DIR/hooks/${hook}" - if [ -f "hooks/${hook}.sh" ]; then + rm -f ".git/hooks/${hook}" + if [ -f "${HOOKDIR}/${hook}.sh" ]; then echo -n " $hook" - ln -s "../../hooks/${hook}.sh" "$GIT_DIR/hooks/${hook}" + ln -s "../../${HOOKDIR}/${hook}.sh" "${GIT_DIR}/hooks/${hook}" fi done echo " Done!" diff --git a/hooks/pre-commit.sh b/dev/hooks/pre-commit.sh similarity index 92% rename from hooks/pre-commit.sh rename to dev/hooks/pre-commit.sh index 6a3e76c..88fdecd 100755 --- a/hooks/pre-commit.sh +++ b/dev/hooks/pre-commit.sh @@ -6,6 +6,8 @@ GIT_DIR=$(git rev-parse --git-dir) cd "$GIT_DIR/.." || exit 1 +HOOKDIR="dev/hooks" + echo "Running pre-commit hook" # if any command inside script returns error, exit and return that error @@ -26,7 +28,7 @@ else fi # run shellcheck before commit -FILES=$(sed '/^#/d' <"hooks/shellcheck.files") +FILES=$(sed '/^#/d' <"${HOOKDIR}/shellcheck.files") if [ "$FILES" != "" ]; then # shellcheck disable=SC2086 shellcheck -x ${FILES} || exit 1 diff --git a/hooks/pre-push.sh b/dev/hooks/pre-push.sh similarity index 95% rename from hooks/pre-push.sh rename to dev/hooks/pre-push.sh index 686c9d4..956de18 100755 --- a/hooks/pre-push.sh +++ b/dev/hooks/pre-push.sh @@ -5,6 +5,9 @@ # no matter from which directory we'll run script GIT_DIR=$(git rev-parse --git-dir) cd "$GIT_DIR/.." || exit 1 + +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//')" @@ -22,7 +25,7 @@ unset IFS; set -f # LOCAL version must greater than latest REMOTE release version if (( $(echo "${VERSION} > ${REMOTEVER}" | bc -l) )); then # update version in bashbot files on push - ./version + dev/version.sh 2>/dev/null else echo "Error: local version ${VERSION} must be greater than latest release version." echo "use \"git tag ...\" to create a local version greater than ${REMOTEVER}" diff --git a/dev/hooks/shellcheck.files b/dev/hooks/shellcheck.files new file mode 100644 index 0000000..57acc37 --- /dev/null +++ b/dev/hooks/shellcheck.files @@ -0,0 +1,14 @@ +# list of files to run shellscheck against +#### $$VERSION$$ 0.70-dev-0-g209c4b3 +# main files +bashbot.sh +commands.sh +bashbot.rc +# example files +examples/calc +examples/notify +examples/question +# dev files +dev/version.sh +dev/hooks/install-hooks.sh +dev/hooks/pre-commit.sh diff --git a/version b/dev/version.sh similarity index 79% rename from version rename to dev/version.sh index 4a4325d..45e2e17 100755 --- a/version +++ b/dev/version.sh @@ -1,6 +1,6 @@ #!/bin/bash # -#### $$VERSION$$ 0.70-dev-2-gebd9e6f +#### $$VERSION$$ 0.70-dev-4-g12fd839 # shellcheck disable=SC2016 # # Easy Versioning in git: @@ -34,11 +34,16 @@ # run this script to (re)place Version number in files # +# 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 + unset IFS # set -f # if you are paranoid use set -f to disable globbing VERSION="$(git describe --tags --long)" -echo "Update files to version $VERSION ..." +echo "Update to version $VERSION ..." FILES="* doc/* test/*" [ "$1" != "" ] && FILES="$*" @@ -47,11 +52,11 @@ for file in $FILES do [ ! -f "$file" ] && continue #[ "$file" == "version" ] && continue - echo -n " $file" + echo -n " $file" >&2 sed -i 's/^#### $$VERSION$$.*/#### \$\$VERSION\$\$ '"$VERSION"'/' "$file" done # try to compile README.txt -echo -n " README.txt" +echo -n " README.txt" >&2 pandoc -f markdown -t asciidoc README.md | sed '/^\[\[/d' >README.txt echo " done." diff --git a/doc/1_firstbot.md b/doc/1_firstbot.md index 614ca9d..186015d 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-2-gebd9e6f +#### $$VERSION$$ 0.70-dev-4-g12fd839 diff --git a/doc/2_usage.md b/doc/2_usage.md index 0c03389..98e9d97 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-2-gebd9e6f +#### $$VERSION$$ 0.70-dev-4-g12fd839 diff --git a/doc/3_advanced.md b/doc/3_advanced.md index 24ceee7..0fe9391 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-2-gebd9e6f +#### $$VERSION$$ 0.70-dev-4-g12fd839 diff --git a/doc/4_expert.md b/doc/4_expert.md index 711c201..1c44d09 100644 --- a/doc/4_expert.md +++ b/doc/4_expert.md @@ -104,5 +104,5 @@ An example crontab is provided in ```bashbot.cron```. #### [Prev Expert Use](4_expert.md) #### [Next Best Practice](5_practice.md) -#### $$VERSION$$ 0.70-dev-2-gebd9e6f +#### $$VERSION$$ 0.70-dev-4-g12fd839 diff --git a/doc/5_practice.md b/doc/5_practice.md index 974a535..36b9965 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-2-gebd9e6f +#### $$VERSION$$ 0.70-dev-4-g12fd839 diff --git a/doc/6_reference.md b/doc/6_reference.md index 580dc37..cefc443 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -347,5 +347,5 @@ Send Input from Telegram to waiting Interactive Chat. #### [Prev Best Practice](5_practice.md) -#### $$VERSION$$ 0.70-dev-2-gebd9e6f +#### $$VERSION$$ 0.70-dev-4-g12fd839 diff --git a/bashbot.cron b/examples/bashbot.cron similarity index 97% rename from bashbot.cron rename to examples/bashbot.cron index 651191a..ad1fc7e 100644 --- a/bashbot.cron +++ b/examples/bashbot.cron @@ -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$$ 0.70-dev-2-gebd9e6f +#### $$VERSION$$ 0.70-dev-4-g12fd839 SHELL=/bin/sh diff --git a/calc b/examples/calc similarity index 96% rename from calc rename to examples/calc index b1c026b..203fdfe 100755 --- a/calc +++ b/examples/calc @@ -3,7 +3,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-2-gebd9e6f +#### $$VERSION$$ 0.70-dev-4-g12fd839 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/notify b/examples/notify similarity index 94% rename from notify rename to examples/notify index 71cc88b..f63f12f 100755 --- a/notify +++ b/examples/notify @@ -2,7 +2,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-2-gebd9e6f +#### $$VERSION$$ 0.70-dev-4-g12fd839 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/question b/examples/question similarity index 96% rename from question rename to examples/question index 8a53443..d3c86c3 100755 --- a/question +++ b/examples/question @@ -3,7 +3,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-2-gebd9e6f +#### $$VERSION$$ 0.70-dev-4-g12fd839 # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/hooks/shellcheck.files b/hooks/shellcheck.files deleted file mode 100644 index 57a57a2..0000000 --- a/hooks/shellcheck.files +++ /dev/null @@ -1,14 +0,0 @@ -# list of files to run shellscheck against -#### $$VERSION$$ 0.70-dev-0-g209c4b3 -# main files -bashbot.rc -bashbot.sh -version -# job files -calc -commands.sh -notify -question -# test files -hooks/install-hooks.sh -hooks/pre-commit.sh