mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-27 09:21:35 +07:00
fix(cli): route telegram thread create to topic-create
This commit is contained in:
14
src/cli/program/message/register.thread.test.ts
Normal file
14
src/cli/program/message/register.thread.test.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { __test__ } from "./register.thread.js";
|
||||||
|
|
||||||
|
describe("resolveThreadCreateAction", () => {
|
||||||
|
it("maps telegram thread create to topic-create", () => {
|
||||||
|
expect(__test__.resolveThreadCreateAction({ channel: "telegram" })).toBe("topic-create");
|
||||||
|
expect(__test__.resolveThreadCreateAction({ channel: " Telegram " })).toBe("topic-create");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("keeps thread-create for non-telegram channels", () => {
|
||||||
|
expect(__test__.resolveThreadCreateAction({ channel: "discord" })).toBe("thread-create");
|
||||||
|
expect(__test__.resolveThreadCreateAction({ channel: undefined })).toBe("thread-create");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
import type { Command } from "commander";
|
import type { Command } from "commander";
|
||||||
import type { MessageCliHelpers } from "./helpers.js";
|
import type { MessageCliHelpers } from "./helpers.js";
|
||||||
|
|
||||||
|
function resolveThreadCreateAction(opts: { channel?: unknown }) {
|
||||||
|
const channel = typeof opts.channel === "string" ? opts.channel.trim().toLowerCase() : "";
|
||||||
|
return channel === "telegram" ? "topic-create" : "thread-create";
|
||||||
|
}
|
||||||
|
|
||||||
export function registerMessageThreadCommands(message: Command, helpers: MessageCliHelpers) {
|
export function registerMessageThreadCommands(message: Command, helpers: MessageCliHelpers) {
|
||||||
const thread = message.command("thread").description("Thread actions");
|
const thread = message.command("thread").description("Thread actions");
|
||||||
|
|
||||||
@@ -17,7 +22,7 @@ export function registerMessageThreadCommands(message: Command, helpers: Message
|
|||||||
.option("-m, --message <text>", "Initial thread message text")
|
.option("-m, --message <text>", "Initial thread message text")
|
||||||
.option("--auto-archive-min <n>", "Thread auto-archive minutes")
|
.option("--auto-archive-min <n>", "Thread auto-archive minutes")
|
||||||
.action(async (opts) => {
|
.action(async (opts) => {
|
||||||
await helpers.runMessageAction("thread-create", opts);
|
await helpers.runMessageAction(resolveThreadCreateAction(opts), opts);
|
||||||
});
|
});
|
||||||
|
|
||||||
helpers
|
helpers
|
||||||
@@ -53,3 +58,5 @@ export function registerMessageThreadCommands(message: Command, helpers: Message
|
|||||||
await helpers.runMessageAction("thread-reply", opts);
|
await helpers.runMessageAction("thread-reply", opts);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const __test__ = { resolveThreadCreateAction };
|
||||||
|
|||||||
Reference in New Issue
Block a user