diff --git a/src/decorators.py b/src/decorators.py index 97ffd1d..3dd5d06 100644 --- a/src/decorators.py +++ b/src/decorators.py @@ -111,6 +111,24 @@ class cmd: return self.func(*largs) # don't check restrictions for role commands + if self.owner_only: + if var.is_owner(nick, cloak): + adminlog(chan, rawnick, self.name, rest) + return self.func(*largs) + + if chan == nick: + pm(cli, nick, "You are not the owner.") + else: + cli.notice(nick, "You are not the owner.") + return + + if not self.admin_only: + return self.func(*largs) + + if var.is_admin(nick, cloak): + adminlog(chan, rawnick, self.name, rest) + return self.func(*largs) + if acc: for pattern in var.DENY_ACCOUNTS: if fnmatch.fnmatch(acc.lower(), pattern.lower()): @@ -126,8 +144,7 @@ class cmd: if fnmatch.fnmatch(acc.lower(), pattern.lower()): for command in self.cmds: if command in var.ALLOW_ACCOUNTS[pattern]: - if self.admin_only or self.owner_only: - adminlog(chan, rawnick, self.name, rest) + adminlog(chan, rawnick, self.name, rest) return self.func(*largs) if not var.ACCOUNTS_ONLY and cloak: @@ -145,33 +162,14 @@ class cmd: if fnmatch.fnmatch(cloak.lower(), pattern.lower()): for command in self.cmds: if command in var.ALLOW[pattern]: - if self.admin_only or self.owner_only: - adminlog(chan, rawnick, self.name, rest) + adminlog(chan, rawnick, self.name, rest) return self.func(*largs) - if self.owner_only: - if var.is_owner(nick, cloak): - adminlog(chan, rawnick, self.name, rest) - return self.func(*largs) - - if chan == nick: - pm(cli, nick, "You are not the owner.") - else: - cli.notice(nick, "You are not the owner.") - return - - if self.admin_only: - if var.is_admin(nick, cloak): - adminlog(chan, rawnick, self.name, rest) - return self.func(*largs) - - if chan == nick: - pm(cli, nick, "You are not an admin.") - else: - cli.notice(nick, "You are not an admin.") - return - - return self.func(*largs) + if chan == nick: + pm(cli, nick, "You are not an admin.") + else: + cli.notice(nick, "You are not an admin.") + return class hook: def __init__(self, name, hookid=-1):