mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2025-02-02 18:38:24 +00:00
Merge pull request #156 from dcoomber/develop
Documentation and variable name updates
This commit is contained in:
commit
5a3e68370d
@ -29,7 +29,7 @@
|
|||||||
# BASHBOT_EVENT_LOCATION location or venue received
|
# BASHBOT_EVENT_LOCATION location or venue received
|
||||||
# BASHBOT_EVENT_FILE file received
|
# BASHBOT_EVENT_FILE file received
|
||||||
#
|
#
|
||||||
# BAHSBOT_EVENT_TIMER this event is a bit special as it fires every Minute
|
# BASHBOT_EVENT_TIMER this event is a bit special as it fires every Minute
|
||||||
# and has 3 meanings: oneshot, every time, every X minutes.
|
# and has 3 meanings: oneshot, every time, every X minutes.
|
||||||
#
|
#
|
||||||
# all global variables and functions can be used in registered functions.
|
# all global variables and functions can be used in registered functions.
|
||||||
|
@ -17,14 +17,13 @@
|
|||||||
|
|
||||||
# save default values
|
# save default values
|
||||||
TERM="" # disable bashbot clear and color output
|
TERM="" # disable bashbot clear and color output
|
||||||
runas="nobody"
|
|
||||||
runcmd="echo Dry run:" # not activated until you edit lines below
|
runcmd="echo Dry run:" # not activated until you edit lines below
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Configuration Section
|
# Configuration Section
|
||||||
|
|
||||||
# edit the next line to fit the user you want to run bashbot, e.g. nobody:
|
# edit the next line to fit the user you want to run bashbot, e.g. nobody:
|
||||||
# runas="nobody"
|
runas="nobody"
|
||||||
|
|
||||||
# uncomment one of the following lines to fit your system
|
# uncomment one of the following lines to fit your system
|
||||||
# runcmd="su $runas -s /bin/bash -c " # runasuser with *su*
|
# runcmd="su $runas -s /bin/bash -c " # runasuser with *su*
|
||||||
@ -81,4 +80,3 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
exit $RETVAL
|
exit $RETVAL
|
||||||
|
|
||||||
|
146
bashbot.sh
146
bashbot.sh
@ -21,7 +21,7 @@
|
|||||||
# - 4 unknown command
|
# - 4 unknown command
|
||||||
# - 5 cannot connect to telegram bot
|
# - 5 cannot connect to telegram bot
|
||||||
# - 6 mandatory module not found
|
# - 6 mandatory module not found
|
||||||
# - 6 can't get bottoken
|
# - 7 can't get bottoken
|
||||||
# - 10 not bash!
|
# - 10 not bash!
|
||||||
# shellcheck disable=SC2140,SC2031,SC2120,SC1091
|
# shellcheck disable=SC2140,SC2031,SC2120,SC1091
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ fi
|
|||||||
ADDONDIR="${BASHBOT_ETC:-.}/addons"
|
ADDONDIR="${BASHBOT_ETC:-.}/addons"
|
||||||
RUNUSER="${USER}" # USER is overwritten by bashbot array :-(, save original
|
RUNUSER="${USER}" # USER is overwritten by bashbot array :-(, save original
|
||||||
|
|
||||||
# OK everything setup, lest start
|
# OK everything setup, lets start
|
||||||
if [[ -z "${SOURCE}" && -z "$BASHBOT_HOME" ]] && ! cd "${RUNDIR}" ; then
|
if [[ -z "${SOURCE}" && -z "$BASHBOT_HOME" ]] && ! cd "${RUNDIR}" ; then
|
||||||
echo -e "${RED}ERROR: Can't change to ${RUNDIR} ...${NC}"
|
echo -e "${RED}ERROR: Can't change to ${RUNDIR} ...${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
@ -190,7 +190,7 @@ if [ -z "${BOTTOKEN}" ]; then
|
|||||||
[ -n "${token}" ] && printf '["bottoken"]\t"%s"\n' "${token}" >> "${BOTCONFIG}.jssh"
|
[ -n "${token}" ] && printf '["bottoken"]\t"%s"\n' "${token}" >> "${BOTCONFIG}.jssh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# no boteadmin, setup botadmin
|
# no botadmin, setup botadmin
|
||||||
if [ -z "$(getConfigKey "botadmin")" ]; then
|
if [ -z "$(getConfigKey "botadmin")" ]; then
|
||||||
# convert old admin
|
# convert old admin
|
||||||
if [ -r "${BOTADMIN}" ]; then
|
if [ -r "${BOTADMIN}" ]; then
|
||||||
@ -250,16 +250,16 @@ debug_checks "start SOURCE=${SOURCE:-no}" "$@"
|
|||||||
if [ -z "${BOTTOKEN}" ]; then
|
if [ -z "${BOTTOKEN}" ]; then
|
||||||
BOTTOKEN="$(getConfigKey "bottoken")"
|
BOTTOKEN="$(getConfigKey "bottoken")"
|
||||||
if [ -z "${BOTTOKEN}" ]; then
|
if [ -z "${BOTTOKEN}" ]; then
|
||||||
BOTERROR="Warning: can't get bot token, try to recover working config"
|
BOTERROR="Warning: can't get bot token, try to recover working config"
|
||||||
echo -e "${ORANGE}${BOTERROR}${NC}"
|
echo -e "${ORANGE}${BOTERROR}${NC}"
|
||||||
if [ -r "${BOTCONFIG}.jssh.ok" ]; then
|
if [ -r "${BOTCONFIG}.jssh.ok" ]; then
|
||||||
log_error "${BOTERROR}"
|
log_error "${BOTERROR}"
|
||||||
cp "${BOTCONFIG}.jssh.ok" "${BOTCONFIG}.jssh"
|
cp "${BOTCONFIG}.jssh.ok" "${BOTCONFIG}.jssh"
|
||||||
BOTTOKEN="$(getConfigKey "bottoken")"
|
BOTTOKEN="$(getConfigKey "bottoken")"
|
||||||
else
|
else
|
||||||
echo -e "${RED}Error: Missing bot token! remove ${BOTCONFIG}.jssh and run \"bashbot.sh init\" may fix it.${NC}"
|
echo -e "${RED}Error: Missing bot token! remove ${BOTCONFIG}.jssh and run \"bashbot.sh init\" may fix it.${NC}"
|
||||||
exit 7
|
exit 7
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -268,12 +268,12 @@ fi
|
|||||||
if ! check_token "${BOTTOKEN}"; then
|
if ! check_token "${BOTTOKEN}"; then
|
||||||
echo -e "${ORANGE}Warning: your bottoken may incorrect. it should have the following format:${NC}"
|
echo -e "${ORANGE}Warning: your bottoken may incorrect. it should have the following format:${NC}"
|
||||||
echo -e "${GREY}123456789${RED}:${GREY}Aa-Zz_0Aa-Zz_1Aa-Zz_2Aa-Zz_3Aa-Zz_4${ORANGE} => ${NC}\c"
|
echo -e "${GREY}123456789${RED}:${GREY}Aa-Zz_0Aa-Zz_1Aa-Zz_2Aa-Zz_3Aa-Zz_4${ORANGE} => ${NC}\c"
|
||||||
echo -e "${GREY}8-10 digits${RED}:${GREY}35 alnum characters + '_-'${NC}"
|
echo -e "${GREY}8-10 digits${RED}:${GREY}35 alphanumeric characters + '_-'${NC}"
|
||||||
echo -e "${ORANGE}Your current token is: '${GREY}^$(cat -ve <<<"${BOTTOKEN//:/${RED}:${GREY}}")${ORANGE}'${NC}"
|
echo -e "${ORANGE}Your current token is: '${GREY}^$(cat -ve <<<"${BOTTOKEN//:/${RED}:${GREY}}")${ORANGE}'${NC}"
|
||||||
[[ ! "${BOTTOKEN}" =~ ^[0-9]{8,10}: ]] &&\
|
[[ ! "${BOTTOKEN}" =~ ^[0-9]{8,10}: ]] &&\
|
||||||
echo -e "${ORANGE}Possible problem in the digits part, len is $(($(wc -c <<<"${BOTTOKEN%:*}")-1))${NC}"
|
echo -e "${ORANGE}Possible problem in the digits part, len is $(($(wc -c <<<"${BOTTOKEN%:*}")-1))${NC}"
|
||||||
[[ ! "${BOTTOKEN}" =~ :[a-zA-Z0-9_-]{35}$ ]] &&\
|
[[ ! "${BOTTOKEN}" =~ :[a-zA-Z0-9_-]{35}$ ]] &&\
|
||||||
echo -e "${ORANGE}Posilbe problem in the charatcers part, len is $(($(wc -c <<<"${BOTTOKEN#*:}")-1))${NC}"
|
echo -e "${ORANGE}Possible problem in the characters part, len is $(($(wc -c <<<"${BOTTOKEN#*:}")-1))${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ export res CAPTION
|
|||||||
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# read commamds file if we are not sourced
|
# read commands file if we are not sourced
|
||||||
COMMANDS="${BASHBOT_ETC:-.}/commands.sh"
|
COMMANDS="${BASHBOT_ETC:-.}/commands.sh"
|
||||||
if [ -z "${SOURCE}" ]; then
|
if [ -z "${SOURCE}" ]; then
|
||||||
if [ ! -f "${COMMANDS}" ] || [ ! -r "${COMMANDS}" ]; then
|
if [ ! -f "${COMMANDS}" ] || [ ! -r "${COMMANDS}" ]; then
|
||||||
@ -350,14 +350,14 @@ procname(){
|
|||||||
printf '%s\n' "$2${ME}_$1"
|
printf '%s\n' "$2${ME}_$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# $1 string to search for proramm incl. parameters
|
# $1 string to search for programme incl. parameters
|
||||||
# returns a list of PIDs of all current bot proceeses matching $1
|
# returns a list of PIDs of all current bot processes matching $1
|
||||||
proclist() {
|
proclist() {
|
||||||
# shellcheck disable=SC2009
|
# shellcheck disable=SC2009
|
||||||
ps -fu "${UID}" | grep -F "$1" | grep -v ' grep'| grep -F "${ME}" | sed 's/\s\+/\t/g' | cut -f 2
|
ps -fu "${UID}" | grep -F "$1" | grep -v ' grep'| grep -F "${ME}" | sed 's/\s\+/\t/g' | cut -f 2
|
||||||
}
|
}
|
||||||
|
|
||||||
# $1 string to search for proramm to kill
|
# $1 string to search for programme to kill
|
||||||
killallproc() {
|
killallproc() {
|
||||||
local procid; procid="$(proclist "$1")"
|
local procid; procid="$(proclist "$1")"
|
||||||
if [ -n "${procid}" ] ; then
|
if [ -n "${procid}" ] ; then
|
||||||
@ -372,7 +372,7 @@ killallproc() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# $ chat $2 mesgid $3 nolog
|
# $ chat $2 msg_id $3 nolog
|
||||||
declare -xr DELETE_URL=$URL'/deleteMessage'
|
declare -xr DELETE_URL=$URL'/deleteMessage'
|
||||||
delete_message() {
|
delete_message() {
|
||||||
[ -z "$3" ] && printf "%s: Delete Message CHAT=%s MSG_ID=%s\n" "$(date)" "${1}" "${2}" >>"${UPDATELOG}"
|
[ -z "$3" ] && printf "%s: Delete Message CHAT=%s MSG_ID=%s\n" "$(date)" "${1}" "${2}" >>"${UPDATELOG}"
|
||||||
@ -410,7 +410,7 @@ if [ -z "${BASHBOT_WGET}" ] && _exists curl ; then
|
|||||||
sendJsonResult "${res}" "sendJson (curl)" "$@"
|
sendJsonResult "${res}" "sendJson (curl)" "$@"
|
||||||
[ -n "${BASHBOT_EVENT_SEND[*]}" ] && event_send "send" "${@}" &
|
[ -n "${BASHBOT_EVENT_SEND[*]}" ] && event_send "send" "${@}" &
|
||||||
}
|
}
|
||||||
#$1 Chat, $2 what , $3 file, $4 URL, $5 caption
|
#$1 Chat, $2 what, $3 file, $4 URL, $5 caption
|
||||||
sendUpload() {
|
sendUpload() {
|
||||||
[ "$#" -lt 4 ] && return
|
[ "$#" -lt 4 ] && return
|
||||||
if [ -n "$5" ]; then
|
if [ -n "$5" ]; then
|
||||||
@ -492,13 +492,13 @@ sendJsonResult(){
|
|||||||
else
|
else
|
||||||
# oops something went wrong!
|
# oops something went wrong!
|
||||||
if [ "${res}" != "" ]; then
|
if [ "${res}" != "" ]; then
|
||||||
BOTSENT[ERROR]="$(JsonGetValue '"error_code"' <<< "${1}")"
|
BOTSENT[ERROR]="$(JsonGetValue '"error_code"' <<< "${1}")"
|
||||||
BOTSENT[DESCRIPTION]="$(JsonGetString '"description"' <<< "${1}")"
|
BOTSENT[DESCRIPTION]="$(JsonGetString '"description"' <<< "${1}")"
|
||||||
BOTSENT[RETRY]="$(JsonGetValue '"parameters","retry_after"' <<< "${1}")"
|
BOTSENT[RETRY]="$(JsonGetValue '"parameters","retry_after"' <<< "${1}")"
|
||||||
else
|
else
|
||||||
BOTSENT[OK]="false"
|
BOTSENT[OK]="false"
|
||||||
BOTSENT[ERROR]="999"
|
BOTSENT[ERROR]="999"
|
||||||
BOTSENT[DESCRIPTION]="Send to telegram not possible, timeout/broken/no connection"
|
BOTSENT[DESCRIPTION]="Send to telegram not possible, timeout/broken/no connection"
|
||||||
fi
|
fi
|
||||||
# log error
|
# log error
|
||||||
[[ "${BOTSENT[ERROR]}" = "400" && "${BOTSENT[DESCRIPTION]}" == *"starting at byte offset"* ]] &&\
|
[[ "${BOTSENT[ERROR]}" = "400" && "${BOTSENT[DESCRIPTION]}" == *"starting at byte offset"* ]] &&\
|
||||||
@ -509,36 +509,36 @@ sendJsonResult(){
|
|||||||
[ -n "${BASHBOT_RETRY}${BASHBOT_WGET}" ] && return
|
[ -n "${BASHBOT_RETRY}${BASHBOT_WGET}" ] && return
|
||||||
|
|
||||||
# OK, we can retry sendJson, let's see what's failed
|
# OK, we can retry sendJson, let's see what's failed
|
||||||
# throttled, telegram say we send to much messages
|
# throttled, telegram say we send too many messages
|
||||||
if [ -n "${BOTSENT[RETRY]}" ]; then
|
if [ -n "${BOTSENT[RETRY]}" ]; then
|
||||||
BASHBOT_RETRY="$(( ++BOTSENT[RETRY] ))"
|
BASHBOT_RETRY="$(( ++BOTSENT[RETRY] ))"
|
||||||
printf "Retry %s in %s seconds ...\n" "${2}" "${BASHBOT_RETRY}"
|
printf "Retry %s in %s seconds ...\n" "${2}" "${BASHBOT_RETRY}"
|
||||||
sendJsonRetry "${2}" "${BASHBOT_RETRY}" "${@:3}"
|
sendJsonRetry "${2}" "${BASHBOT_RETRY}" "${@:3}"
|
||||||
unset BASHBOT_RETRY
|
unset BASHBOT_RETRY
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
# timeout, failed connection or blocked
|
# timeout, failed connection or blocked
|
||||||
if [ "${BOTSENT[ERROR]}" == "999" ];then
|
if [ "${BOTSENT[ERROR]}" == "999" ];then
|
||||||
# check if default curl and args are OK
|
# check if default curl and args are OK
|
||||||
if ! curl -sL -k -m 2 "${URL}" >/dev/null 2>&1 ; then
|
if ! curl -sL -k -m 2 "${URL}" >/dev/null 2>&1 ; then
|
||||||
printf "%s: BASHBOT IP Address seems blocked!\n" "$(date)"
|
printf "%s: BASHBOT IP Address seems blocked!\n" "$(date)"
|
||||||
# user provided function to recover or notify block
|
# user provided function to recover or notify block
|
||||||
if _exec_if_function bashbotBlockRecover; then
|
if _exec_if_function bashbotBlockRecover; then
|
||||||
BASHBOT_RETRY="2"
|
BASHBOT_RETRY="2"
|
||||||
printf "bashbotBlockRecover returned true, retry %s ...\n" "${2}"
|
printf "bashbotBlockRecover returned true, retry %s ...\n" "${2}"
|
||||||
sendJsonRetry "${2}" "${BASHBOT_RETRY}" "${@:3}"
|
sendJsonRetry "${2}" "${BASHBOT_RETRY}" "${@:3}"
|
||||||
unset BASHBOT_RETRY
|
unset BASHBOT_RETRY
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
# are not blocked, default curl and args are working
|
# are not blocked, default curl and args are working
|
||||||
if [ -n "${BASHBOT_CURL_ARGS}" ] || [ "${BASHBOT_CURL}" != "curl" ]; then
|
if [ -n "${BASHBOT_CURL_ARGS}" ] || [ "${BASHBOT_CURL}" != "curl" ]; then
|
||||||
printf "Problem with \"%s %s\"? retry %s with default config ...\n"\
|
printf "Problem with \"%s %s\"? retry %s with default config ...\n"\
|
||||||
"${BASHBOT_CURL}" "${BASHBOT_CURL_ARGS}" "${2}"
|
"${BASHBOT_CURL}" "${BASHBOT_CURL_ARGS}" "${2}"
|
||||||
BASHBOT_RETRY="2"; BASHBOT_CURL="curl"; BASHBOT_CURL_ARGS=""
|
BASHBOT_RETRY="2"; BASHBOT_CURL="curl"; BASHBOT_CURL_ARGS=""
|
||||||
sendJsonRetry "${2}" "${BASHBOT_RETRY}" "${@:3}"
|
sendJsonRetry "${2}" "${BASHBOT_RETRY}" "${@:3}"
|
||||||
unset BASHBOT_RETRY
|
unset BASHBOT_RETRY
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
} >>"${ERRORLOG}"
|
} >>"${ERRORLOG}"
|
||||||
@ -570,15 +570,15 @@ getBotName() {
|
|||||||
# pure bash implementation, done by KayM (@gnadelwartz)
|
# pure bash implementation, done by KayM (@gnadelwartz)
|
||||||
# see https://stackoverflow.com/a/55666449/9381171
|
# see https://stackoverflow.com/a/55666449/9381171
|
||||||
JsonDecode() {
|
JsonDecode() {
|
||||||
local out="$1" remain="" U=""
|
local out="$1" remain="" U=""
|
||||||
local regexp='(.*)\\u[dD]([0-9a-fA-F]{3})\\u[dD]([0-9a-fA-F]{3})(.*)'
|
local regexp='(.*)\\u[dD]([0-9a-fA-F]{3})\\u[dD]([0-9a-fA-F]{3})(.*)'
|
||||||
while [[ "${out}" =~ $regexp ]] ; do
|
while [[ "${out}" =~ $regexp ]] ; do
|
||||||
U=$(( ( (0xd${BASH_REMATCH[2]} & 0x3ff) <<10 ) | ( 0xd${BASH_REMATCH[3]} & 0x3ff ) + 0x10000 ))
|
U=$(( ( (0xd${BASH_REMATCH[2]} & 0x3ff) <<10 ) | ( 0xd${BASH_REMATCH[3]} & 0x3ff ) + 0x10000 ))
|
||||||
remain="$(printf '\\U%8.8x' "${U}")${BASH_REMATCH[4]}${remain}"
|
remain="$(printf '\\U%8.8x' "${U}")${BASH_REMATCH[4]}${remain}"
|
||||||
out="${BASH_REMATCH[1]}"
|
out="${BASH_REMATCH[1]}"
|
||||||
done
|
done
|
||||||
# this echo must stay for correct decoding!
|
# this echo must stay for correct decoding!
|
||||||
echo -e "${out}${remain}"
|
echo -e "${out}${remain}"
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonGetString() {
|
JsonGetString() {
|
||||||
@ -608,7 +608,7 @@ process_client() {
|
|||||||
# log message on debug
|
# log message on debug
|
||||||
[[ -n "${debug}" ]] && printf "\n%s: New Message ==========\n%s\n" "$(date)" "$UPDATE" >>"${LOGDIR}/MESSAGE.log"
|
[[ -n "${debug}" ]] && printf "\n%s: New Message ==========\n%s\n" "$(date)" "$UPDATE" >>"${LOGDIR}/MESSAGE.log"
|
||||||
|
|
||||||
# check for uers / groups to ignore
|
# check for users / groups to ignore
|
||||||
jssh_updateArray_async "BASHBOTBLOCKED" "${BLOCKEDFILE}"
|
jssh_updateArray_async "BASHBOTBLOCKED" "${BLOCKEDFILE}"
|
||||||
[ -n "${USER[ID]}" ] && [[ -n "${BASHBOTBLOCKED[${USER[ID]}]}" || -n "${BASHBOTBLOCKED[${CHAT[ID]}]}" ]] && return
|
[ -n "${USER[ID]}" ] && [[ -n "${BASHBOTBLOCKED[${USER[ID]}]}" || -n "${BASHBOTBLOCKED[${CHAT[ID]}]}" ]] && return
|
||||||
|
|
||||||
@ -796,7 +796,7 @@ process_message() {
|
|||||||
MESSAGE[0]+="$(JsonDecode "${UPD["result",${num},"message","text"]}" | sed 's|\\/|/|g')"
|
MESSAGE[0]+="$(JsonDecode "${UPD["result",${num},"message","text"]}" | sed 's|\\/|/|g')"
|
||||||
MESSAGE[ID]="${UPD["result",${num},"message","message_id"]}"
|
MESSAGE[ID]="${UPD["result",${num},"message","message_id"]}"
|
||||||
|
|
||||||
# Chat ID is now parsed when update isreceived
|
# Chat ID is now parsed when update is received
|
||||||
CHAT[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","chat","last_name"]}")"
|
CHAT[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","chat","last_name"]}")"
|
||||||
CHAT[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"message","chat","first_name"]}")"
|
CHAT[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"message","chat","first_name"]}")"
|
||||||
CHAT[USERNAME]="$(JsonDecode "${UPD["result",${num},"message","chat","username"]}")"
|
CHAT[USERNAME]="$(JsonDecode "${UPD["result",${num},"message","chat","username"]}")"
|
||||||
@ -806,7 +806,7 @@ process_message() {
|
|||||||
CHAT[TYPE]="$(JsonDecode "${UPD["result",${num},"message","chat","type"]}")"
|
CHAT[TYPE]="$(JsonDecode "${UPD["result",${num},"message","chat","type"]}")"
|
||||||
CHAT[ALL_ADMIN]="${UPD["result",${num},"message","chat","all_members_are_administrators"]}"
|
CHAT[ALL_ADMIN]="${UPD["result",${num},"message","chat","all_members_are_administrators"]}"
|
||||||
|
|
||||||
# user ID is now parsed when update isreceived
|
# user ID is now parsed when update is received
|
||||||
#USER[ID]="${UPD["result",${num},"message","from","id"]}"
|
#USER[ID]="${UPD["result",${num},"message","from","id"]}"
|
||||||
USER[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"message","from","first_name"]}")"
|
USER[FIRST_NAME]="$(JsonDecode "${UPD["result",${num},"message","from","first_name"]}")"
|
||||||
USER[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","from","last_name"]}")"
|
USER[LAST_NAME]="$(JsonDecode "${UPD["result",${num},"message","from","last_name"]}")"
|
||||||
@ -903,7 +903,7 @@ process_message() {
|
|||||||
[ -z "${MESSAGE[0]}" ] && [ -n "${SERVICE[PINNED]}" ] &&\
|
[ -z "${MESSAGE[0]}" ] && [ -n "${SERVICE[PINNED]}" ] &&\
|
||||||
MESSAGE[0]="/_new_pinned_message ${USER[ID]} ${PINNED[ID]} ${PINNED[MESSAGE]}"
|
MESSAGE[0]="/_new_pinned_message ${USER[ID]} ${PINNED[ID]} ${PINNED[MESSAGE]}"
|
||||||
fi
|
fi
|
||||||
# set SSERVICE to yes if a service message was received
|
# set SERVICE to yes if a service message was received
|
||||||
[[ "${SERVICE[*]}" =~ ^[[:blank:]]*$ ]] || SERVICE[0]="yes"
|
[[ "${SERVICE[*]}" =~ ^[[:blank:]]*$ ]] || SERVICE[0]="yes"
|
||||||
|
|
||||||
# split message in command and args
|
# split message in command and args
|
||||||
@ -928,7 +928,7 @@ start_bot() {
|
|||||||
[[ "${1}" == *"debug" ]] && exec &>>"${DEBUGLOG}"
|
[[ "${1}" == *"debug" ]] && exec &>>"${DEBUGLOG}"
|
||||||
printf "%s\n" "${DEBUGMSG}"; DEBUGMSG="${1}"
|
printf "%s\n" "${DEBUGMSG}"; DEBUGMSG="${1}"
|
||||||
[[ "${DEBUGMSG}" == "xdebug"* ]] && set -x
|
[[ "${DEBUGMSG}" == "xdebug"* ]] && set -x
|
||||||
#cleaup old pipes and empty logfiles
|
# cleaup old pipes and empty logfiles
|
||||||
find "${DATADIR}" -type p -delete
|
find "${DATADIR}" -type p -delete
|
||||||
find "${DATADIR}" -size 0 -name "*.log" -delete
|
find "${DATADIR}" -size 0 -name "*.log" -delete
|
||||||
# load addons on startup
|
# load addons on startup
|
||||||
@ -964,7 +964,7 @@ start_bot() {
|
|||||||
sleep "$(_round_float "${nextsleep}e-3" "1")"
|
sleep "$(_round_float "${nextsleep}e-3" "1")"
|
||||||
# get next update
|
# get next update
|
||||||
UPDATE="$(getJson "$UPD_URL$OFFSET" "nolog" 2>/dev/null | "${JSONSHFILE}" -s -b -n 2>/dev/null | iconv -f utf-8 -t utf-8 -c)"
|
UPDATE="$(getJson "$UPD_URL$OFFSET" "nolog" 2>/dev/null | "${JSONSHFILE}" -s -b -n 2>/dev/null | iconv -f utf-8 -t utf-8 -c)"
|
||||||
# did we ge an responsn0r
|
# did we get an response?
|
||||||
if [ -n "${UPDATE}" ]; then
|
if [ -n "${UPDATE}" ]; then
|
||||||
# we got something, do processing
|
# we got something, do processing
|
||||||
[ "${OFFSET}" = "-999" ] && [ "${nextsleep}" -gt "$((maxsleep*2))" ] &&\
|
[ "${OFFSET}" = "-999" ] && [ "${nextsleep}" -gt "$((maxsleep*2))" ] &&\
|
||||||
@ -981,7 +981,7 @@ start_bot() {
|
|||||||
process_updates "${DEBUGMSG}"
|
process_updates "${DEBUGMSG}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# ups, something bad happened, wait maxsleep*10
|
# oops, something bad happened, wait maxsleep*10
|
||||||
(( nextsleep=nextsleep*2 , nextsleep= nextsleep>maxsleep*10 ?maxsleep*10:nextsleep ))
|
(( nextsleep=nextsleep*2 , nextsleep= nextsleep>maxsleep*10 ?maxsleep*10:nextsleep ))
|
||||||
[ "${OFFSET}" = "-999" ] &&\
|
[ "${OFFSET}" = "-999" ] &&\
|
||||||
log_error "Repeated timeout/broken/no connection on telegram update, sleep $(_round_float "${nextsleep}e-3")s"
|
log_error "Repeated timeout/broken/no connection on telegram update, sleep $(_round_float "${nextsleep}e-3")s"
|
||||||
@ -1017,7 +1017,7 @@ bot_init() {
|
|||||||
done
|
done
|
||||||
echo "Done."
|
echo "Done."
|
||||||
fi
|
fi
|
||||||
#setup bashbot
|
# setup bashbot
|
||||||
[[ "${UID}" -eq "0" ]] && RUNUSER="nobody"
|
[[ "${UID}" -eq "0" ]] && RUNUSER="nobody"
|
||||||
echo -n "Enter User to run bashbot [$RUNUSER]: "
|
echo -n "Enter User to run bashbot [$RUNUSER]: "
|
||||||
read -r TOUSER
|
read -r TOUSER
|
||||||
@ -1081,11 +1081,11 @@ if [ -z "${SOURCE}" ]; then
|
|||||||
##############
|
##############
|
||||||
# internal options only for use from bashbot and developers
|
# internal options only for use from bashbot and developers
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
# update botname botname when starting only
|
# update botname when starting only
|
||||||
"botname"|"start"*)
|
"botname"|"start"*)
|
||||||
ME="$(getBotName)"
|
ME="$(getBotName)"
|
||||||
if [ -n "${ME}" ]; then
|
if [ -n "${ME}" ]; then
|
||||||
# ok we have a connection an got botname, save it
|
# ok we have a connection and got botname, save it
|
||||||
[ -n "${CLEAR}" ] && echo -e "${GREY}Bottoken is valid ...${NC}"
|
[ -n "${CLEAR}" ] && echo -e "${GREY}Bottoken is valid ...${NC}"
|
||||||
jssh_updateKeyDB "botname" "${ME}" "${BOTCONFIG}"
|
jssh_updateKeyDB "botname" "${ME}" "${BOTCONFIG}"
|
||||||
rm -f "${BOTCONFIG}.jssh.flock"
|
rm -f "${BOTCONFIG}.jssh.flock"
|
||||||
@ -1115,7 +1115,7 @@ if [ -z "${SOURCE}" ]; then
|
|||||||
debug_checks "end outproc" "$@"
|
debug_checks "end outproc" "$@"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
# finally starts the read update loop, internal use only1
|
# finally starts the read update loop, internal use only1
|
||||||
"startbot" )
|
"startbot" )
|
||||||
start_bot "$2"
|
start_bot "$2"
|
||||||
debug_checks "end startbot" "$@"
|
debug_checks "end startbot" "$@"
|
||||||
@ -1127,7 +1127,7 @@ if [ -z "${SOURCE}" ]; then
|
|||||||
debug_checks "end init" "$@"
|
debug_checks "end init" "$@"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
# print usage sats
|
# print usage stats
|
||||||
"count") echo -e "${RED}Command ${GREY}count${RED} is deprecated, use ${GREY}stats{$RED}instead.${NC}";&
|
"count") echo -e "${RED}Command ${GREY}count${RED} is deprecated, use ${GREY}stats{$RED}instead.${NC}";&
|
||||||
"stats")
|
"stats")
|
||||||
ME="$(getConfigKey "botname")"
|
ME="$(getConfigKey "botname")"
|
||||||
@ -1163,7 +1163,7 @@ if [ -z "${SOURCE}" ]; then
|
|||||||
debug_checks "end $1" "$@"
|
debug_checks "end $1" "$@"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
# sedn message to all users
|
# send message to all users
|
||||||
'broadcast')
|
'broadcast')
|
||||||
ME="$(getConfigKey "botname")"
|
ME="$(getConfigKey "botname")"
|
||||||
declare -A SENDALL
|
declare -A SENDALL
|
||||||
@ -1184,7 +1184,7 @@ if [ -z "${SOURCE}" ]; then
|
|||||||
debug_checks "end $1" "$@"
|
debug_checks "end $1" "$@"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
# does what is says
|
# does what it says
|
||||||
"status")
|
"status")
|
||||||
ME="$(getConfigKey "botname")"
|
ME="$(getConfigKey "botname")"
|
||||||
SESSION="${ME:-_bot}-startbot"
|
SESSION="${ME:-_bot}-startbot"
|
||||||
@ -1199,7 +1199,7 @@ if [ -z "${SOURCE}" ]; then
|
|||||||
debug_checks "end status" "$@"
|
debug_checks "end status" "$@"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# start bot as background jod and check if bot is running
|
# start bot as background job and check if bot is running
|
||||||
"start")
|
"start")
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
SESSION="${ME:-_bot}-startbot"
|
SESSION="${ME:-_bot}-startbot"
|
||||||
@ -1257,6 +1257,6 @@ if [ -z "${SOURCE}" ]; then
|
|||||||
# warn if root
|
# warn if root
|
||||||
if [[ "${UID}" -eq "0" ]] ; then
|
if [[ "${UID}" -eq "0" ]] ; then
|
||||||
echo -e "\\n${ORANGE}WARNING: ${SCRIPT} was started as ROOT (UID 0)!${NC}"
|
echo -e "\\n${ORANGE}WARNING: ${SCRIPT} was started as ROOT (UID 0)!${NC}"
|
||||||
echo -e "${ORANGE}You are at HIGH RISK when running a Telegram BOT with root privilegs!${NC}"
|
echo -e "${ORANGE}You are at HIGH RISK when running a Telegram BOT with root privileges!${NC}"
|
||||||
fi
|
fi
|
||||||
fi # end source
|
fi # end source
|
||||||
|
2
db.json
2
db.json
@ -14,7 +14,7 @@
|
|||||||
"ok":
|
"ok":
|
||||||
{
|
{
|
||||||
"ok":true,
|
"ok":true,
|
||||||
"description":"Ttest for ok"
|
"description":"Test for ok"
|
||||||
} ,
|
} ,
|
||||||
"getMe":
|
"getMe":
|
||||||
{
|
{
|
||||||
|
@ -107,8 +107,8 @@ by sourcing it:
|
|||||||
|
|
||||||
*usage:* . bashbot.sh source
|
*usage:* . bashbot.sh source
|
||||||
|
|
||||||
Before sourcing 'bahsbot.sh' for interactive and script use, you should export and set BASHBOT_HOME to bashbots installation dir,
|
Before sourcing 'bashbot.sh' for interactive and script use, you should export and set BASHBOT_HOME to bashbots installation dir,
|
||||||
e.g. '/usr/local/telegram-bot-bash'. see [Bashbot Environemt](#Bashbot-environment)
|
e.g. '/usr/local/telegram-bot-bash'. see [Bashbot Environment](#Bashbot-environment)
|
||||||
|
|
||||||
**Note:** *If you don't set BASHBOT_HOME bashbot will use the actual directory as NEW home directory
|
**Note:** *If you don't set BASHBOT_HOME bashbot will use the actual directory as NEW home directory
|
||||||
which means it will create all needed files and ask for bot token and botadmin if you are not in the real bot home!*
|
which means it will create all needed files and ask for bot token and botadmin if you are not in the real bot home!*
|
||||||
|
@ -15,7 +15,7 @@ To start with a clean/minimal bot copy ```mycommands.sh.clean``` to ```mycommand
|
|||||||
the message strings and place commands in the```case ... esac``` block of the function mycommands():
|
the message strings and place commands in the```case ... esac``` block of the function mycommands():
|
||||||
```bash
|
```bash
|
||||||
# file: mycommands.sh
|
# file: mycommands.sh
|
||||||
# your additional bahsbot commands
|
# your additional bashbot commands
|
||||||
|
|
||||||
# uncomment the following lines to overwrite info and help messages
|
# uncomment the following lines to overwrite info and help messages
|
||||||
bashbot_info='This is *MY* variant of _bashbot_, the Telegram bot written entirely in bash.
|
bashbot_info='This is *MY* variant of _bashbot_, the Telegram bot written entirely in bash.
|
||||||
|
@ -281,7 +281,7 @@ fi
|
|||||||
*See also [Chat Member](https://core.telegram.org/bots/api/#chatmember)*
|
*See also [Chat Member](https://core.telegram.org/bots/api/#chatmember)*
|
||||||
|
|
||||||
##### user_is_allowed
|
##### user_is_allowed
|
||||||
Bahsbot supports User Access Control, see [Advanced Usage](3_advanced.md)
|
Bashbot supports User Access Control, see [Advanced Usage](3_advanced.md)
|
||||||
|
|
||||||
*usage:* user_is_allowed "${USER[ID]}" "what" "${CHAT[ID]}"
|
*usage:* user_is_allowed "${USER[ID]}" "what" "${CHAT[ID]}"
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
## Notes for bashbot developers
|
## Notes for bashbot developers
|
||||||
This section is about help and best practices for new bashbot developers. The main focus on is creating new versions of bashbot, modules and addons, not on develop your individual bot. Nevertheless the information provided here should help your bot development also.
|
This section is about help and best practices for new bashbot developers. The main focus on is creating new versions of bashbot, modules and addons, not on develop your individual bot. Nevertheless the information provided here should help your bot development also.
|
||||||
|
|
||||||
If you want to provide fixes or new features [fork bashbot on githup](https://help.github.com/en/articles/fork-a-repo) and provide changes as [pull request on github](https://help.github.com/en/articles/creating-a-pull-request).
|
If you want to provide fixes or new features [fork bashbot on github](https://help.github.com/en/articles/fork-a-repo) and provide changes as [pull request on github](https://help.github.com/en/articles/creating-a-pull-request).
|
||||||
|
|
||||||
### Debugging Bashbot
|
### Debugging Bashbot
|
||||||
Usually all bashbot output is discarded.
|
Usually all bashbot output is discarded.
|
||||||
@ -31,13 +31,13 @@ you can the change the level of verbosity of the debug argument:
|
|||||||
to keep 'bashbot.sh' small, while extending functionality. In addition not every function is needed by all bots, so you can
|
to keep 'bashbot.sh' small, while extending functionality. In addition not every function is needed by all bots, so you can
|
||||||
disable modules, e.g. by rename the respective module file to 'module.sh.off'.
|
disable modules, e.g. by rename the respective module file to 'module.sh.off'.
|
||||||
|
|
||||||
Modules must use only functions provided by 'bahsbot.sh' or the module itself and should not depend on other modules or addons.
|
Modules must use only functions provided by 'bashbot.sh' or the module itself and should not depend on other modules or addons.
|
||||||
The only mandatory module is 'module/sendMessage.sh'.
|
The only mandatory module is 'module/sendMessage.sh'.
|
||||||
|
|
||||||
If a not mandatory module is used in 'bashbot.sh' or 'commands.sh', the use of ```_is_function``` or
|
If a not mandatory module is used in 'bashbot.sh' or 'commands.sh', the use of ```_is_function``` or
|
||||||
```_execute_if_function``` is mandatory to catch absence of the module.
|
```_execute_if_function``` is mandatory to catch absence of the module.
|
||||||
|
|
||||||
**Addons** resides in ```addons/*.sh.dist``` and are not endabled by default. To activate an addon rename it to end with '.sh', e.g. by
|
**Addons** resides in ```addons/*.sh.dist``` and are not enabled by default. To activate an addon rename it to end with '.sh', e.g. by
|
||||||
```cp addons/example.sh.dist addons/example.sh```.
|
```cp addons/example.sh.dist addons/example.sh```.
|
||||||
|
|
||||||
Addons must register themself to BASHBOT_EVENTS at startup, e.g. to call a function every time a message is received.
|
Addons must register themself to BASHBOT_EVENTS at startup, e.g. to call a function every time a message is received.
|
||||||
@ -115,7 +115,7 @@ To avoid wrong use of EVENT_SEND, e.g. fork bomb, event processing is suspended
|
|||||||
*Example:*
|
*Example:*
|
||||||
```bash
|
```bash
|
||||||
# register callback:
|
# register callback:
|
||||||
BAHSBOT_EVENT_SEND["example_log","1"]="example_log"
|
BASHBOT_EVENT_SEND["example_log","1"]="example_log"
|
||||||
EXAMPLE_LOG="${BASHBOT_ETC:-.}/addons/${EXAMPLE_ME}.log"
|
EXAMPLE_LOG="${BASHBOT_ETC:-.}/addons/${EXAMPLE_ME}.log"
|
||||||
|
|
||||||
# Note: do not call any send message functions from EVENT_SEND!
|
# Note: do not call any send message functions from EVENT_SEND!
|
||||||
@ -130,7 +130,7 @@ example_log(){
|
|||||||
|
|
||||||
Important: Bashbot timer tick is disabled by default and must be enabled by setting BASHBOT_START_TIMER to any value not zero.
|
Important: Bashbot timer tick is disabled by default and must be enabled by setting BASHBOT_START_TIMER to any value not zero.
|
||||||
|
|
||||||
* BAHSBOT_EVENT_TIMER executed every minute and can be used in 3 variants: oneshot, once a minute, every X minutes.
|
* BASHBOT_EVENT_TIMER executed every minute and can be used in 3 variants: oneshot, once a minute, every X minutes.
|
||||||
|
|
||||||
Registering to BASHBOT_EVENT_TIMER works similar as for message events, but you must add a timing argument to the name.
|
Registering to BASHBOT_EVENT_TIMER works similar as for message events, but you must add a timing argument to the name.
|
||||||
EVENT_TIMER is triggered every 60s and waits until the current running command is finished, so it's not exactly every
|
EVENT_TIMER is triggered every 60s and waits until the current running command is finished, so it's not exactly every
|
||||||
@ -139,7 +139,7 @@ minute, but once a minute.
|
|||||||
Every time EVENT_TIMER is triggered the variable "EVENT_TIMER" is increased. each callback is executed if ```EVENT_TIMER % time``` is '0' (true).
|
Every time EVENT_TIMER is triggered the variable "EVENT_TIMER" is increased. each callback is executed if ```EVENT_TIMER % time``` is '0' (true).
|
||||||
This means if you register an every 5 minutes callback first execution may < 5 Minutes, all subsequent executions are once every 5. Minute.
|
This means if you register an every 5 minutes callback first execution may < 5 Minutes, all subsequent executions are once every 5. Minute.
|
||||||
|
|
||||||
*usage:* BAHSBOT_EVENT_TIMER[ "name" , "time" ], where time is:
|
*usage:* BASHBOT_EVENT_TIMER[ "name" , "time" ], where time is:
|
||||||
|
|
||||||
* 0 ignored
|
* 0 ignored
|
||||||
* 1 execute once every minute
|
* 1 execute once every minute
|
||||||
@ -151,7 +151,7 @@ Note: If you want exact "in x minutes" use "EVENT_TIMER plus x" as time: ```-(EV
|
|||||||
*Example:*
|
*Example:*
|
||||||
```bash
|
```bash
|
||||||
# register callback:
|
# register callback:
|
||||||
BAHSBOT_EVENT_TIMER["example_every","1"]="example_everymin"
|
BASHBOT_EVENT_TIMER["example_every","1"]="example_everymin"
|
||||||
|
|
||||||
# function called every minute
|
# function called every minute
|
||||||
example_everymin() {
|
example_everymin() {
|
||||||
@ -160,13 +160,13 @@ example_everymin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# register other callback:
|
# register other callback:
|
||||||
BAHSBOT_EVENT_TIMER["example_every5","5"]="example_every5min"
|
BASHBOT_EVENT_TIMER["example_every5","5"]="example_every5min"
|
||||||
|
|
||||||
# execute once on the next 10 minutes since start "event"
|
# execute once on the next 10 minutes since start "event"
|
||||||
BAHSBOT_EVENT_TIMER["example_10min","-10"]="example_in10min"
|
BASHBOT_EVENT_TIMER["example_10min","-10"]="example_in10min"
|
||||||
|
|
||||||
# once in exact 10 minutes
|
# once in exact 10 minutes
|
||||||
BAHSBOT_EVENT_TIMER["example_10min","$(( (EVENT_TIMER+10) * -1 ))"]="example_in10min"
|
BASHBOT_EVENT_TIMER["example_10min","$(( (EVENT_TIMER+10) * -1 ))"]="example_in10min"
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ To create a new test run ```test/ADD-test-new.sh``` and answer the questions, it
|
|||||||
Each test consists of a script script named after ```p-name-test.sh``` *(where p is test pass 'a-z' and name the name
|
Each test consists of a script script named after ```p-name-test.sh``` *(where p is test pass 'a-z' and name the name
|
||||||
of your test)* and an optional dir ```p-name-test/``` *(script name minus '.sh')* for additional files.
|
of your test)* and an optional dir ```p-name-test/``` *(script name minus '.sh')* for additional files.
|
||||||
|
|
||||||
Tests with no dependency to other tests will run in pass 'a', tests which need an initialized bahsbot environment must run in pass 'd' or later.
|
Tests with no dependency to other tests will run in pass 'a', tests which need an initialized bashbot environment must run in pass 'd' or later.
|
||||||
A temporary test environment is created when 'ALL-tests.sh' starts and deleted after all tests are finished.
|
A temporary test environment is created when 'ALL-tests.sh' starts and deleted after all tests are finished.
|
||||||
|
|
||||||
The file ```ALL-tests.inc.sh``` must be included from all tests and provide the test environment as shell variables:
|
The file ```ALL-tests.inc.sh``` must be included from all tests and provide the test environment as shell variables:
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# copy to mycommands.sh and add all your commands an functions here ...
|
# copy to mycommands.sh and add all your commands an functions here ...
|
||||||
export res
|
export res
|
||||||
|
|
||||||
# your additional bahsbot commands ...
|
# your additional bashbot commands ...
|
||||||
mycommands() {
|
mycommands() {
|
||||||
|
|
||||||
case "$MESSAGE" in
|
case "$MESSAGE" in
|
||||||
|
@ -24,6 +24,7 @@ unset IFS
|
|||||||
# discard STDIN for background jobs!
|
# discard STDIN for background jobs!
|
||||||
cat >/dev/null &
|
cat >/dev/null &
|
||||||
|
|
||||||
|
# shellcheck source=examples/background-scripts/mycommands.sh
|
||||||
source "./mycommands.sh"
|
source "./mycommands.sh"
|
||||||
|
|
||||||
# check if $1 is a number
|
# check if $1 is a number
|
||||||
|
@ -24,6 +24,8 @@ cat >/dev/null &
|
|||||||
|
|
||||||
# watch for new files created by a trusted program
|
# watch for new files created by a trusted program
|
||||||
WATCHDIR="/my_trusted/dir_to_watch"
|
WATCHDIR="/my_trusted/dir_to_watch"
|
||||||
|
|
||||||
|
# shellcheck source=examples/background-scripts/mycommands.sh
|
||||||
source "./mycommands.sh"
|
source "./mycommands.sh"
|
||||||
|
|
||||||
# test your script and the remove ...
|
# test your script and the remove ...
|
||||||
@ -39,4 +41,3 @@ loop_callback() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
watch_dir_loop "$WATCHDIR"
|
watch_dir_loop "$WATCHDIR"
|
||||||
|
|
||||||
|
@ -19,11 +19,13 @@ export 'LANGUAGE=C.UTF-8'
|
|||||||
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
|
||||||
|
|
||||||
# discard STDIN for background jobs!
|
# shellcheck source=examples/background-scripts/mycommands.sh
|
||||||
cat >/dev/null &
|
cat >/dev/null &
|
||||||
|
|
||||||
# watch for new logfiles
|
# watch for new logfiles
|
||||||
WATCHDIR="/var/log"
|
WATCHDIR="/var/log"
|
||||||
|
|
||||||
|
# shellcheck disable=SC1091
|
||||||
source "./mycommands.sh"
|
source "./mycommands.sh"
|
||||||
|
|
||||||
# test your script and the remove ...
|
# test your script and the remove ...
|
||||||
|
@ -23,8 +23,8 @@ if true; then
|
|||||||
else
|
else
|
||||||
# alternative linux like locations
|
# alternative linux like locations
|
||||||
BINDIR="/usr/local/bin"
|
BINDIR="/usr/local/bin"
|
||||||
ETC="/etc/bahsbot"
|
ETC="/etc/bashbot"
|
||||||
VAR="/var/bahsbot"
|
VAR="/var/bashbot"
|
||||||
export BASHBOT_JSONSH="/usr/local/bin/JSON.sh"
|
export BASHBOT_JSONSH="/usr/local/bin/JSON.sh"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -206,7 +206,7 @@ else
|
|||||||
my_startup
|
my_startup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# your additional bahsbot commands
|
# your additional bashbot commands
|
||||||
# NOTE: command can have @botname attached, you must add * in case tests...
|
# NOTE: command can have @botname attached, you must add * in case tests...
|
||||||
mycommands() {
|
mycommands() {
|
||||||
# a service Message was received
|
# a service Message was received
|
||||||
|
@ -32,7 +32,7 @@ bashbot_help='*Available commands*:
|
|||||||
'
|
'
|
||||||
|
|
||||||
|
|
||||||
# your additional bahsbot commands
|
# your additional bashbot commands
|
||||||
# NOTE: command can have @botname attached, you must add * in case tests...
|
# NOTE: command can have @botname attached, you must add * in case tests...
|
||||||
mycommands() {
|
mycommands() {
|
||||||
local msg=""
|
local msg=""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user