feat(csm): bootstrap discussion callback flow

This commit is contained in:
zhi
2026-04-02 02:35:08 +00:00
parent 9fa71f37bf
commit 62cd2f20cf
9 changed files with 450 additions and 3 deletions

View File

@@ -18,6 +18,9 @@ type MessageReceivedDeps = {
recordChannelAccount: (api: OpenClawPluginApi, channelId: string, accountId: string) => boolean;
extractMentionedUserIds: (content: string) => string[];
buildUserIdToAccountIdMap: (api: OpenClawPluginApi) => Map<string, string>;
discussionService?: {
maybeReplyClosedChannel: (channelId: string, senderId?: string) => Promise<boolean>;
};
};
export function registerMessageReceivedHook(deps: MessageReceivedDeps): void {
@@ -31,6 +34,7 @@ export function registerMessageReceivedHook(deps: MessageReceivedDeps): void {
recordChannelAccount,
extractMentionedUserIds,
buildUserIdToAccountIdMap,
discussionService,
} = deps;
api.on("message_received", async (event, ctx) => {
@@ -51,6 +55,11 @@ export function registerMessageReceivedHook(deps: MessageReceivedDeps): void {
(typeof (e as Record<string, unknown>).from === "string" ? ((e as Record<string, unknown>).from as string) : "");
const moderatorUserId = getModeratorUserId(livePre);
if (discussionService) {
const closedHandled = await discussionService.maybeReplyClosedChannel(preChannelId, from);
if (closedHandled) return;
}
if (moderatorUserId && from === moderatorUserId) {
if (shouldDebugLog(livePre, preChannelId)) {
api.logger.info(`dirigent: ignoring moderator message in channel=${preChannelId}`);