From 7fb31d31608f9706e2091a451a185ee333232c00 Mon Sep 17 00:00:00 2001 From: Vincent Le Goff Date: Sun, 2 Jul 2017 16:23:49 -0700 Subject: [PATCH 1/3] Let ChannelCommand.arg_regex override the value set by the CHANNEL_HANDLER --- evennia/comms/channelhandler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evennia/comms/channelhandler.py b/evennia/comms/channelhandler.py index 520b0934d9..30f54c5d95 100644 --- a/evennia/comms/channelhandler.py +++ b/evennia/comms/channelhandler.py @@ -66,6 +66,7 @@ class ChannelCommand(command.Command): key = "general" help_category = "Channel Names" obj = None + arg_regex = r"\s.*?|/history.*?" def parse(self): """ @@ -212,7 +213,6 @@ class ChannelHandler(object): locks="cmd:all();%s" % channel.locks, help_category="Channel names", obj=channel, - arg_regex=r"\s.*?|/history.*?", is_channel=True) # format the help entry key = channel.key From 69c5f33c38f56caf4b93fc4ca3c983b63b61bed5 Mon Sep 17 00:00:00 2001 From: Vincent Le Goff Date: Sun, 2 Jul 2017 16:46:33 -0700 Subject: [PATCH 2/3] Allow to change suggestion_cutoff and suggestion_maxnum in help --- evennia/commands/default/help.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/evennia/commands/default/help.py b/evennia/commands/default/help.py index 4590ab74c6..fce601e90a 100644 --- a/evennia/commands/default/help.py +++ b/evennia/commands/default/help.py @@ -49,6 +49,12 @@ class CmdHelp(Command): # 'help_more' flag to False. 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): """ 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 caller = self.caller - suggestion_cutoff = 0.6 - suggestion_maxnum = 5 + suggestion_cutoff = self.suggestion_cutoff + suggestion_maxnum = self.suggestion_maxnum if not query: query = "all" @@ -211,12 +217,14 @@ class CmdHelp(Command): # Try to access a particular command # 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 - [vocabulary.extend(cmd.aliases) for cmd in all_cmds] - suggestions = [sugg for sugg in string_suggestions(query, set(vocabulary), cutoff=suggestion_cutoff, maxnum=suggestion_maxnum) - if sugg != query] - if not suggestions: - suggestions = [sugg for sugg in vocabulary if sugg != query and sugg.startswith(query)] + suggestions = None + if suggestion_maxnum > 0: + vocabulary = [cmd.key for cmd in all_cmds if cmd] + [topic.key for topic in all_topics] + all_categories + [vocabulary.extend(cmd.aliases) for cmd in all_cmds] + suggestions = [sugg for sugg in string_suggestions(query, set(vocabulary), cutoff=suggestion_cutoff, maxnum=suggestion_maxnum) + 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 match = [cmd for cmd in all_cmds if cmd == query] From a2c76f06cd3e551255713ae0bb73ffe209db156f Mon Sep 17 00:00:00 2001 From: David Newman Date: Wed, 12 Jul 2017 08:16:48 -0400 Subject: [PATCH 3/3] docs: add missing word --- evennia/contrib/rpsystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evennia/contrib/rpsystem.py b/evennia/contrib/rpsystem.py index 73a682eb95..5aa33db50e 100644 --- a/evennia/contrib/rpsystem.py +++ b/evennia/contrib/rpsystem.py @@ -627,7 +627,7 @@ class SdescHandler(object): def get(self): """ 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