diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/__init__.py | 0 | ||||
-rw-r--r-- | modules/base.py | 12 | ||||
-rw-r--r-- | modules/help.py | 18 |
3 files changed, 30 insertions, 0 deletions
diff --git a/modules/__init__.py b/modules/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/modules/__init__.py diff --git a/modules/base.py b/modules/base.py new file mode 100644 index 0000000..9d54c40 --- /dev/null +++ b/modules/base.py @@ -0,0 +1,12 @@ +class ModuleBase: + def __init__(self, manager): + self.manager = manager + + def commands(self): + return [] + + def message(self, message_type, message_from, message_subject, message_body, reply): + pass + + def groupchat(self, room, message_from, message_body, reply): + pass diff --git a/modules/help.py b/modules/help.py new file mode 100644 index 0000000..d239f84 --- /dev/null +++ b/modules/help.py @@ -0,0 +1,18 @@ +from base import ModuleBase +import re + +class Module(ModuleBase): + def __init__(self, manager): + ModuleBase.__init__(self, manager) + + def commands(self): + return [('!help', 'Zeigt diese Hilfe an...')] + + def groupchat(self, room, message_from, message_body, reply): + if not re.match(r'!help(?:\W|\Z)', message_body): + return + + commands = reduce(lambda l, mod: l + mod.commands(), self.manager.modules, []) + helpstring = reduce(lambda s, (c, h): s + c + ': ' + h + '\n', commands, '') + + reply('Befehle:\n\n' + helpstring) |