diff --git a/earwigbot/commands/chanops.py b/earwigbot/commands/chanops.py index 83399fc..ea54500 100644 --- a/earwigbot/commands/chanops.py +++ b/earwigbot/commands/chanops.py @@ -36,7 +36,7 @@ class ChanOps(Command): de_escalate = data.command in ["devoice", "deop"] if de_escalate and (not data.args or data.args[0] == data.nick): target = data.nick - elif data.host not in self.config.irc["permissions"]["admins"]: + elif not self.config.irc["permissions"].is_admin(data): self.reply(data, "You must be a bot admin to use this command.") return diff --git a/earwigbot/commands/git_command.py b/earwigbot/commands/git_command.py index 645ed04..b57ee05 100644 --- a/earwigbot/commands/git_command.py +++ b/earwigbot/commands/git_command.py @@ -39,7 +39,7 @@ class Git(Command): def process(self, data): self.data = data - if data.host not in self.config.irc["permissions"]["owners"]: + if not self.config.irc["permissions"].is_owner(data): msg = "You must be a bot owner to use this command." self.reply(data, msg) return diff --git a/earwigbot/commands/quit.py b/earwigbot/commands/quit.py index 5d8a1b2..0331d08 100644 --- a/earwigbot/commands/quit.py +++ b/earwigbot/commands/quit.py @@ -29,7 +29,7 @@ class Quit(Command): commands = ["quit", "restart", "reload"] def process(self, data): - if data.host not in self.config.irc["permissions"]["owners"]: + if not self.config.irc["permissions"].is_owner(data): self.reply(data, "You must be a bot owner to use this command.") return if data.command == "quit": diff --git a/earwigbot/commands/threads.py b/earwigbot/commands/threads.py index 385ac1c..e878d09 100644 --- a/earwigbot/commands/threads.py +++ b/earwigbot/commands/threads.py @@ -32,7 +32,7 @@ class Threads(Command): def process(self, data): self.data = data - if data.host not in self.config.irc["permissions"]["owners"]: + if not self.config.irc["permissions"].is_owner(data): msg = "You must be a bot owner to use this command." self.reply(data, msg) return diff --git a/earwigbot/config/permissions.py b/earwigbot/config/permissions.py index 4860cba..b05f215 100644 --- a/earwigbot/config/permissions.py +++ b/earwigbot/config/permissions.py @@ -83,13 +83,15 @@ class PermissionsDB(object): except sqlite.OperationalError: self._create(conn) - def is_admin(self, nick="*", ident="*", host="*"): + def is_admin(self, data): """Return ``True`` if the given user is a bot admin, else ``False``.""" - return self._is_rank(_User(nick, ident, host), rank=self.ADMIN) + user = _User(data.nick, data.ident, data.host) + return self._is_rank(user, rank=self.ADMIN) - def is_owner(self, nick="*", ident="*", host="*"): + def is_owner(self, data): """Return ``True`` if the given user is a bot owner, else ``False``.""" - return self._is_rank(_User(nick, ident, host), rank=self.OWNER) + user = _User(data.nick, data.ident, data.host) + return self._is_rank(user, rank=self.OWNER) def add_admin(self, nick="*", ident="*", host="*"): """Add an nick/ident/host combo to the bot admins list."""