diff --git a/doc/3_advanced.md b/doc/3_advanced.md index 141138b..ceb3eb0 100644 --- a/doc/3_advanced.md +++ b/doc/3_advanced.md @@ -39,11 +39,20 @@ In addition you can check individual capabilities of users as you must define in # allow user 987654321 only to start bot in chat 98979695 987654321:start:98979695 +# special case allow ALL users ONE action in all groups or in one group +ALL:search:* +ALL:search:98979695 + +# not valid, ALL must have an action! +ALL:*:* + # * are only allowed on the right hand side and not for user! # the following examples are NOT valid! *:*:* *:start:* *:*:98979695 + + ``` You must use the function ```user_is_allowed``` to check if a user has the capability to do something. Example: Check if user has capability to start bot. @@ -288,5 +297,5 @@ Note: If you disable automatic retry, se above, you disable also connection prob #### [Prev Getting started](2_usage.md) #### [Next Expert Use](4_expert.md) -#### $$VERSION$$ v1.0-0-g99217c4 +#### $$VERSION$$ v1.2-dev-14-g6ec00d4 diff --git a/modules/chatMember.sh b/modules/chatMember.sh index 2299c0f..09f9e69 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$$ v1.0-0-g99217c4 +#### $$VERSION$$ v1.2-dev-14-g6ec00d4 # will be automatically sourced from bashbot @@ -59,11 +59,18 @@ user_is_botadmin() { } user_is_allowed() { - local acl="$1" [ -z "$1" ] && return 1 - grep -F -xq "${acl}:*:*" <"${BOTACL}" && return 0 - [ -n "$2" ] && acl="${acl}:$2" - grep -F -xq "${acl}:*" <"${BOTACL}" && return 0 - [ -n "$3" ] && acl="${acl}:$3" - grep -F -xq "${acl}" <"${BOTACL}" + # user can do everything + 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 + # all users are allowed to do one action in every chat + 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 + # all users are allowed to do one action in one chat + grep -F -xq "ALL:$2:$3" <"${BOTACL}" && return 0 + return 1 }