From fe1c9ef746679aac9798f130ceff904c1a132602 Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 6 Feb 2020 23:50:19 +0000 Subject: allow multipe require_accces (comma sep), support "low"/"high"/"admin" --- src/core_modules/channel_access.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/core_modules') 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: -- cgit v1.3.1-10-gc9f91