Hooks can now contain help on optional keywords
This commit is contained in:
parent
c6aa38147b
commit
9790954dfc
@ -100,7 +100,9 @@ class Bot(threading.Thread):
|
|||||||
for (s, h) in self.modules[module].__nemubot_context__.hooks:
|
for (s, h) in self.modules[module].__nemubot_context__.hooks:
|
||||||
if s == "in_Command" and (h.name is not None or h.regexp is not None) and h.is_matching(msg.args[0][1:]):
|
if s == "in_Command" and (h.name is not None or h.regexp is not None) and h.is_matching(msg.args[0][1:]):
|
||||||
if h.help_usage:
|
if h.help_usage:
|
||||||
return res.append_message(["\x03\x02%s%s\x03\x02: %s" % (msg.args[0], (" " + k if k is not None else ""), h.help_usage[k]) for k in h.help_usage], title="Usage for command %s from module %s" % (msg.args[0], module))
|
lp = ["\x03\x02%s%s\x03\x02: %s" % (msg.args[0], (" " + k if k is not None else ""), h.help_usage[k]) for k in h.help_usage]
|
||||||
|
jp = ["\x03\x02@%s\x03\x02: %s" % (k, h.keywords[k]) for k in h.keywords]
|
||||||
|
return res.append_message(lp + ([". Moreover, you can provides some optional parameters: "] + jp if len(jp) else []), title="Usage for command %s from module %s" % (msg.args[0], module))
|
||||||
elif h.help:
|
elif h.help:
|
||||||
return res.append_message("Command %s from module %s: %s" % (msg.args[0], module, h.help))
|
return res.append_message("Command %s from module %s: %s" % (msg.args[0], module, h.help))
|
||||||
else:
|
else:
|
||||||
|
@ -25,7 +25,8 @@ class Message(Abstract):
|
|||||||
"""Class storing hook information, specialized for a generic Message"""
|
"""Class storing hook information, specialized for a generic Message"""
|
||||||
|
|
||||||
def __init__(self, call, name=None, regexp=None, channels=list(),
|
def __init__(self, call, name=None, regexp=None, channels=list(),
|
||||||
server=None, help=None, help_usage=dict(), **kargs):
|
server=None, help=None, help_usage=dict(), keywords=dict(),
|
||||||
|
**kargs):
|
||||||
|
|
||||||
Abstract.__init__(self, call=call, **kargs)
|
Abstract.__init__(self, call=call, **kargs)
|
||||||
|
|
||||||
@ -33,6 +34,7 @@ class Message(Abstract):
|
|||||||
assert channels is None or type(channels) is list, channels
|
assert channels is None or type(channels) is list, channels
|
||||||
assert server is None or type(server) is str, server
|
assert server is None or type(server) is str, server
|
||||||
assert type(help_usage) is dict, help_usage
|
assert type(help_usage) is dict, help_usage
|
||||||
|
assert type(keywords) is dict, keywords
|
||||||
|
|
||||||
self.name = str(name) if name is not None else None
|
self.name = str(name) if name is not None else None
|
||||||
self.regexp = regexp
|
self.regexp = regexp
|
||||||
@ -40,6 +42,7 @@ class Message(Abstract):
|
|||||||
self.channels = channels
|
self.channels = channels
|
||||||
self.help = help
|
self.help = help
|
||||||
self.help_usage = help_usage
|
self.help_usage = help_usage
|
||||||
|
self.keywords = keywords
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user