Преглед изворни кода

Implement new permissions system in bot commands.

tags/v0.1^2
Ben Kurtovic пре 12 година
родитељ
комит
bff57f55bc
5 измењених фајлова са 10 додато и 8 уклоњено
  1. +1
    -1
      earwigbot/commands/chanops.py
  2. +1
    -1
      earwigbot/commands/git_command.py
  3. +1
    -1
      earwigbot/commands/quit.py
  4. +1
    -1
      earwigbot/commands/threads.py
  5. +6
    -4
      earwigbot/config/permissions.py

+ 1
- 1
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



+ 1
- 1
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


+ 1
- 1
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":


+ 1
- 1
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


+ 6
- 4
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."""


Loading…
Откажи
Сачувај