From ee96e79f341755140f7a5d85ea825d880d43ac2e Mon Sep 17 00:00:00 2001 From: Alexander PapaTutuWawa Date: Sun, 13 Jun 2021 19:34:05 +0200 Subject: [PATCH] fix: Rename _on_command of BaseModule --- mira/base.py | 4 ++-- mira/module.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mira/base.py b/mira/base.py index 40a5298..03bd222 100644 --- a/mira/base.py +++ b/mira/base.py @@ -51,7 +51,7 @@ class MiraBot: def _initialise_modules(self): for module in self._config['modules']: - logger.debug("Initialising module %s" % (module)) + logger.debug("Initialising module %s" % (module['name'])) mod = importlib.import_module(module['name']) self._modules[mod.NAME] = mod.get_instance(self, config=module, name=mod.NAME) @@ -117,7 +117,7 @@ class MiraBot: ' module that is restricted to whitelisted users only') return - self._modules[cmd[0]]._on_command(cmd[1:], message) + self._modules[cmd[0]].__on_command(cmd[1:], message) # Module Function: Send message def send_message(self, message): diff --git a/mira/module.py b/mira/module.py index 1c00227..7397313 100644 --- a/mira/module.py +++ b/mira/module.py @@ -16,10 +16,13 @@ along with this program. If not, see . ''' import asyncio from functools import partial +import logging from mira.storage import StorageManager from mira.subscription import SubscriptionManager +logger = logging.getLogger('mira.module') + class ManagerWrapper: ''' Wrapper class around {Storage, Subscription}Manager in order @@ -52,6 +55,8 @@ class BaseModule: self._stm = ManagerWrapper(self._name, StorageManager) self._sum = ManagerWrapper(self._name, SubscriptionManager) + + logger.debug('Init of %s done' % (self._name)) def get_option(self, key, default=None): ''' @@ -69,11 +74,13 @@ class BaseModule: ''' self._base.send_message_wrapper(to, body) - def _on_command(self, cmd, msg): + def __on_command(self, cmd, msg): def run(func): loop = asyncio.get_event_loop() loop.create_task(func(cmd, msg)) - + + logger.debug('Received command: %s' % (str(cmd))) + if not self._subcommand_table: run(self.on_command) elif cmd and cmd[0] in self._subcommand_table: