fix: Rename _on_command of BaseModule
This commit is contained in:
parent
3b2b89061b
commit
ee96e79f34
@ -51,7 +51,7 @@ class MiraBot:
|
|||||||
|
|
||||||
def _initialise_modules(self):
|
def _initialise_modules(self):
|
||||||
for module in self._config['modules']:
|
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'])
|
mod = importlib.import_module(module['name'])
|
||||||
self._modules[mod.NAME] = mod.get_instance(self, config=module, name=mod.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')
|
' module that is restricted to whitelisted users only')
|
||||||
return
|
return
|
||||||
|
|
||||||
self._modules[cmd[0]]._on_command(cmd[1:], message)
|
self._modules[cmd[0]].__on_command(cmd[1:], message)
|
||||||
|
|
||||||
# Module Function: Send message
|
# Module Function: Send message
|
||||||
def send_message(self, message):
|
def send_message(self, message):
|
||||||
|
@ -16,10 +16,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
'''
|
'''
|
||||||
import asyncio
|
import asyncio
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
import logging
|
||||||
|
|
||||||
from mira.storage import StorageManager
|
from mira.storage import StorageManager
|
||||||
from mira.subscription import SubscriptionManager
|
from mira.subscription import SubscriptionManager
|
||||||
|
|
||||||
|
logger = logging.getLogger('mira.module')
|
||||||
|
|
||||||
class ManagerWrapper:
|
class ManagerWrapper:
|
||||||
'''
|
'''
|
||||||
Wrapper class around {Storage, Subscription}Manager in order
|
Wrapper class around {Storage, Subscription}Manager in order
|
||||||
@ -52,6 +55,8 @@ class BaseModule:
|
|||||||
|
|
||||||
self._stm = ManagerWrapper(self._name, StorageManager)
|
self._stm = ManagerWrapper(self._name, StorageManager)
|
||||||
self._sum = ManagerWrapper(self._name, SubscriptionManager)
|
self._sum = ManagerWrapper(self._name, SubscriptionManager)
|
||||||
|
|
||||||
|
logger.debug('Init of %s done' % (self._name))
|
||||||
|
|
||||||
def get_option(self, key, default=None):
|
def get_option(self, key, default=None):
|
||||||
'''
|
'''
|
||||||
@ -69,11 +74,13 @@ class BaseModule:
|
|||||||
'''
|
'''
|
||||||
self._base.send_message_wrapper(to, body)
|
self._base.send_message_wrapper(to, body)
|
||||||
|
|
||||||
def _on_command(self, cmd, msg):
|
def __on_command(self, cmd, msg):
|
||||||
def run(func):
|
def run(func):
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
loop.create_task(func(cmd, msg))
|
loop.create_task(func(cmd, msg))
|
||||||
|
|
||||||
|
logger.debug('Received command: %s' % (str(cmd)))
|
||||||
|
|
||||||
if not self._subcommand_table:
|
if not self._subcommand_table:
|
||||||
run(self.on_command)
|
run(self.on_command)
|
||||||
elif cmd and cmd[0] in self._subcommand_table:
|
elif cmd and cmd[0] in self._subcommand_table:
|
||||||
|
Loading…
Reference in New Issue
Block a user