summaryrefslogtreecommitdiffstats
path: root/modules/help.py
blob: d239f849e134ed78c0e30251e9f267a7eb695b45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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)