diff options
| author | 2020-02-06 23:50:19 +0000 | |
|---|---|---|
| committer | 2020-02-06 23:50:19 +0000 | |
| commit | fe1c9ef746679aac9798f130ceff904c1a132602 (patch) | |
| tree | 87a5ee1743cc8f6c9c813ffe27f56cbcde27e023 /src/core_modules | |
| parent | accept "1"/"0" as "true"/"false" for !config (diff) | |
| signature | ||
allow multipe require_accces (comma sep), support "low"/"high"/"admin"
Diffstat (limited to 'src/core_modules')
| -rw-r--r-- | src/core_modules/channel_access.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/core_modules/channel_access.py b/src/core_modules/channel_access.py index d4a81d42..977ecdbd 100644 --- a/src/core_modules/channel_access.py +++ b/src/core_modules/channel_access.py @@ -4,14 +4,28 @@ from src import ModuleManager, utils +SPECIAL = ["low", "high", "admin"] + class Module(ModuleManager.BaseModule): _name = "ChanAccess" - def _has_channel_access(self, target, user, require_access): - access = target.get_user_setting(user.get_id(), "access", []) + def _has_channel_access(self, target, user, names): + required_access = [] + for name in names.split(","): + name = name.strip() + + if name in SPECIAL: + required_access.extend(SPECIAL[:SPECIAL.index(name)+1]) + else: + required_access.append(name) + + print(required_access) + + user_access = target.get_user_setting(user.get_id(), "access", []) identified = self.exports.get_one("is-identified")(user) + matched = list(set(required_access)&set(user_access)) - return (require_access in access or "*" in access) and identified + return ("*" in required_access or matched) and identified def _command_check(self, event, channel, require_access): if channel: |
