Admins are members of the named group.
authorCMDR furrycat <elite@furrycat.net>
Mon, 26 Sep 2016 08:52:21 +0000 (09:52 +0100)
committerCMDR furrycat <elite@furrycat.net>
Mon, 26 Sep 2016 08:52:21 +0000 (09:52 +0100)
bot.py

diff --git a/bot.py b/bot.py
index e7952f9..3f93971 100755 (executable)
--- 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