diff --git a/src/decorators.py b/src/decorators.py index ac3af7d..4d253d0 100644 --- a/src/decorators.py +++ b/src/decorators.py @@ -189,7 +189,7 @@ class cmd: return flags = var.FLAGS[hostmask] + var.FLAGS_ACCS[acc] - is_full_admin = "F" in flags + is_full_admin = var.is_admin(nick, ident, host) if self.flag and (is_full_admin or is_owner): adminlog(chan, rawnick, self.name, rest) return self.func(*largs) diff --git a/src/settings.py b/src/settings.py index 61a4c08..520c5da 100644 --- a/src/settings.py +++ b/src/settings.py @@ -377,7 +377,27 @@ def is_admin(nick, ident=None, host=None, acc=None): acc = USERS[nick]["account"] hostmask = nick + "!" + ident + "@" + host flags = FLAGS[hostmask] + FLAGS_ACCS[acc] - return "F" in flags + + if not "F" in flags: + try: + hosts = set(botconfig.ADMINS) + accounts = set(botconfig.ADMINS_ACCOUNTS) + + if not DISABLE_ACCOUNTS and acc and acc != "*": + for pattern in accounts: + if fnmatch.fnmatch(acc.lower(), pattern.lower()): + return True + + if host: + for hostmask in hosts: + if match_hostmask(hostmask, nick, ident, host): + return True + except AttributeError: + pass + + return is_owner(nick, ident, host, acc) + + return True def irc_lower(nick): mapping = {