Test for plugin on_ready() before trying to run.
authorCMDR furrycat <elite@furrycat.net>
Wed, 26 Oct 2016 06:56:32 +0000 (07:56 +0100)
committerCMDR furrycat <elite@furrycat.net>
Wed, 26 Oct 2016 06:56:45 +0000 (07:56 +0100)
app.py
db.py
plugins/__init__.py

diff --git a/app.py b/app.py
index eea831e..d38292c 100644 (file)
--- a/app.py
+++ b/app.py
@@ -2006,8 +2006,7 @@ def on_ready():
     log.debug('Maybe unassigning {}'.format(member.name))
     yield from set_unassigned(member)
   if not threads_ready.value:
-    for plugin in plugins.all():
-      asyncio.async(plugin.on_ready())
+    plugins.on_ready()
     asyncio.async(do_announcements())
     asyncio.async(maybe_sleep())
     threads_ready.value = True
diff --git a/db.py b/db.py
index e091b4c..5f10c36 100644 (file)
--- a/db.py
+++ b/db.py
@@ -1,4 +1,3 @@
-import asyncio
 import discord
 import logging
 import sqlite3
@@ -173,8 +172,3 @@ class DBConnection(object):
 
   def delete_announcement(self, client, id):
     return self.delete_from_table(client, 'announcements', id)
-
-  @asyncio.coroutine
-  def on_ready(self):
-    # Override me.
-    return
index 17c0175..75e611a 100644 (file)
@@ -40,3 +40,8 @@ class Plugins(object):
   def all(self):
     for name, data in self.loaded.items():
       yield data['plugin']
+
+  def on_ready(self):
+    for name, data in self.loaded.items():
+      if hasattr(data['module'], 'on_ready'):
+        asyncio.async(data['module'].on_ready())