Fix discussion channel closure handling
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user