init: change bahsbot path in rc-file also

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-01-16 12:59:11 +01:00
parent 172a9e5461
commit d8453aad36
2 changed files with 10 additions and 9 deletions

View File

@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb
# 8 - curl/wget missing
# 10 - not bash!
#
#### $$VERSION$$ v1.30-dev-31-g161e883
#### $$VERSION$$ v1.30-dev-32-g172a9e5
##################################################################
# emmbeded system may claim bash but it is not
@ -1133,9 +1133,10 @@ bot_init() {
# adjust values in bashbot.rc
if [ -w "bashbot.rc" ]; then
printf "Adjust user and botname in bashbot.rc ...\n"
sed -i '/^[# ]*runas=/ s/runas=.*$/runas="'"${touser}"'"/' "bashbot.rc"
sed -i '/^[# ]*runas=/ s|runas=.*$|runas="'"${touser}"'"|' "bashbot.rc"
sed -i '/^[# ]*bashbot=/ s|bashbot=.*$|bashbot="cd '"${PWD}"'; '"${PWD}"'/'"${0##*/}"'"|' "bashbot.rc"
botname="$(getConfigKey "botname")"
[ -n "${botname}" ] && sed -i '/^[# ]*name=/ s/name=.*$/name="'"${botname}"'"/' "bashbot.rc"
[ -n "${botname}" ] && sed -i '/^[# ]*name=/ s|name=.*$|name="'"${botname}"'"|' "bashbot.rc"
printf "Done.\n"
fi
# ask to check bottoken online

View File

@ -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.30-dev-28-gd269f98
#### $$VERSION$$ v1.30-dev-31-g161e883
# will be automatically sourced from bashbot
@ -115,16 +115,16 @@ user_is_allowed() {
[ -z "$1" ] && return 1
user_is_admin "$1" && return 0
# user can do everything
grep -F -xq "$1:*:*" <"${BOTACL}" && return 0
grep -F -xq "$1:*:*" "${BOTACL}" && return 0
[ -z "$2" ] && return 1
# user is allowed todo one action in every chat
grep -F -xq "$1:$2:*" <"${BOTACL}" && return 0
grep -F -xq "$1:$2:*" "${BOTACL}" && return 0
# all users are allowed to do one action in every chat
grep -F -xq "ALL:$2:*" <"${BOTACL}" && return 0
grep -F -xq "ALL:$2:*" "${BOTACL}" && return 0
[ -z "$3" ] && return 1
# user is allowed to do one action in one chat
grep -F -xq "$1:$2:$3" <"${BOTACL}" && return 0
grep -F -xq "$1:$2:$3" "${BOTACL}" && return 0
# all users are allowed to do one action in one chat
grep -F -xq "ALL:$2:$3" <"${BOTACL}" && return 0
grep -F -xq "ALL:$2:$3" "${BOTACL}" && return 0
return 1
}