mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-11-26 17:26:27 +00:00
rename tmp-bot-bash to data-bot-bash
This commit is contained in:
parent
aa938397f5
commit
ca73be8c41
13
bashbot.sh
13
bashbot.sh
@ -10,7 +10,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.70-dev2-10-gfa9e879
|
#### $$VERSION$$ v0.70-dev2-12-gaa93839
|
||||||
#
|
#
|
||||||
# Exit Codes:
|
# Exit Codes:
|
||||||
# - 0 sucess (hopefully)
|
# - 0 sucess (hopefully)
|
||||||
@ -36,7 +36,7 @@ RUNDIR="${BASHBOT_VAR:-${SCRIPTDIR}}"
|
|||||||
[ "${RUNDIR}" = "${SCRIPTDIR}" ] && SCRIPT="./$(basename "${SCRIPT}")"
|
[ "${RUNDIR}" = "${SCRIPTDIR}" ] && SCRIPT="./$(basename "${SCRIPT}")"
|
||||||
|
|
||||||
|
|
||||||
RUNUSER="${USER}" # USER is overwritten by bashbot array, $USER may not work later on...
|
RUNUSER="${USER}" # USER is overwritten by bashbot array
|
||||||
|
|
||||||
if [ "$1" != "source" ] && ! cd "${RUNDIR}" ; then
|
if [ "$1" != "source" ] && ! cd "${RUNDIR}" ; then
|
||||||
echo -e "${RED}ERROR: Can't change to ${RUNDIR} ...${NC}"
|
echo -e "${RED}ERROR: Can't change to ${RUNDIR} ...${NC}"
|
||||||
@ -93,7 +93,7 @@ if [ ! -f "${BOTACL}" ]; then
|
|||||||
echo "" >"${BOTACL}"
|
echo "" >"${BOTACL}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TMPDIR="${BASHBOT_VAR:-.}/tmp-bot-bash"
|
TMPDIR="${BASHBOT_VAR:-.}/data-bot-bash"
|
||||||
if [ ! -d "${TMPDIR}" ]; then
|
if [ ! -d "${TMPDIR}" ]; then
|
||||||
mkdir "${TMPDIR}"
|
mkdir "${TMPDIR}"
|
||||||
elif [ ! -w "${TMPDIR}" ]; then
|
elif [ ! -w "${TMPDIR}" ]; then
|
||||||
@ -155,7 +155,8 @@ GETMEMBER_URL=$URL'/getChatMember'
|
|||||||
FILE_URL='https://api.telegram.org/file/bot'$BOTTOKEN'/'
|
FILE_URL='https://api.telegram.org/file/bot'$BOTTOKEN'/'
|
||||||
UPD_URL=$URL'/getUpdates?offset='
|
UPD_URL=$URL'/getUpdates?offset='
|
||||||
GET_URL=$URL'/getFile'
|
GET_URL=$URL'/getFile'
|
||||||
OFFSET=0
|
|
||||||
|
unset USER
|
||||||
declare -A USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO
|
declare -A USER MESSAGE URLS CONTACT LOCATION CHAT FORWARD REPLYTO
|
||||||
|
|
||||||
|
|
||||||
@ -616,6 +617,7 @@ process_message() {
|
|||||||
|
|
||||||
# main get updates loop, should never terminate
|
# main get updates loop, should never terminate
|
||||||
start_bot() {
|
start_bot() {
|
||||||
|
local OFFSET=0
|
||||||
local mysleep="100" # ms
|
local mysleep="100" # ms
|
||||||
local addsleep="100"
|
local addsleep="100"
|
||||||
local maxsleep="$(( ${BASHBOT_SLEEP:-5000} + 100 ))"
|
local maxsleep="$(( ${BASHBOT_SLEEP:-5000} + 100 ))"
|
||||||
@ -643,6 +645,9 @@ start_bot() {
|
|||||||
|
|
||||||
# initialize bot environment, user and permissions
|
# initialize bot environment, user and permissions
|
||||||
bot_init() {
|
bot_init() {
|
||||||
|
# move tmpdir to datadir
|
||||||
|
local OLDTMP="${BASHBOT_VAR:-.}/tmp-bot-bash"
|
||||||
|
[ -d "${OLDTMP}" ] && { mv -n "${OLDTMP}/"* "${TMPDIR}"; rmdir "${OLDTMP}"; }
|
||||||
[[ "$(id -u)" -eq "0" ]] && RUNUSER="nobody"
|
[[ "$(id -u)" -eq "0" ]] && RUNUSER="nobody"
|
||||||
echo -n "Enter User to run basbot [$RUNUSER]: "
|
echo -n "Enter User to run basbot [$RUNUSER]: "
|
||||||
read -r TOUSER
|
read -r TOUSER
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ v0.70-dev2-10-gfa9e879
|
#### $$VERSION$$ v0.70-dev2-12-gaa93839
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ v0.70-dev2-10-gfa9e879
|
#### $$VERSION$$ v0.70-dev2-12-gaa93839
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
@ -26,8 +26,8 @@ echo "Check process_message ..."
|
|||||||
for i in 1 2
|
for i in 1 2
|
||||||
do
|
do
|
||||||
[ "${i}" = "1" ] && ! which python >/dev/null 2>&1 && continue
|
[ "${i}" = "1" ] && ! which python >/dev/null 2>&1 && continue
|
||||||
[ "${i}" = "1" ] && echo " ... JsonDecode Phyton" && unset BASHBOT_DECODE
|
[ "${i}" = "1" ] && echo " ... with JsonDecode Phyton" && unset BASHBOT_DECODE
|
||||||
[ "${i}" = "2" ] && echo " ... JsonDecode Bash" && export BASHBOT_DECODE="yes"
|
[ "${i}" = "2" ] && echo " ... with JsonDecode Bash" && export BASHBOT_DECODE="yes"
|
||||||
set -x
|
set -x
|
||||||
{ process_message "0"; set +x; } >>"${LOGFILE}" 2>&1;
|
{ process_message "0"; set +x; } >>"${LOGFILE}" 2>&1;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#### $$VERSION$$ v0.70-dev2-11-g8549727
|
#### $$VERSION$$ v0.70-dev2-12-gaa93839
|
||||||
|
|
||||||
# include common functions and definitions
|
# include common functions and definitions
|
||||||
# shellcheck source=test/ALL-tests.inc.sh
|
# shellcheck source=test/ALL-tests.inc.sh
|
||||||
@ -16,7 +16,7 @@ source "${TESTDIR}/bashbot.sh" source
|
|||||||
# start writing your tests here ...
|
# start writing your tests here ...
|
||||||
|
|
||||||
# first user asking for botadmin will botadmin
|
# first user asking for botadmin will botadmin
|
||||||
echo " test \"user_is_botadmin\" ..."
|
echo "Check \"user_is_botadmin\" ..."
|
||||||
|
|
||||||
echo '?' >"${ADMINFILE}" # auto mode
|
echo '?' >"${ADMINFILE}" # auto mode
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ fi
|
|||||||
echo "${SUCCESS}"
|
echo "${SUCCESS}"
|
||||||
|
|
||||||
# lets see If UAC works ...
|
# lets see If UAC works ...
|
||||||
echo " test \"user_is_allowed\" ..."
|
echo "Check \"user_is_allowed\" ..."
|
||||||
|
|
||||||
echo " ... with not rules"
|
echo " ... with not rules"
|
||||||
user_is_allowed "NOBOTADMIN" "ANYTHING" && exit 1 # should always fail because no rules exist
|
user_is_allowed "NOBOTADMIN" "ANYTHING" && exit 1 # should always fail because no rules exist
|
||||||
|
Loading…
Reference in New Issue
Block a user