From 9cca55b3764f4d34ed7a96c4725596a6359a26e5 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Fri, 1 Jan 2021 21:55:13 +0100 Subject: [PATCH] multiline printf --- bashbot.sh | 12 ++++++------ xxx | 53 ----------------------------------------------------- 2 files changed, 6 insertions(+), 59 deletions(-) delete mode 100644 xxx diff --git a/bashbot.sh b/bashbot.sh index 9d70bcb..4a39e4f 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -30,7 +30,7 @@ # 8 - curl/wget missing # 10 - not bash! # -#### $$VERSION$$ v1.21-pre-11-g03c8c9d +#### $$VERSION$$ v1.21-pre-12-ged1cc4a ################################################################## # emmbeded system may claim bash but it is not @@ -279,16 +279,16 @@ fi # BOTTOKEN format checks if ! check_token "${BOTTOKEN}"; then - printf "\n${ORANGE}Warning: Your bot token is incorrect, it should have the following format:${NC}\n" - printf "${RED}:${NC}<35_alphanumeric_characters-hash> ${RED}e.g. =>${NC} 123456789${RED}:${NC}Aa-Zz_0Aa-Zz_1Aa-Zz_2Aa-Zz_3Aa-Zz_4\n\n" - printf "${GREY}Your bot token: '${NC}${BOTTOKEN//:/${RED}:${NC}}'\n" + printf "\n${ORANGE}Warning: Your bot token is incorrect, it should have the following format:${NC}\n%b%b"\ + "${RED}:${NC}<35_alphanumeric_characters-hash> ${RED}e.g. =>${NC} 123456789${RED}:${NC}Aa-Zz_0Aa-Zz_1Aa-Zz_2Aa-Zz_3Aa-Zz_4\n\n"\ + "${GREY}Your bot token: '${NC}${BOTTOKEN//:/${RED}:${NC}}'\n" if [[ ! "${BOTTOKEN}" =~ ^[0-9]{8,10}: ]]; then - printf "${GREY}\tHint: Bot id len: ${NC}$(($(wc -c <<<"${BOTTOKEN%:*}")-1)) ${GREY}but should be${NC} 8-10\n" + printf "${GREY}\tHint: Bot id not a number or wrong len: ${NC}$(($(wc -c <<<"${BOTTOKEN%:*}")-1)) ${GREY}but should be${NC} 8-10\n" [ -n "$(getConfigKey "botid")" ] && printf "\t${GREEN}Did you mean: \"${NC}$(getConfigKey "botid")${GREEN}\" ?${NN}" fi [[ ! "${BOTTOKEN}" =~ :[a-zA-Z0-9_-]{35}$ ]] &&\ - printf "${GREY}\tHint: Hash contains invalid character or is not${NC} 35 ${GREY}characters long, hash len is ${NC}$(($(wc -c <<<"${BOTTOKEN#*:}")-1))\n" + printf "${GREY}\tHint: Hash contains invalid character or has not len${NC} 35 ${GREY}, hash len is ${NC}$(($(wc -c <<<"${BOTTOKEN#*:}")-1))\n" printf "\n" fi diff --git a/xxx b/xxx deleted file mode 100644 index 499b6c5..0000000 --- a/xxx +++ /dev/null @@ -1,53 +0,0 @@ -# CREATE botconfig if not exist -# assume everything already set up correctly if TOKEN is set -if [ -z "${BOTTOKEN}" ]; then - # BOTCONFIG does not exist, create - [ ! -f "${BOTCONFIG}.jssh" ] && printf '["bot_config_key"]\t"config_key_value"\n' >>"${BOTCONFIG}.jssh" - if [ -z "$(getConfigKey "bottoken")" ]; then - # ask user for bot token - if [ -z "${INTERACTIVE}" ] && [ "$1" != "init" ]; then - printf "Running headless, set BOTTOKEN or run ${SCRIPT} init first!\n" - exit 2 - else - printf "${RED}ENTER BOT TOKEN...${NN}${ORANGE}PLEASE WRITE YOUR TOKEN HERE OR PRESS CTRL+C TO ABORT${NN}" - read -r token - printf "\n" - fi - [ -n "${token}" ] && printf '["bottoken"]\t"%s"\n' "${token}" >> "${BOTCONFIG}.jssh" - fi - # no botadmin, setup botadmin - if [ -z "$(getConfigKey "botadmin")" ]; then - # ask user for bot admin - if [ -z "${INTERACTIVE}" ]; then - printf "Running headless, set botadmin to AUTO MODE!\n" - else - printf "${RED}ENTER BOT ADMIN...${NN}${ORANGE}PLEASE WRITE YOUR TELEGRAM ID HERE OR PRESS ENTER\nTO MAKE FIRST USER TYPING '/start' BOT ADMIN${NN}?\b" - read -r admin - fi - [ -z "${admin}" ] && admin='?' - printf '["botadmin"]\t"%s"\n' "${admin}" >> "${BOTCONFIG}.jssh" - fi - # setup botacl file - if [ ! -f "${BOTACL}" ]; then - printf "${GREY}Create initial ${BOTACL} file.${NN}" - printf '\n' >"${BOTACL}" - fi - # check data dir file - if [ ! -w "${DATADIR}" ]; then - printf "${RED}ERROR: ${DATADIR} does not exist or is not writeable!.${NN}" - exit 2 - fi - # setup count file - if [ ! -f "${COUNTFILE}.jssh" ]; then - printf '["counted_user_chat_id"]\t"num_messages_seen"\n' >> "${COUNTFILE}.jssh" - elif [ ! -w "${COUNTFILE}.jssh" ]; then - printf "${RED}ERROR: Can't write to ${COUNTFILE}!.${NN}" - ls -l "${COUNTFILE}.jssh" - exit 2 - fi - # setup blocked file - if [ ! -f "${BLOCKEDFILE}.jssh" ]; then - printf '["blocked_user_or_chat_id"]\t"name and reason"\n' >>"${BLOCKEDFILE}.jssh" - fi -fi -