botadmin is also an admin, better default for /start command

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-05-16 08:49:36 +02:00
parent f13a2d05cc
commit 93f49665aa
2 changed files with 6 additions and 5 deletions

View File

@ -15,7 +15,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.94-0-gaaa71c8
#### $$VERSION$$ v0.94-1-gf13a2d0
#
# adjust your language setting here, e.g.when run from other user or cron.
@ -104,7 +104,7 @@ if [ -z "${1}" ] || [[ "${1}" == *"debug"* ]];then
'/start'*)
send_action "${CHAT[ID]}" "typing"
user_is_botadmin "${USER[ID]}" && send_markdown_message "${CHAT[ID]}" "You are *BOTADMIN*."
if _is_botadmin || _is_allowed "start" ; then
if user_is_admin "${CHAT[ID]}" "${USER[ID]}" || user_is_allowed "${USER[ID]}" "start" ; then
send_markdown_message "${CHAT[ID]}" "${bashbot_help}"
else
send_normal_message "${CHAT[ID]}" "You are not allowed to start Bot."
@ -115,9 +115,9 @@ if [ -z "${1}" ] || [[ "${1}" == *"debug"* ]];then
send_markdown_message "${CHAT[ID]}" "${bashbot_help}"
;;
'/leavechat'*) # bot leave chat if user is admin in chat
if user_is_botadmin "${USER[ID]}" ; then
if user_is_admin "${CHAT[ID]}" "${USER[ID]}" || user_is_allowed "${USER[ID]}" "leave" ; then
send_markdown_message "${CHAT[ID]}" "*LEAVING CHAT...*"
leave_chat "${CHAT[ID]}"
leave_chat "${CHAT[ID]}"
fi
;;

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$$ v0.94-0-gaaa71c8
#### $$VERSION$$ v0.94-1-gf13a2d0
# source once magic, function named like file
eval "$(basename "${BASH_SOURCE[0]}")(){ :; }"
@ -45,6 +45,7 @@ user_is_admin() {
[ "$1" = "$2" ] && return 0
local me; me="$(get_chat_member_status "$1" "$2")"
if [ "${me}" = "creator" ] || [ "${me}" = "administrator" ]; then return 0; fi
user_is_botadmin "$2" && return 0
return 1
}