



























@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
33import { resolveQQBotCommandsAllowFrom, resolveSlashCommandAuth } from "./slash-command-auth.js";
44import { getWrittenQQBotConfig, installCommandRuntime } from "./slash-command-test-support.js";
55import { getFrameworkCommands, matchSlashCommand } from "./slash-commands-impl.js";
6-import type { SlashCommandContext } from "./slash-commands.js";
6+import { SlashCommandRegistry, type SlashCommandContext } from "./slash-commands.js";
7788function createStreamingContext(overrides: Partial<SlashCommandContext> = {}): SlashCommandContext {
99return {
@@ -29,8 +29,39 @@ function createStreamingContext(overrides: Partial<SlashCommandContext> = {}): S
2929}
30303131describe("QQBot framework slash commands", () => {
32-it("routes bot-approve through the auth-gated framework registry", () => {
33-expect(getFrameworkCommands().map((command) => command.name)).toContain("bot-approve");
32+it("exposes private-only admin commands with private-chat metadata", () => {
33+const commands = getFrameworkCommands();
34+const names = commands.map((command) => command.name);
35+36+expect(names).toEqual(
37+expect.arrayContaining(["bot-approve", "bot-clear-storage", "bot-logs", "bot-streaming"]),
38+);
39+for (const commandName of ["bot-approve", "bot-clear-storage", "bot-logs", "bot-streaming"]) {
40+expect(commands.find((command) => command.name === commandName)?.c2cOnly).toBe(true);
41+}
42+});
43+44+it("preserves private-only auth metadata for framework registration", () => {
45+const registry = new SlashCommandRegistry();
46+registry.register({
47+name: "private-admin",
48+description: "private admin command",
49+requireAuth: true,
50+c2cOnly: true,
51+handler: () => "ok",
52+});
53+registry.register({
54+name: "shared-admin",
55+description: "shared admin command",
56+requireAuth: true,
57+handler: () => "ok",
58+});
59+60+const commands = registry.getFrameworkCommands();
61+62+expect(commands.map((command) => command.name)).toEqual(["private-admin", "shared-admin"]);
63+expect(commands.find((command) => command.name === "private-admin")?.c2cOnly).toBe(true);
64+expect(commands.find((command) => command.name === "shared-admin")?.c2cOnly).toBeUndefined();
3465});
35663667it("routes bot-streaming through the auth-gated framework registry", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。