summaryrefslogtreecommitdiffstats
path: root/modules/help.py
blob: 99f05a48f7f11af6705939b7a0f89b123076f566 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from . 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, nick, text, handler):
        if not re.match(r'!help(?:\W|\Z)', text):
            return
        
        commands = self.manager.commands()
        helpstring = reduce(lambda s, (c, h): s + c + ': ' + h + '\n', commands, '')
        helptexts = '\n'.join(self.manager.helptexts())
        
        handler.reply(('Befehle:\n' + helpstring + '\n' + helptexts).strip())