diff --git a/src/channel.ts b/src/channel.ts index bf4a958..f353a9b 100644 --- a/src/channel.ts +++ b/src/channel.ts @@ -1,6 +1,5 @@ /** - * PIT Channel 主文件 - * @module channel + * PIT Channel 主文? * @module channel */ import type { @@ -33,7 +32,7 @@ import { chunkText } from "./utils/chunker.js"; import { createLogger } from "./utils/logger.js"; import { registerWebUIRoutes } from "./webui/routes.js"; -const MODULE = "pit-bot"; +const MODULE = "zhidui-channel"; // Gateway 实例映射 const gateways = new Map(); @@ -42,10 +41,10 @@ const gateways = new Map(); * PIT Bot Channel Plugin */ export const pitBotPlugin: ChannelPlugin = { - id: "pit-bot", + id: "zhidui-channel", meta: { - id: "pit-bot", + id: "zhidui-channel", label: "PIT Bot", selectionLabel: "PIT Bot", docsPath: "/docs/channels/pit-bot", @@ -121,7 +120,7 @@ export const pitBotPlugin: ChannelPlugin = { const gateway = gateways.get(accountId); if (!gateway) { return { - channel: "pit-bot", + channel: "zhidui-channel", messageId: "", error: new Error(`Gateway not available for account ${accountId}`), }; @@ -130,7 +129,7 @@ export const pitBotPlugin: ChannelPlugin = { const result = await gateway.sendText(to, text, replyToId); return { - channel: "pit-bot", + channel: "zhidui-channel", messageId: result.messageId ?? "", error: result.error ? new Error(result.error) : undefined, }; @@ -138,7 +137,7 @@ export const pitBotPlugin: ChannelPlugin = { const message = error instanceof Error ? error.message : String(error); log.error("sendText failed", { to, accountId, error: message }); return { - channel: "pit-bot", + channel: "zhidui-channel", messageId: "", error: new Error(message), }; @@ -152,7 +151,7 @@ export const pitBotPlugin: ChannelPlugin = { const gateway = gateways.get(accountId); if (!gateway) { return { - channel: "pit-bot", + channel: "zhidui-channel", messageId: "", error: new Error(`Gateway not available for account ${accountId}`), }; @@ -161,7 +160,7 @@ export const pitBotPlugin: ChannelPlugin = { const result = await gateway.sendMedia(to, mediaUrl ?? "", text, replyToId); return { - channel: "pit-bot", + channel: "zhidui-channel", messageId: result.messageId ?? "", error: result.error ? new Error(result.error) : undefined, }; @@ -169,7 +168,7 @@ export const pitBotPlugin: ChannelPlugin = { const message = error instanceof Error ? error.message : String(error); log.error("sendMedia failed", { to, accountId, error: message }); return { - channel: "pit-bot", + channel: "zhidui-channel", messageId: "", error: new Error(message), }; @@ -205,7 +204,7 @@ export const pitBotPlugin: ChannelPlugin = { getStatus: () => ctx.getStatus(), onMessage: (message: PITUserMessage) => { ctx.emitMessage({ - channel: "pit-bot", + channel: "zhidui-channel", accountId: account.accountId, chatId: `pit-bot:user:${message.userId}`, chatType: "direct", @@ -310,8 +309,7 @@ export const pitBotPlugin: ChannelPlugin = { }, } as ChannelStatusAdapter, - // 初始化钩子 - init: async (api: unknown) => { + // 初始化钩? init: async (api: unknown) => { const log = createLogger(MODULE); log.info("PIT Bot plugin initializing");