소스 검색

Implement new permissions system in bot commands.

tags/v0.1^2
Ben Kurtovic 11 년 전
부모
커밋
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."""


불러오는 중...
취소
저장