better messages for invalid bot token
This commit is contained in:
parent
cae6288598
commit
b123c3dbce
18
bashbot.sh
18
bashbot.sh
|
@ -11,7 +11,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$$ v1.21-dev-5-g874e37e
|
#### $$VERSION$$ v1.21-dev-6-gcae6288
|
||||||
#
|
#
|
||||||
# Exit Codes:
|
# Exit Codes:
|
||||||
# - 0 success (hopefully)
|
# - 0 success (hopefully)
|
||||||
|
@ -276,20 +276,20 @@ fi
|
||||||
|
|
||||||
# BOTTOKEN format checks
|
# BOTTOKEN format checks
|
||||||
if ! check_token "${BOTTOKEN}"; then
|
if ! check_token "${BOTTOKEN}"; then
|
||||||
printf "${ORANGE}Warning: your bottoken may incorrect. it should have the following format:${NN}"
|
printf "${ORANGE}Warning: Your bot token is incorrect, it should have the following format:${NC}\n"
|
||||||
printf "${GREY}123456789${RED}:${GREY}Aa-Zz_0Aa-Zz_1Aa-Zz_2Aa-Zz_3Aa-Zz_4${ORANGE} => ${NC}"
|
printf "<your_bot_id>${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}8-10 digits${RED}:${GREY}35 alphanumeric characters + '_-'${NN}"
|
printf "${GREY}Your bot token: '${NC}${BOTTOKEN//:/${RED}:${NC}}'\n"
|
||||||
printf "${ORANGE}Your current token is: '${GREY}^$(cat -ve <<<"${BOTTOKEN//:/${RED}:${GREY}}")${ORANGE}'${NN}"
|
|
||||||
if [[ ! "${BOTTOKEN}" =~ ^[0-9]{8,10}: ]]; then
|
if [[ ! "${BOTTOKEN}" =~ ^[0-9]{8,10}: ]]; then
|
||||||
printf "${ORANGE}Possible problem in the digits part, len is $(($(wc -c <<<"${BOTTOKEN%:*}")-1))${NN}"
|
printf "${GREY}\tHint: Bot id len: ${NC}$(($(wc -c <<<"${BOTTOKEN%:*}")-1)) ${GREY}but should be${NC} 8-10\n"
|
||||||
[ -n "$(getConfigKey "botid")" ] && printf "${GREY}Did you mean: \"${NC}$(getConfigKey "botid")${GREY}\" ?${NN}"
|
[ -n "$(getConfigKey "botid")" ] && printf "\t${GREEN}Did you mean: \"${NC}$(getConfigKey "botid")${GREEN}\" ?${NN}"
|
||||||
fi
|
fi
|
||||||
[[ ! "${BOTTOKEN}" =~ :[a-zA-Z0-9_-]{35}$ ]] &&\
|
[[ ! "${BOTTOKEN}" =~ :[a-zA-Z0-9_-]{35}$ ]] &&\
|
||||||
printf "${ORANGE}Possible problem in the characters part, len is $(($(wc -c <<<"${BOTTOKEN#*:}")-1))${NN}"
|
printf "${GREY}\tHint: Hash token: invalid character or not${NC} 35 ${GREY}characters long, len is ${NC}$(($(wc -c <<<"${BOTTOKEN#*:}")-1))\n"
|
||||||
|
printf "\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# here we start with the real stuff
|
# here we start with the real stuff
|
||||||
BASHBOT_RETRY="" # retry by default
|
BASHBOT_RETRY="" # retry by default
|
||||||
|
|
Loading…
Reference in New Issue