Lint.
authorCMDR furrycat <elite@furrycat.net>
Wed, 25 Nov 2020 09:04:37 +0000 (10:04 +0100)
committerCMDR furrycat <elite@furrycat.net>
Wed, 25 Nov 2020 09:04:37 +0000 (10:04 +0100)
bot.py

diff --git a/bot.py b/bot.py
index 969b547..b93955a 100644 (file)
--- a/bot.py
+++ b/bot.py
@@ -40,14 +40,14 @@ def is_admin(user, server = None, context = None):
     params.append(server.id)
   if context is not None:
     params.append(context)
-  sql = 'select id from admins where server_id in ({}) and bot_id in (?, ?) and user_id=?'.format(', '.join(['?'] * len(params)))
+  sql = 'select count(*) from admins where server_id in ({}) and bot_id in (?, ?) and user_id=?'.format(', '.join(['?'] * len(params)))
   params.append('global')
   params.append(client.user.id)
   params.append(user.id)
   cursor = db.query(sql, params)
-  for row in cursor.fetchall():
+  row = cursor.fetchone()
+  if row and row[0] > 0:
     ret = True
-    break
   db.close_db()
   tb = reversed(traceback.extract_stack()[0:-2])
   log.info('{}: User {} {} an administrator{}'.format(': '.join([format_frame(frame) for frame in tb]), user.name, 'is' if ret else 'is not', ' on server {}'.format(server.name) if server is not None else ''))
@@ -589,7 +589,7 @@ async def maybe_say(channel, text, *, typing = None, attachment = None, embed =
     try:
       ok = True
       send = {}
-      async with typing_context_manager(channel, typing) as context_manager:
+      async with typing_context_manager(channel, typing):
         if embed:
           send['embed'] = embed
         if attachment is not None: