From f1220e7b0219782e3cb30490ff7694ffecc06232 Mon Sep 17 00:00:00 2001 From: Chiizujin Date: Sat, 30 Mar 2024 18:30:41 +1100 Subject: [PATCH 1/2] Add sethelp/category switch for changing database help topic's category --- evennia/commands/default/help.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/evennia/commands/default/help.py b/evennia/commands/default/help.py index 9956a23c08..90a67602f2 100644 --- a/evennia/commands/default/help.py +++ b/evennia/commands/default/help.py @@ -780,13 +780,14 @@ class CmdSetHelp(CmdHelp): Edit the help database. Usage: - sethelp[/switches] [[;alias;alias][,category[,locks]] [= ] - + sethelp[/switches] [[;alias;alias][,category[,locks]] + [= ] Switches: edit - open a line editor to edit the topic's help text. replace - overwrite existing help topic. append - add text to the end of existing topic with a newline between. extend - as append, but don't add a newline. + category - change category of existing help topic. delete - remove help topic. Examples: @@ -794,6 +795,7 @@ class CmdSetHelp(CmdHelp): sethelp/append pickpocketing,Thievery = This steals ... sethelp/replace pickpocketing, ,attr(is_thief) = This steals ... sethelp/edit thievery + sethelp/category thievery = classes If not assigning a category, the `settings.DEFAULT_HELP_CATEGORY` category will be used. If no lockstring is specified, everyone will be able to read @@ -840,7 +842,7 @@ class CmdSetHelp(CmdHelp): key = "sethelp" aliases = [] - switch_options = ("edit", "replace", "append", "extend", "delete") + switch_options = ("edit", "replace", "append", "extend", "category", "delete") locks = "cmd:perm(Helper)" help_category = "Building" arg_regex = None @@ -857,7 +859,7 @@ class CmdSetHelp(CmdHelp): if not self.args: self.msg( - "Usage: sethelp[/switches] [;alias;alias][,category[,locks,..] = " + "Usage: sethelp[/switches] [[;alias;alias][,category[,locks]] [= ]" ) return @@ -986,6 +988,19 @@ class CmdSetHelp(CmdHelp): self.msg(f"Entry updated:\n{old_entry.entrytext}{aliastxt}") return + if "category" in switches: + # set the category + if not old_entry: + self.msg(f"Could not find topic '{topicstr}'{aliastxt}.") + return + if not self.rhs: + self.msg("You must supply a category.") + return + category = self.rhs.lower() + old_entry.help_category = category + self.msg(f"Category for entry '{topicstr}'{aliastxt} changed to '{category}'.") + return + if "delete" in switches or "del" in switches: # delete the help entry if not old_entry: From 9f9d58bedc5dc150a0957491970d5aa6770caa96 Mon Sep 17 00:00:00 2001 From: Chiizujin Date: Sun, 31 Mar 2024 02:27:30 +1100 Subject: [PATCH 2/2] Add unit test for sethelp/category --- evennia/commands/default/tests.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/evennia/commands/default/tests.py b/evennia/commands/default/tests.py index 8977c890d3..3a272e04f7 100644 --- a/evennia/commands/default/tests.py +++ b/evennia/commands/default/tests.py @@ -197,6 +197,12 @@ class TestHelp(BaseEvenniaCommandTest): cmdset=CharacterCmdSet(), ) self.call(help_module.CmdHelp(), "testhelp", "Help for testhelp", cmdset=CharacterCmdSet()) + self.call( + help_module.CmdSetHelp(), + "/category testhelp = misc", + "Category for entry 'testhelp' changed to 'misc'.", + cmdset=CharacterCmdSet(), + ) @parameterized.expand( [