Do not load settings which are not active (module not loaded)

Restart the bot, on heavy DB errors, with an 30 seconds delay (like: all connections terminated by DB, table_definition_cache exhausted)
Fix for channel prefixing (org <-> priv)
This commit is contained in:
2021-11-30 16:57:31 +01:00
parent c100b0ea76
commit bf6c1842d2
17 changed files with 57 additions and 29 deletions
+7 -2
View File
@@ -10,7 +10,7 @@ class Registry:
logger = None
@classmethod
def inject_all(cls):
def inject_all(cls, modules):
# inject registry so instance can get references to other instances
for key in cls._registry:
try:
@@ -23,7 +23,10 @@ class Registry:
@classmethod
def pre_start_all(cls):
# call pre_start() on instances so they can start any init() processes
mods = cls.get_instance("bot").modules
for key in cls._registry:
if str(cls._registry[key].module_name).split(".")[0] not in mods:
continue
try:
cls._registry[key].pre_start
except AttributeError:
@@ -34,7 +37,10 @@ class Registry:
@classmethod
def start_all(cls):
# call start() on instances so they can finish any init() processes
mods = cls.get_instance("bot").modules
for key in cls._registry:
if str(cls._registry[key].module_name).split(".")[0] not in mods:
continue
try:
cls._registry[key].start
except AttributeError:
@@ -60,7 +66,6 @@ class Registry:
inst.module_name = Registry.get_module_name(inst)
inst.module_dir = Registry.get_module_dir(inst)
if not override and name in cls._registry:
raise Exception("Overriding '%s' with new instance" % name)
elif override and name not in cls._registry: