Fix discussion channel closure handling

This commit is contained in:
zhi
2026-04-02 03:49:03 +00:00
parent 2c870ea2c5
commit d9bb5c2e21
4 changed files with 41 additions and 21 deletions

View File

@@ -7,6 +7,7 @@ import { sendModeratorMessage } from "./moderator-discord.js";
type DiscussionServiceDeps = {
api: OpenClawPluginApi;
moderatorBotToken?: string;
moderatorUserId?: string;
workspaceRoot?: string;
forceNoReplyForSession: (sessionKey: string) => void;
};
@@ -171,6 +172,7 @@ export function createDiscussionService(deps: DiscussionServiceDeps) {
async function maybeReplyClosedChannel(channelId: string, senderId?: string): Promise<boolean> {
const metadata = getDiscussion(channelId);
if (!metadata || metadata.status !== "closed") return false;
if (deps.moderatorUserId && senderId && senderId === deps.moderatorUserId) return true;
if (!deps.moderatorBotToken) return true;
await sendModeratorMessage(deps.moderatorBotToken, channelId, buildClosedMessage(), deps.api.logger);
return true;
@@ -179,6 +181,9 @@ export function createDiscussionService(deps: DiscussionServiceDeps) {
return {
initDiscussion,
getDiscussion,
isClosedDiscussion(channelId: string): boolean {
return isDiscussionClosed(channelId);
},
maybeSendIdleReminder,
maybeReplyClosedChannel,
handleCallback,