From 25e6c53cc85df3aa97b50c8002ade05164164c46 Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Mon, 26 Sep 2016 09:52:21 +0100 Subject: [PATCH] Admins are members of the named group. --- bot.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index e7952f9..3f93971 100755 --- a/bot.py +++ b/bot.py @@ -12,9 +12,10 @@ import re import util admins = [] +admin_role = 'Cat' fd = open('ADMINS', 'r') for line in fd.readlines(): - admin = int(line.strip()) + admin = line.strip() admins.append(admin) fd.close() @@ -59,8 +60,19 @@ def not_admin(message): yield from maybe_say(message.channel, 'hiss!') @asyncio.coroutine +def is_admin(server, member): + if server is None: + return member.id in admins + for role in server.roles: + if role.name != admin_role: + continue + if role.id in member.roles: + return True + return False + +@asyncio.coroutine def do_admin(message, command, raw): - if not int(message.author.id) in admins: + if not is_admin(message.server, message.author): yield from not_admin(message) return @@ -147,7 +159,7 @@ def do_fork(message, command, raw): @asyncio.coroutine def set_role(member, role_name = 'Unassigned', minimum = 1): - if int(member.id) in admins: + if is_admin(None, member): return role = None -- 2.7.4