operator help: complete + context-aware (ops-17): !bot help full grouped list, !help for everyone per-channel
This commit is contained in:
@@ -133,3 +133,69 @@ class TestTasksKillSwitch(OpsBase):
|
||||
"""OPS-09: bot-initiated posts respect pause/quiet."""
|
||||
await self.bot.on_message(self.staff_msg("!bot pause"))
|
||||
self.assertFalse(self.bot.bot_initiated_allowed())
|
||||
|
||||
|
||||
class TestHelp(OpsBase):
|
||||
STAFF_CMDS = (
|
||||
"pause",
|
||||
"resume",
|
||||
"quiet <minutes>",
|
||||
"status",
|
||||
"spend",
|
||||
"images on|off",
|
||||
"memory <user>",
|
||||
"forget-fact <id>",
|
||||
"pin <channel|global>",
|
||||
"unpin <id>",
|
||||
"pins",
|
||||
"task-approve <id>",
|
||||
"task-cancel <id>",
|
||||
"(list)",
|
||||
)
|
||||
|
||||
def test_staff_help_is_complete_and_grouped(self):
|
||||
"""OPS-17: staff help lists every operator command, grouped by purpose."""
|
||||
text = self.bot._help_text(staff=True)
|
||||
for cmd in self.STAFF_CMDS:
|
||||
self.assertIn(cmd, text, f"missing {cmd!r} in staff help")
|
||||
for group in ("Control:", "Cost:", "Memory:", "Tasks:"):
|
||||
self.assertIn(group, text)
|
||||
for cmd in ("!help", "!forgetme", "!privacy", "!wichtel"):
|
||||
self.assertIn(cmd, text) # everywhere-commands shown too
|
||||
|
||||
def test_user_help_hides_operator_commands(self):
|
||||
"""OPS-17: non-staff help shows only the everyone-commands."""
|
||||
text = self.bot._help_text(staff=False)
|
||||
for cmd in ("!help", "!forgetme", "!privacy", "!wichtel"):
|
||||
self.assertIn(cmd, text)
|
||||
for op in ("task-approve", "images on|off", "spend", "Staff commands", "Control:"):
|
||||
self.assertNotIn(op, text)
|
||||
|
||||
async def test_bot_help_in_staff_channel_returns_full_help(self):
|
||||
"""OPS-17: `!bot help` answers with the complete staff help."""
|
||||
await self.bot.on_message(self.staff_msg("!bot help"))
|
||||
text = self.bot.staff_channel.send.await_args.args[0]
|
||||
self.assertIn("Staff commands", text)
|
||||
self.assertIn("task-cancel <id>", text)
|
||||
|
||||
async def test_unknown_bot_command_falls_back_to_help(self):
|
||||
"""OPS-17: an unrecognised `!bot` command shows the full help, not a partial line."""
|
||||
await self.bot.on_message(self.staff_msg("!bot wat"))
|
||||
text = self.bot.staff_channel.send.await_args.args[0]
|
||||
self.assertIn("Control:", text)
|
||||
|
||||
async def test_help_in_public_channel_is_user_scoped(self):
|
||||
"""OPS-17: `!help` in a normal channel lists only everyone-commands."""
|
||||
msg = self.public_msg("!help")
|
||||
await self.bot.on_message(msg)
|
||||
text = msg.channel.send.await_args.args[0]
|
||||
self.assertIn("!forgetme", text)
|
||||
self.assertNotIn("Staff commands", text)
|
||||
self.assertNotIn("task-approve", text)
|
||||
|
||||
async def test_help_works_while_paused(self):
|
||||
"""OPS-17: help answers even when replies are paused."""
|
||||
await self.bot.on_message(self.staff_msg("!bot pause"))
|
||||
msg = self.public_msg("!help")
|
||||
await self.bot.on_message(msg)
|
||||
msg.channel.send.assert_awaited()
|
||||
|
||||
Reference in New Issue
Block a user