2023-09-08 02:49:37 +02:00
|
|
|
from mipa.ext.commands.bot import Bot
|
|
|
|
|
|
|
|
class ModuleInterface:
|
|
|
|
def __init__(self):
|
|
|
|
self.name = None
|
|
|
|
self.regex_pattern = None
|
|
|
|
self.funcs = {}
|
|
|
|
self.manager: (ModuleManager | None) = None
|
|
|
|
|
|
|
|
def set_manager(self, manager):
|
|
|
|
self.manager = manager
|
2023-10-02 07:36:36 +02:00
|
|
|
#self.module_ready()
|
2023-09-08 02:49:37 +02:00
|
|
|
|
|
|
|
def get_execute_pattern(self, regex_pattern):
|
|
|
|
return self.__regex_pattern
|
|
|
|
|
|
|
|
def module_ready(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
async def execute_module(self, ctx):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def get_func(self, name):
|
|
|
|
return self.funcs[name]
|
|
|
|
|
|
|
|
|
|
|
|
class ModuleManager:
|
|
|
|
def __init__(self, main_bot = None):
|
|
|
|
self.modules = {}
|
|
|
|
self.bot: (Bot | None) = main_bot
|
|
|
|
|
|
|
|
def require(self, name):
|
|
|
|
return self.modules[name]
|
|
|
|
|
|
|
|
def register_module(self, module):
|
|
|
|
if module.name not in self.modules:
|
|
|
|
self.modules[module.name] = module
|
|
|
|
module.set_manager(self)
|