mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-12-29 13:12:36 +00:00
add make-standalone.sh, creates old style minimal bashbot files
This commit is contained in:
parent
0c5e3dd597
commit
e492da05f7
@ -12,7 +12,7 @@
|
|||||||
# This file is public domain in the USA and all free countries.
|
# This file is public domain in the USA and all free countries.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
|
#### $$VERSION$$ v0.80-dev2-2-g0c5e3dd
|
||||||
#
|
#
|
||||||
# Exit Codes:
|
# Exit Codes:
|
||||||
# - 0 sucess (hopefully)
|
# - 0 sucess (hopefully)
|
||||||
@ -32,6 +32,7 @@ if [ -t 1 ] && [ "$TERM" != "" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# get location and name of bashbot.sh
|
# get location and name of bashbot.sh
|
||||||
|
export SCRIPT SCRIPTDIR MODULEDIR RUNDIR RUNUSER
|
||||||
SCRIPT="$0"
|
SCRIPT="$0"
|
||||||
SCRIPTDIR="$(dirname "$0")"
|
SCRIPTDIR="$(dirname "$0")"
|
||||||
MODULEDIR="${SCRIPTDIR}/modules"
|
MODULEDIR="${SCRIPTDIR}/modules"
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# this has to run once atfer git clone
|
# this has to run once atfer git clone
|
||||||
# and every time we create new hooks
|
# and every time we create new hooks
|
||||||
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
|
#### $$VERSION$$ v0.80-dev2-2-g0c5e3dd
|
||||||
|
|
||||||
# magic to ensure that we're always inside the root of our application,
|
# magic to ensure that we're always inside the root of our application,
|
||||||
# no matter from which directory we'll run script
|
# no matter from which directory we'll run script
|
||||||
GIT_DIR=$(git rev-parse --git-dir)
|
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
|
||||||
cd "${GIT_DIR}/.." || exit 1
|
if [ "$GIT_DIR" != "" ] ; then
|
||||||
|
cd "$GIT_DIR/.." || exit 1
|
||||||
|
else
|
||||||
|
echo "Sorry, no git repository $(pwd)" && exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# create test environment
|
# create test environment
|
||||||
TESTENV="/tmp/bashbot.test$$"
|
TESTENV="/tmp/bashbot.test$$"
|
||||||
|
@ -3,12 +3,16 @@
|
|||||||
#
|
#
|
||||||
# works together with git pre-push.sh and ADD all changed files since last push
|
# works together with git pre-push.sh and ADD all changed files since last push
|
||||||
|
|
||||||
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
|
#### $$VERSION$$ v0.80-dev2-2-g0c5e3dd
|
||||||
|
|
||||||
# magic to ensure that we're always inside the root of our application,
|
# magic to ensure that we're always inside the root of our application,
|
||||||
# no matter from which directory we'll run script
|
# no matter from which directory we'll run script
|
||||||
GIT_DIR=$(git rev-parse --git-dir)
|
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
|
||||||
cd "$GIT_DIR/.." || exit 1
|
if [ "$GIT_DIR" != "" ] ; then
|
||||||
|
cd "$GIT_DIR/.." || exit 1
|
||||||
|
else
|
||||||
|
echo "Sorry, no git repository $(pwd)" && exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
[ ! -f .git/.lastpush ] && echo "No push or hooks not installed, use \"git add\" instead ... Abort" && exit
|
[ ! -f .git/.lastpush ] && echo "No push or hooks not installed, use \"git add\" instead ... Abort" && exit
|
||||||
|
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# this has to run once atfer git clone
|
# this has to run once atfer git clone
|
||||||
# and every time we create new hooks
|
# and every time we create new hooks
|
||||||
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
|
#### $$VERSION$$ v0.80-dev2-2-g0c5e3dd
|
||||||
|
|
||||||
# magic to ensure that we're always inside the root of our application,
|
# magic to ensure that we're always inside the root of our application,
|
||||||
# no matter from which directory we'll run script
|
# no matter from which directory we'll run script
|
||||||
GIT_DIR=$(git rev-parse --git-dir)
|
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
|
||||||
cd "$GIT_DIR/.." || exit 1
|
if [ "$GIT_DIR" != "" ] ; then
|
||||||
|
cd "$GIT_DIR/.." || exit 1
|
||||||
|
else
|
||||||
|
echo "Sorry, no git repository $(pwd)" && exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
HOOKDIR="dev/hooks"
|
HOOKDIR="dev/hooks"
|
||||||
|
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# this has to run once atfer git clone
|
# this has to run once atfer git clone
|
||||||
# and every time we create new hooks
|
# and every time we create new hooks
|
||||||
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
|
#### $$VERSION$$ v0.80-dev2-2-g0c5e3dd
|
||||||
|
|
||||||
# magic to ensure that we're always inside the root of our application,
|
# magic to ensure that we're always inside the root of our application,
|
||||||
# no matter from which directory we'll run script
|
# no matter from which directory we'll run script
|
||||||
GIT_DIR=$(git rev-parse --git-dir)
|
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
|
||||||
cd "$GIT_DIR/.." || exit 1
|
if [ "$GIT_DIR" != "" ] ; then
|
||||||
|
cd "$GIT_DIR/.." || exit 1
|
||||||
|
else
|
||||||
|
echo "Sorry, no git repository $(pwd)" && exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
VERSION="$(git describe --tags | sed -e 's/-[0-9].*//' -e 's/v//')"
|
VERSION="$(git describe --tags | sed -e 's/-[0-9].*//' -e 's/v//')"
|
||||||
|
|
||||||
@ -18,6 +22,7 @@ DISTFILES="bashbot.rc bashbot.sh commands.sh mycommands.sh doc examples modu
|
|||||||
|
|
||||||
for test in "dev/all-tests.sh"
|
for test in "dev/all-tests.sh"
|
||||||
do
|
do
|
||||||
|
[ ! -x ""${test} ] && continue
|
||||||
if ! "${test}" ; then
|
if ! "${test}" ; then
|
||||||
echo "Test ${test} failed, can't create dist!"
|
echo "Test ${test} failed, can't create dist!"
|
||||||
exit 1
|
exit 1
|
87
dev/make-standalone.sh
Executable file
87
dev/make-standalone.sh
Executable file
@ -0,0 +1,87 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# this has to run once atfer git clone
|
||||||
|
# and every time we create new hooks
|
||||||
|
#### $$VERSION$$ v0.80-dev2-2-g0c5e3dd
|
||||||
|
|
||||||
|
# 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 2>/dev/null)
|
||||||
|
if [ "$GIT_DIR" != "" ] ; then
|
||||||
|
cd "$GIT_DIR/.." || exit 1
|
||||||
|
else
|
||||||
|
[ ! -f "bashbot.sh" ] && echo "bashbot.sh not found in $(pwd)" && exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#DISTNAME="telegram-bot-bash"
|
||||||
|
DISTDIR="./standalone/${DISTNAME}"
|
||||||
|
DISTFILES="bashbot.sh commands.sh mycommands.sh modules LICENSE README.txt token count botacl botadmin"
|
||||||
|
|
||||||
|
# run tests first!
|
||||||
|
|
||||||
|
for test in "dev/all-tests.sh"
|
||||||
|
do
|
||||||
|
[ ! -x "${test}" ] && continue
|
||||||
|
if ! "${test}" ; then
|
||||||
|
echo "Test ${test} failed, can't create standalone!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# create dir for distribution and copy files
|
||||||
|
mkdir -p "${DISTDIR}" 2>/dev/null
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
cp -r ${DISTFILES} "${DISTDIR}" 2>/dev/null
|
||||||
|
cd "${DISTDIR}" || exit 1
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# here the magic starts
|
||||||
|
# create all in one bashbot.sh file
|
||||||
|
|
||||||
|
echo "OK, noe lets do the magic ..."
|
||||||
|
echo " ... create unified commands.sh"
|
||||||
|
|
||||||
|
{
|
||||||
|
# first head of commands.sh
|
||||||
|
sed -n '0,/^if / p' commands.sh | head -n -2 | grep -v 'mycommands.sh'
|
||||||
|
|
||||||
|
# then mycommands from first non comment line on
|
||||||
|
printf '\n##############################\n# my commands starts here ...\n'
|
||||||
|
sed -n '/^$/,$ p' mycommands.sh
|
||||||
|
|
||||||
|
# last tail of commands.sh
|
||||||
|
printf '\n##############################\n# default commands starts here ...\n'
|
||||||
|
sed -n '/\/mycommands.sh"/,$ p' commands.sh | tail -n +2
|
||||||
|
|
||||||
|
} >>$$commands.sh
|
||||||
|
|
||||||
|
mv $$commands.sh commands.sh
|
||||||
|
rm -f mycommands.sh
|
||||||
|
|
||||||
|
echo " ... create unified bashbot.sh"
|
||||||
|
|
||||||
|
{
|
||||||
|
# first head of bashbot.sh
|
||||||
|
sed -n '0,/\/commands.sh"/ p' bashbot.sh | head -n -2
|
||||||
|
|
||||||
|
# then mycommands from first non comment line on
|
||||||
|
printf '\n##############################\n# bashbot modules starts here ...\n'
|
||||||
|
cat modules/*.sh | sed -e 's/^#\!\/bin\/bash.*//'
|
||||||
|
|
||||||
|
# last tail of commands.sh
|
||||||
|
printf '\n##############################\n# bashbot functions starts here ...\n\n'
|
||||||
|
sed -n '/\/commands.sh"/,$ p' bashbot.sh
|
||||||
|
|
||||||
|
} >>$$bashbot.sh
|
||||||
|
|
||||||
|
mv $$bashbot.sh bashbot.sh
|
||||||
|
chmod +x bashbot.sh
|
||||||
|
|
||||||
|
rm -rf modules
|
||||||
|
|
||||||
|
echo "Done!"
|
||||||
|
|
||||||
|
cd .. || exit 1
|
||||||
|
|
||||||
|
echo -e "\\nStandalone bashbot files are now availible in \"${DISTDIR}\":\\n"
|
||||||
|
ls -l "${DISTDIR}"*
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
|
#### $$VERSION$$ v0.80-dev2-2-g0c5e3dd
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
#
|
#
|
||||||
# Easy Versioning in git:
|
# Easy Versioning in git:
|
||||||
@ -36,8 +36,12 @@
|
|||||||
|
|
||||||
# magic to ensure that we're always inside the root of our application,
|
# magic to ensure that we're always inside the root of our application,
|
||||||
# no matter from which directory we'll run script
|
# no matter from which directory we'll run script
|
||||||
GIT_DIR=$(git rev-parse --git-dir)
|
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
|
||||||
cd "$GIT_DIR/.." || exit 1
|
if [ "$GIT_DIR" != "" ] ; then
|
||||||
|
cd "$GIT_DIR/.." || exit 1
|
||||||
|
else
|
||||||
|
echo "Sorry, no git repository $(pwd)" && exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
unset IFS
|
unset IFS
|
||||||
# set -f # if you are paranoid use set -f to disable globbing
|
# set -f # if you are paranoid use set -f to disable globbing
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# files: mycommands.sh.dist
|
# files: mycommands.sh.dist
|
||||||
# copy to mycommands.sh and add all your commands and functions here ...
|
# copy to mycommands.sh and add all your commands and functions here ...
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.80-dev2-1-g0b36bc5
|
#### $$VERSION$$ v0.80-dev2-2-g0c5e3dd
|
||||||
#
|
#
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
@ -117,7 +117,7 @@ else
|
|||||||
local image result sep="" count="1"
|
local image result sep="" count="1"
|
||||||
result="$(wget --user-agent 'Mozilla/5.0' -qO - "https://images.search.yahoo.com/search/images?p=$1" | sed 's/</\n</g' | grep "<img src=")"
|
result="$(wget --user-agent 'Mozilla/5.0' -qO - "https://images.search.yahoo.com/search/images?p=$1" | sed 's/</\n</g' | grep "<img src=")"
|
||||||
while read -r image; do
|
while read -r image; do
|
||||||
[ "$count" -gt "9" ] && break
|
[ "$count" -gt "20" ] && break
|
||||||
image="${image#* src=\'}"; image="${image%%&pid=*}"
|
image="${image#* src=\'}"; image="${image%%&pid=*}"
|
||||||
[[ "${image}" = *"src="* ]] && continue
|
[[ "${image}" = *"src="* ]] && continue
|
||||||
echo "${sep}"; inline_query_compose "$RANDOM" "photo" "${image}"; sep=","
|
echo "${sep}"; inline_query_compose "$RANDOM" "photo" "${image}"; sep=","
|
||||||
|
Loading…
Reference in New Issue
Block a user