Add module aliases
A module can add an alias by simply defining def matrix_start(self, bot): super().matrix_start(bot) bot.module_aliases['my_alias'] = self.name No alias will override a module name
This commit is contained in:
parent
6f6acfd681
commit
1efce55ff8
4
bot.py
4
bot.py
|
@ -40,6 +40,7 @@ class Bot:
|
|||
self.client = None
|
||||
self.join_on_invite = False
|
||||
self.modules = dict()
|
||||
self.module_aliases = dict()
|
||||
self.leave_empty_rooms = True
|
||||
self.pollcount = 0
|
||||
self.poll_task = None
|
||||
|
@ -260,7 +261,8 @@ class Bot:
|
|||
# Strip away non-alphanumeric characters, including leading ! for security
|
||||
command = re.sub(r'\W+', '', command)
|
||||
|
||||
moduleobject = self.modules.get(command)
|
||||
# Fallback to any declared aliases
|
||||
moduleobject = self.modules.get(command) or self.modules.get(self.module_aliases.get(command))
|
||||
|
||||
if moduleobject is not None:
|
||||
if moduleobject.enabled:
|
||||
|
|
Loading…
Reference in New Issue