attempt to ask the modules for help text

This commit is contained in:
Mike Bloy 2011-01-08 22:32:18 -06:00
parent 763f8906d7
commit 87088e67d1
1 changed files with 40 additions and 10 deletions

View File

@ -39,23 +39,53 @@ class Help(Module):
"""look for karma strings at the start of messages"""
match = self.helpre.search(what)
if (match):
if match:
(module, key) = match.group(2,4)
if (module == None):
return self.help_descriptions()
return self.handle_help_descriptions()
elif (key == None):
return self.help_module(module)
return self.handle_help_module(module)
else:
return self.help_detail(module, key)
return self.handle_help_detail(module, key)
def help_descriptions(self):
return "asked for general help"
def handle_help_descriptions(self):
message = "General Help:\n"
for module in self.irc.modlist:
description = module.help_description()
if description:
message += " %s - %s\n" % (module.__class__.__name__,
description)
return message
def help_module(self, module):
return "asked for help on module %s" % (module)
def handle_help_module(self, modname):
module = self.find_module(modname)
if module:
helptext = module.help_summary()
if helptext:
return "%s - %s" % (modname, helptext)
else:
return "no help available for module %s" % (modname)
else:
return "no module named '%s' is loaded" % (modname)
def help_detail(self, module, key):
return "asked for help on module %s detail %s" % (module, key)
def handle_help_detail(self, modname, key):
module = self.find_module(modname)
if module:
helptext = module.help_detail(key)
if helptext:
return "%s (%s) - %s" % (modname, key, helptext)
else:
return "no help available for module '%s', command '%s'" % (modname, key)
else:
return "no module named '%s' is loaded" % (modname)
return "asked for help on module %s detail %s" % (modname, key)
def find_module(self, modname):
for module in self.irc.modlist:
if modname == module.__class__.__name__:
return module
return None
if __name__ == "__main__":
print "Hello World"