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:
parent
6a5985b002
commit
793fdb0e84
|
@ -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):
|
||||
|
|
|
@ -132,6 +132,8 @@ DISCORD_BOT_MAX_MESSAGES = 5000
|
|||
LOGGER_BASE_DIR = './logs'
|
||||
WEATHER_WEATHER_UNDERGROUND_API_KEY = 'key'
|
||||
|
||||
BOT_PLUGINS = []
|
||||
|
||||
|
||||
# get local settings
|
||||
|
||||
|
|
Loading…
Reference in New Issue