From 93f49665aa69d9342f78c33830e151e4961a1830 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sat, 16 May 2020 08:49:36 +0200 Subject: [PATCH] botadmin is also an admin, better default for /start command --- commands.sh | 8 ++++---- modules/chatMember.sh | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/commands.sh b/commands.sh index b732f5a..61935c7 100644 --- a/commands.sh +++ b/commands.sh @@ -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 ;; diff --git a/modules/chatMember.sh b/modules/chatMember.sh index 34f2853..ad9559d 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$$ 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 }