From b454827109e246e8118e8469a9ddaf92296f4ae7 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Wed, 3 Mar 2021 13:40:51 +0100 Subject: [PATCH] bin: use BOTNAME BOTADMIN --- bashbot.sh | 2 +- bin/any_command.sh | 4 +- bin/bashbot_env.inc.sh | 93 ---------------------------------------- bin/bashbot_init.inc.sh | 2 +- bin/bashbot_stats.sh | 4 +- bin/delete_message.sh | 4 +- bin/edit_buttons.sh | 4 +- bin/edit_message.sh | 4 +- bin/kickban_user.sh | 2 +- bin/process_batch.sh | 4 +- bin/process_update.sh | 4 +- bin/promote_user.sh | 2 +- bin/send_broadcast.sh | 4 +- bin/send_buttons.sh | 4 +- bin/send_dice.sh | 4 +- bin/send_edit_message.sh | 1 - bin/send_file.sh | 4 +- bin/send_message.sh | 4 +- modules/background.sh | 2 +- modules/chatMember.sh | 2 +- 20 files changed, 30 insertions(+), 124 deletions(-) delete mode 100644 bin/bashbot_env.inc.sh delete mode 120000 bin/send_edit_message.sh diff --git a/bashbot.sh b/bashbot.sh index 182cdbc..71bcaa4 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb # 8 - curl/wget missing # 10 - not bash! # -#### $$VERSION$$ v1.45-dev-67-g53e936e +#### $$VERSION$$ v1.45-dev-68-ge6838d1 ################################################################## # are we running in a terminal? diff --git a/bin/any_command.sh b/bin/any_command.sh index 2b62f19..1e1373e 100755 --- a/bin/any_command.sh +++ b/bin/any_command.sh @@ -21,7 +21,7 @@ USAGE='any_command.sh [-h|--help] [--force|--reference] bot_command args ...' # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 30.01.2021 10:24 # -#### $$VERSION$$ v1.45-dev-7-ga9ed559 +#### $$VERSION$$ v1.45-dev-68-ge6838d1 #=============================================================================== #### @@ -68,7 +68,7 @@ fi # ready, do stuff here ----- COMMAND="$1" if [ "$2" == "BOTADMIN" ]; then - ARG1="${BOT_ADMIN}" + ARG1="${BOTADMIN}" else ARG1="$2" fi diff --git a/bin/bashbot_env.inc.sh b/bin/bashbot_env.inc.sh deleted file mode 100644 index d4b43b9..0000000 --- a/bin/bashbot_env.inc.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -#=============================================================================== -# -# FILE: bashbot_env.inc.sh -# -# USAGE: source bashbot_env.inc.sh [debug] -# -# DESCRIPTION: set bashbot environment for all scripts in this directory -# -# OPTIONS: $1 - will be forwarded ro bashbot, e.g. debug -# -# LICENSE: WTFPLv2 http://www.wtfpl.net/txt/copying/ -# AUTHOR: KayM (gnadelwartz), kay@rrr.de -# CREATED: 18.12.2020 12:27 -# -#### $$VERSION$$ v1.45-dev-67-g53e936e -#=============================================================================== - -############ -# set where your bashbot lives -export BASHBOT_HOME BASHBOT_ETC BASHBOT_VAR FILE_REGEX ME - -# default: one dir up -BASHBOT_HOME="$(cd "${BASH_SOURCE[0]%/*}/../" >/dev/null 2>&1 && pwd)" -[ "${BASHBOT_HOME}" = "" ] && BASHBOT_HOME="../" - -# set you own BASHBOT_HOME if different, e.g. -# BASHBOT_HOME="/usr/local/telegram-bot-bash" -BASHBOT_VAR="${BASHBOT_HOME}" -BASHBOT_ETC="${BASHBOT_HOME}" - -##### -# if files are not readable, eviroment is wrong or bashbot is not initialized - -# check for bashbot -if [ ! -r "${BASHBOT_HOME}/bashbot.sh" ]; then - printf "%s\n" "Bashbot.sh not found in \"${BASHBOT_HOME}\"" - exit 4 -fi - -dev=" Are we in dev or did you forget to run init?" -# check for botconfig.jssh readable -if [ ! -r "${BASHBOT_ETC}/botconfig.jssh" ]; then - printf "%s\n" "Bashbot config file in \"${BASHBOT_ETC}\" does not exist or is not readable. ${dev}" - exit 3 -fi -# check for count.jssh readable -if [ ! -r "${BASHBOT_VAR}/count.jssh" ]; then - printf "%s\n" "Bashbot count file in \"${BASHBOT_VAR}\" does not exist or is not readable. ${dev}" - exit 3 -fi - -# shellcheck disable=SC1090 -source "${BASHBOT_HOME}/bashbot.sh" source "$1" - -# overwrite bot FILE regex to BASHBOT_VAR -# change this to the location you want to allow file uploads from -UPLOADDIR="${BASHBOT_VAR%/bin*}" -FILE_REGEX="${UPLOADDIR}/.*" - -# get and check ADMIN and NAME -# shellcheck disable=SC2153 -BOT_ADMIN="${BOTADMIN}" -BOT_NAME="$(getConfigKey "botname")" -ME="${BOT_NAME}" -[[ -z "${BOT_ADMIN}" || "${BOT_ADMIN}" == "?" ]] && printf "%s\n" "${ORANGE}Warning: Botadmin not set, send bot command${NC} /start" -[[ -z "${BOT_NAME}" ]] && printf "%s\n" "${ORANGE}Warning: Botname not set, run bashbot.sh botname" - -# default webhook pipe -export WEBHOOK="${DATADIR}/webhook-fifo-${ME}" - - -# output command result or Telegram response -print_result() { jssh_printDB "BOTSENT" | sort -r; } -print_response() { jssh_printDB "UPD"; } - -# check and output help -print_help() { - case "$1" in - '') - printf "missing arguments\n" - ;& - "-h"*) - printf 'usage: %s\n' "${USAGE}" - exit 1 - ;; - '--h'*) - sed -n '/^#====/,/^#====/p' <"$0" - exit 1 - ;; - esac -} - diff --git a/bin/bashbot_init.inc.sh b/bin/bashbot_init.inc.sh index e12fc5a..7746e6f 100644 --- a/bin/bashbot_init.inc.sh +++ b/bin/bashbot_init.inc.sh @@ -11,7 +11,7 @@ # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 27.01.2021 13:42 # -#### $$VERSION$$ v1.45-dev-59-ga9ac7ea +#### $$VERSION$$ v1.45-dev-68-ge6838d1 #=============================================================================== # shellcheck disable=SC2059 diff --git a/bin/bashbot_stats.sh b/bin/bashbot_stats.sh index df23119..e111bfa 100755 --- a/bin/bashbot_stats.sh +++ b/bin/bashbot_stats.sh @@ -17,7 +17,7 @@ USAGE='bashbot_stats.sh [-h|--help] [debug]' # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 23.12.2020 20:34 # -#### $$VERSION$$ v1.40-0-gf9dab50 +#### $$VERSION$$ v1.45-dev-68-ge6838d1 #=============================================================================== # set bashbot environment @@ -27,7 +27,7 @@ source "${0%/*}/bashbot_env.inc.sh" "$1" #### # ready, do stuff here ----- -echo -e "${GREEN}Hi I'm ${BOT_NAME}.${NC}" +echo -e "${GREEN}Hi I'm ${BOTNAME}.${NC}" declare -A STATS jssh_readDB_async "STATS" "${COUNTFILE}" for MSG in ${!STATS[*]} diff --git a/bin/delete_message.sh b/bin/delete_message.sh index 8b26769..e5eab73 100755 --- a/bin/delete_message.sh +++ b/bin/delete_message.sh @@ -20,7 +20,7 @@ USAGE='delete_message.sh [-h|--help] "CHAT[ID]" "MESSAGE[ID]" [debug]' # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 03.01.2021 15:37 # -#### $$VERSION$$ v1.40-0-gf9dab50 +#### $$VERSION$$ v1.45-dev-68-ge6838d1 #=============================================================================== #### @@ -34,7 +34,7 @@ print_help "$1" #### # ready, do stuff here ----- if [ "$1" == "BOTADMIN" ]; then - CHAT="${BOT_ADMIN}" + CHAT="${BOTADMIN}" else CHAT="$1" fi diff --git a/bin/edit_buttons.sh b/bin/edit_buttons.sh index 0455d1c..62a63a2 100755 --- a/bin/edit_buttons.sh +++ b/bin/edit_buttons.sh @@ -26,7 +26,7 @@ USAGE='send_message.sh [-h|--help] "CHAT[ID]" "MESSAGE[ID]" "text|url" ...' # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 21.01.2021 08:10 # -#### $$VERSION$$ v1.40-0-gf9dab50 +#### $$VERSION$$ v1.45-dev-68-ge6838d1 #=============================================================================== #### @@ -40,7 +40,7 @@ print_help "$1" #### # ready, do stuff here ----- if [ "$1" == "BOTADMIN" ]; then - CHAT="${BOT_ADMIN}" + CHAT="${BOTADMIN}" else CHAT="$1" fi diff --git a/bin/edit_message.sh b/bin/edit_message.sh index dd9b766..7bd6119 100755 --- a/bin/edit_message.sh +++ b/bin/edit_message.sh @@ -23,7 +23,7 @@ USAGE='send_edit_message.sh [-h|--help] [format|caption] "CHAT[ID]" "MESSAGE[ID] # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 23.12.2020 16:52 # -#### $$VERSION$$ v1.40-0-gf9dab50 +#### $$VERSION$$ v1.45-dev-68-ge6838d1 #=============================================================================== #### @@ -55,7 +55,7 @@ print_help "$1" #### # ready, do stuff here ----- if [ "$1" == "BOTADMIN" ]; then - CHAT="${BOT_ADMIN}" + CHAT="${BOTADMIN}" else CHAT="$1" fi diff --git a/bin/kickban_user.sh b/bin/kickban_user.sh index cb31df1..49b3633 100755 --- a/bin/kickban_user.sh +++ b/bin/kickban_user.sh @@ -20,7 +20,7 @@ USAGE='kickban_user.sh [-h|--help] [-u|--unban] "CHAT[ID]" "USER[ID]" [debug]' # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 25.01.2021 20:34 # -#### $$VERSION$$ v1.40-0-gf9dab50 +#### $$VERSION$$ v1.45-dev-68-ge6838d1 #=============================================================================== #### diff --git a/bin/process_batch.sh b/bin/process_batch.sh index 5c5b726..509d3fb 100755 --- a/bin/process_batch.sh +++ b/bin/process_batch.sh @@ -21,7 +21,7 @@ USAGE='process_update.sh [-h|--help] [-s|--startbot] [-w|--watch] [-n|--lines n] # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 27.02.2021 13:14 # -#### $$VERSION$$ v1.45-dev-60-g2415814 +#### $$VERSION$$ v1.45-dev-68-ge6838d1 #=============================================================================== #### @@ -83,7 +83,7 @@ tail ${follow} ${lines} "${file}" |\ do # read json from stdin and convert update format # replace any ID named BOTADMIN with ID of bot admin - : "${input//\"id\":BOTADMIN,/\"id\":${BOT_ADMIN},}" + : "${input//\"id\":BOTADMIN,/\"id\":${BOTADMIN},}" json='{"result": ['"${_}"']}' UPDATE="$(${JSONSHFILE} -b -n <<<"${json}" 2>/dev/null)" diff --git a/bin/process_update.sh b/bin/process_update.sh index 439679d..61fc5db 100755 --- a/bin/process_update.sh +++ b/bin/process_update.sh @@ -15,7 +15,7 @@ USAGE='process_update.sh [-h|--help] [debug] [/dev/null)" # process telegram update diff --git a/bin/promote_user.sh b/bin/promote_user.sh index a0faa63..9fc9dcd 100755 --- a/bin/promote_user.sh +++ b/bin/promote_user.sh @@ -25,7 +25,7 @@ USAGE='promote_user.sh [-h|--help] "CHAT[ID]" "USER[ID]" "right[:true|false]" .. # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 25.01.2021 22:34 # -#### $$VERSION$$ v1.45-dev-53-g941598d +#### $$VERSION$$ v1.45-dev-68-ge6838d1 #=============================================================================== #### diff --git a/bin/send_broadcast.sh b/bin/send_broadcast.sh index a3390a3..9b3807d 100755 --- a/bin/send_broadcast.sh +++ b/bin/send_broadcast.sh @@ -28,7 +28,7 @@ USAGE='broadcast_message.sh [-h|--help] [--doit] [--groups|--both|--db=file] [fo # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 16.12.2020 16:14 # -#### $$VERSION$$ v1.40-0-gf9dab50 +#### $$VERSION$$ v1.45-dev-68-ge6838d1 #=============================================================================== #### @@ -91,7 +91,7 @@ if [ -z "${SENDALL[*]}" ]; then fi # loop over users - printf "${GREEN}Sending broadcast message to ${SENDTO}${GROUPSALSO} of ${BOT_NAME} using database:${NC}${GREY} ${database##*/}" + printf "${GREEN}Sending broadcast message to ${SENDTO}${GROUPSALSO} of ${BOTNAME} using database:${NC}${GREY} ${database##*/}" { # dry run [ -z "${DOIT}" ] && printf "${NC}\n${ORANGE}DRY RUN! use --doit as first argument to execute broadcast...${NC}\n" diff --git a/bin/send_buttons.sh b/bin/send_buttons.sh index f2d2b3e..984a0c1 100755 --- a/bin/send_buttons.sh +++ b/bin/send_buttons.sh @@ -26,7 +26,7 @@ USAGE='send_message.sh [-h|--help] "CHAT[ID]" "message" "text|url" ...' # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 18.01.2021 11:34 # -#### $$VERSION$$ v1.40-0-gf9dab50 +#### $$VERSION$$ v1.45-dev-68-ge6838d1 #=============================================================================== #### @@ -40,7 +40,7 @@ print_help "$1" #### # ready, do stuff here ----- if [ "$1" == "BOTADMIN" ]; then - CHAT="${BOT_ADMIN}" + CHAT="${BOTADMIN}" else CHAT="$1" fi diff --git a/bin/send_dice.sh b/bin/send_dice.sh index dc81c4a..cf95ba2 100755 --- a/bin/send_dice.sh +++ b/bin/send_dice.sh @@ -21,7 +21,7 @@ USAGE='send_dice.sh [-h|--help] "CHAT[ID]" "emoji" [debug]' # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 07.02.2021 18:45 # -#### $$VERSION$$ v1.45-dev-8-g069570e +#### $$VERSION$$ v1.45-dev-68-ge6838d1 #=============================================================================== #### @@ -35,7 +35,7 @@ print_help "$1" #### # ready, do stuff here ----- if [ "$1" == "BOTADMIN" ]; then - CHAT="${BOT_ADMIN}" + CHAT="${BOTADMIN}" else CHAT="$1" fi diff --git a/bin/send_edit_message.sh b/bin/send_edit_message.sh deleted file mode 120000 index e6089f6..0000000 --- a/bin/send_edit_message.sh +++ /dev/null @@ -1 +0,0 @@ -edit_message.sh \ No newline at end of file diff --git a/bin/send_file.sh b/bin/send_file.sh index 1cc2dc2..a77b47d 100755 --- a/bin/send_file.sh +++ b/bin/send_file.sh @@ -25,7 +25,7 @@ USAGE='send_file.sh [-h|--help] "CHAT[ID]" "file|URL" "caption ...." [type] [deb # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 25.12.2020 20:24 # -#### $$VERSION$$ v1.40-0-gf9dab50 +#### $$VERSION$$ v1.45-dev-68-ge6838d1 #=============================================================================== #### @@ -39,7 +39,7 @@ print_help "$1" #### # ready, do stuff here ----- if [ "$1" == "BOTADMIN" ]; then - CHAT="${BOT_ADMIN}" + CHAT="${BOTADMIN}" else CHAT="$1" fi diff --git a/bin/send_message.sh b/bin/send_message.sh index 10edd37..c0e39f4 100755 --- a/bin/send_message.sh +++ b/bin/send_message.sh @@ -22,7 +22,7 @@ USAGE='send_message.sh [-h|--help] [format] "CHAT[ID]" "message ...." [debug]' # AUTHOR: KayM (gnadelwartz), kay@rrr.de # CREATED: 16.12.2020 11:34 # -#### $$VERSION$$ v1.40-0-gf9dab50 +#### $$VERSION$$ v1.45-dev-68-ge6838d1 #=============================================================================== #### @@ -50,7 +50,7 @@ print_help "$1" #### # ready, do stuff here ----- if [ "$1" == "BOTADMIN" ]; then - CHAT="${BOT_ADMIN}" + CHAT="${BOTADMIN}" else CHAT="$1" fi diff --git a/modules/background.sh b/modules/background.sh index 44b655c..4c775d4 100644 --- a/modules/background.sh +++ b/modules/background.sh @@ -6,7 +6,7 @@ # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # # shellcheck disable=SC1117,SC2059 -#### $$VERSION$$ v1.45-dev-67-g53e936e +#### $$VERSION$$ v1.45-dev-68-ge6838d1 # will be automatically sourced from bashbot diff --git a/modules/chatMember.sh b/modules/chatMember.sh index 53c6ffa..90f60fd 100644 --- a/modules/chatMember.sh +++ b/modules/chatMember.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v1.45-dev-67-g53e936e +#### $$VERSION$$ v1.45-dev-68-ge6838d1 # will be automatically sourced from bashbot