Merge branch 'master' into devel
This commit is contained in:
commit
e56b0024c4
3 changed files with 18 additions and 10 deletions
|
|
@ -49,6 +49,12 @@ class CmdHelp(Command):
|
||||||
# 'help_more' flag to False.
|
# 'help_more' flag to False.
|
||||||
help_more = True
|
help_more = True
|
||||||
|
|
||||||
|
# suggestion cutoff, between 0 and 1 (1 => perfect match)
|
||||||
|
suggestion_cutoff = 0.6
|
||||||
|
|
||||||
|
# number of suggestions (set to 0 to remove suggestions from help)
|
||||||
|
suggestion_maxnum = 5
|
||||||
|
|
||||||
def msg_help(self, text):
|
def msg_help(self, text):
|
||||||
"""
|
"""
|
||||||
messages text to the caller, adding an extra oob argument to indicate
|
messages text to the caller, adding an extra oob argument to indicate
|
||||||
|
|
@ -178,8 +184,8 @@ class CmdHelp(Command):
|
||||||
query, cmdset = self.args, self.cmdset
|
query, cmdset = self.args, self.cmdset
|
||||||
caller = self.caller
|
caller = self.caller
|
||||||
|
|
||||||
suggestion_cutoff = 0.6
|
suggestion_cutoff = self.suggestion_cutoff
|
||||||
suggestion_maxnum = 5
|
suggestion_maxnum = self.suggestion_maxnum
|
||||||
|
|
||||||
if not query:
|
if not query:
|
||||||
query = "all"
|
query = "all"
|
||||||
|
|
@ -211,12 +217,14 @@ class CmdHelp(Command):
|
||||||
# Try to access a particular command
|
# Try to access a particular command
|
||||||
|
|
||||||
# build vocabulary of suggestions and rate them by string similarity.
|
# build vocabulary of suggestions and rate them by string similarity.
|
||||||
vocabulary = [cmd.key for cmd in all_cmds if cmd] + [topic.key for topic in all_topics] + all_categories
|
suggestions = None
|
||||||
[vocabulary.extend(cmd.aliases) for cmd in all_cmds]
|
if suggestion_maxnum > 0:
|
||||||
suggestions = [sugg for sugg in string_suggestions(query, set(vocabulary), cutoff=suggestion_cutoff, maxnum=suggestion_maxnum)
|
vocabulary = [cmd.key for cmd in all_cmds if cmd] + [topic.key for topic in all_topics] + all_categories
|
||||||
if sugg != query]
|
[vocabulary.extend(cmd.aliases) for cmd in all_cmds]
|
||||||
if not suggestions:
|
suggestions = [sugg for sugg in string_suggestions(query, set(vocabulary), cutoff=suggestion_cutoff, maxnum=suggestion_maxnum)
|
||||||
suggestions = [sugg for sugg in vocabulary if sugg != query and sugg.startswith(query)]
|
if sugg != query]
|
||||||
|
if not suggestions:
|
||||||
|
suggestions = [sugg for sugg in vocabulary if sugg != query and sugg.startswith(query)]
|
||||||
|
|
||||||
# try an exact command auto-help match
|
# try an exact command auto-help match
|
||||||
match = [cmd for cmd in all_cmds if cmd == query]
|
match = [cmd for cmd in all_cmds if cmd == query]
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ class ChannelCommand(command.Command):
|
||||||
key = "general"
|
key = "general"
|
||||||
help_category = "Channel Names"
|
help_category = "Channel Names"
|
||||||
obj = None
|
obj = None
|
||||||
|
arg_regex = r"\s.*?|/history.*?"
|
||||||
|
|
||||||
def parse(self):
|
def parse(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -212,7 +213,6 @@ class ChannelHandler(object):
|
||||||
locks="cmd:all();%s" % channel.locks,
|
locks="cmd:all();%s" % channel.locks,
|
||||||
help_category="Channel names",
|
help_category="Channel names",
|
||||||
obj=channel,
|
obj=channel,
|
||||||
arg_regex=r"\s.*?|/history.*?",
|
|
||||||
is_channel=True)
|
is_channel=True)
|
||||||
# format the help entry
|
# format the help entry
|
||||||
key = channel.key
|
key = channel.key
|
||||||
|
|
|
||||||
|
|
@ -627,7 +627,7 @@ class SdescHandler(object):
|
||||||
def get(self):
|
def get(self):
|
||||||
"""
|
"""
|
||||||
Simple getter. The sdesc should never be allowed to
|
Simple getter. The sdesc should never be allowed to
|
||||||
be empty, but it is we must fall back to the key.
|
be empty, but if it is we must fall back to the key.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self.sdesc or self.obj.key
|
return self.sdesc or self.obj.key
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue