config option for loading bot "plugins"

as it turns out, i can't use a module __init__.py to load bot stuff, if
that code would refer to django models, because the django code will try
to do stuff before the apps are initialized, and then the entire house
of cards crumbles apart.

so, i will explicitly load these bot "plugins" separately, after the
modules proper are all initialized
This commit is contained in:
Brian S. Stephan 2018-01-09 15:18:38 -06:00
parent 6a5985b002
commit 793fdb0e84
2 changed files with 7 additions and 0 deletions

View File

@ -1,5 +1,6 @@
"""Start the Discord bot and connect to Discord."""
import asyncio
import importlib
import logging
from django.conf import settings
@ -16,6 +17,10 @@ async def on_ready():
"""Print some basic login info to the console, when the bot connects."""
logger.info("Logged in as {0:s} ({1:s})".format(hitomi.user.name, hitomi.user.id))
# now load bot plugins
for plugin in settings.BOT_PLUGINS:
importlib.import_module(plugin)
@hitomi.event
async def on_message(message):

View File

@ -132,6 +132,8 @@ DISCORD_BOT_MAX_MESSAGES = 5000
LOGGER_BASE_DIR = './logs'
WEATHER_WEATHER_UNDERGROUND_API_KEY = 'key'
BOT_PLUGINS = []
# get local settings