| @@ -36,7 +36,7 @@ class ChanOps(Command): | |||||
| de_escalate = data.command in ["devoice", "deop"] | de_escalate = data.command in ["devoice", "deop"] | ||||
| if de_escalate and (not data.args or data.args[0] == data.nick): | if de_escalate and (not data.args or data.args[0] == data.nick): | ||||
| target = 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.") | self.reply(data, "You must be a bot admin to use this command.") | ||||
| return | return | ||||
| @@ -39,7 +39,7 @@ class Git(Command): | |||||
| def process(self, data): | def process(self, data): | ||||
| self.data = 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." | msg = "You must be a bot owner to use this command." | ||||
| self.reply(data, msg) | self.reply(data, msg) | ||||
| return | return | ||||
| @@ -29,7 +29,7 @@ class Quit(Command): | |||||
| commands = ["quit", "restart", "reload"] | commands = ["quit", "restart", "reload"] | ||||
| def process(self, data): | 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.") | self.reply(data, "You must be a bot owner to use this command.") | ||||
| return | return | ||||
| if data.command == "quit": | if data.command == "quit": | ||||
| @@ -32,7 +32,7 @@ class Threads(Command): | |||||
| def process(self, data): | def process(self, data): | ||||
| self.data = 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." | msg = "You must be a bot owner to use this command." | ||||
| self.reply(data, msg) | self.reply(data, msg) | ||||
| return | return | ||||
| @@ -83,13 +83,15 @@ class PermissionsDB(object): | |||||
| except sqlite.OperationalError: | except sqlite.OperationalError: | ||||
| self._create(conn) | 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 ``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 ``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="*"): | def add_admin(self, nick="*", ident="*", host="*"): | ||||
| """Add an nick/ident/host combo to the bot admins list.""" | """Add an nick/ident/host combo to the bot admins list.""" | ||||