fix: prevent idle reminder from re-waking dormant discussion channel
The moderator bot's own idle reminder message triggered message_received, which saw senderId != currentSpeaker and called wakeFromDormant, immediately undoing the dormant state just entered. Fix: derive the moderator bot's Discord user ID from the token and skip wake-from-dormant when the sender is the moderator bot itself. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
||||
|
||||
type Logger = { info: (m: string) => void; warn: (m: string) => void };
|
||||
|
||||
function userIdFromToken(token: string): string | undefined {
|
||||
export function userIdFromBotToken(token: string): string | undefined {
|
||||
try {
|
||||
const segment = token.split(".")[0];
|
||||
const padded = segment + "=".repeat((4 - (segment.length % 4)) % 4);
|
||||
@@ -19,7 +19,7 @@ export function resolveDiscordUserId(api: OpenClawPluginApi, accountId: string):
|
||||
const accounts = (discord.accounts as Record<string, Record<string, unknown>>) || {};
|
||||
const acct = accounts[accountId];
|
||||
if (!acct?.token || typeof acct.token !== "string") return undefined;
|
||||
return userIdFromToken(acct.token);
|
||||
return userIdFromBotToken(acct.token);
|
||||
}
|
||||
|
||||
export type ModeratorMessageResult =
|
||||
|
||||
Reference in New Issue
Block a user