6
6
help = {'help': u'Provides help and usage information about plugins.'}
8
8
class Help(Processor):
15
def intro(self, event):
16
event.addresponse(u'Use "features" to get a list of available features. "help <feature>" will give a description of the feature, and "usage <feature>" will describe how to use it.')
19
def features(self, event):
22
for processor in ibid.processors:
23
module = eval(processor.__module__)
24
if hasattr(module, 'help'):
25
for feature in module.help.keys():
26
if feature not in features:
27
features.append(feature)
29
event.addresponse(u' '.join(features))
31
@match(r'^help\s+(.+)$')
32
def help(self, event, feature):
33
feature = feature.lower()
35
for processor in ibid.processors:
36
module = eval(processor.__module__)
37
if hasattr(module, 'help') and feature in module.help:
38
event.addresponse(module.help[feature])
41
event.addresponse(u"I can't help you with %s" % feature)
43
@match(r'^(?:usage|how\s+do\s+I\s+use)\s+(.+)$')
44
def usage(self, event, feature):
45
feature = feature.lower()
47
for processor in ibid.processors:
48
for name, klass in inspect.getmembers(processor, inspect.isclass):
49
if hasattr(klass, 'feature') and klass.feature == feature and klass.__doc__:
50
for line in klass.__doc__.splitlines():
51
event.addresponse('Usage: %s' % line.strip())
53
if not event.responses:
54
event.addresponse(u"I don't know how to use %s either" % feature)
15
def intro(self, event):
16
event.addresponse(u'Use "features" to get a list of available features. '
17
u'"help <feature>" will give a description of the feature, and "usage <feature>" will describe how to use it.')
20
def features(self, event):
23
for processor in ibid.processors:
24
module = eval(processor.__module__)
25
if hasattr(module, 'help'):
26
for feature in module.help.keys():
27
if feature not in features:
28
features.append(feature)
30
event.addresponse(u' '.join(features))
32
@match(r'^help\s+(.+)$')
33
def help(self, event, feature):
34
feature = feature.lower()
36
for processor in ibid.processors:
37
module = eval(processor.__module__)
38
if hasattr(module, 'help') and feature in module.help:
39
event.addresponse(module.help[feature])
42
event.addresponse(u"I can't help you with %s" % feature)
44
@match(r'^(?:usage|how\s+do\s+I\s+use)\s+(.+)$')
45
def usage(self, event, feature):
46
feature = feature.lower()
48
for processor in ibid.processors:
49
for name, klass in inspect.getmembers(processor, inspect.isclass):
50
if hasattr(klass, 'feature') and klass.feature == feature and klass.__doc__:
51
for line in klass.__doc__.splitlines():
52
event.addresponse('Usage: %s' % line.strip())
54
if not event.responses:
55
event.addresponse(u"I don't know how to use %s either" % feature)
57
# vi: set et sta sw=4 ts=4: