mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 15:23:43 +00:00
Status reactions: fix stall timers and gating (#22190)
* feat: add shared status reaction controller * feat: add statusReactions config schema * feat: wire status reactions for Discord and Telegram * fix: restore original 10s/30s stall defaults for Discord compatibility * Status reactions: fix stall timers and gating * Format status reaction imports --------- Co-authored-by: Matt <mateus.carniatto@gmail.com>
This commit is contained in:
@@ -23,6 +23,10 @@ import { formatLocationText, toLocationContext } from "../channels/location.js";
|
||||
import { logInboundDrop } from "../channels/logging.js";
|
||||
import { resolveMentionGatingWithBypass } from "../channels/mention-gating.js";
|
||||
import { recordInboundSession } from "../channels/session.js";
|
||||
import {
|
||||
createStatusReactionController,
|
||||
type StatusReactionController,
|
||||
} from "../channels/status-reactions.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import { readSessionUpdatedAt, resolveStorePath } from "../config/sessions.js";
|
||||
@@ -521,8 +525,41 @@ export const buildTelegramMessageContext = async ({
|
||||
};
|
||||
const reactionApi =
|
||||
typeof api.setMessageReaction === "function" ? api.setMessageReaction.bind(api) : null;
|
||||
const ackReactionPromise =
|
||||
shouldAckReaction() && msg.message_id && reactionApi
|
||||
|
||||
// Status Reactions controller (lifecycle reactions)
|
||||
const statusReactionsConfig = cfg.messages?.statusReactions;
|
||||
const statusReactionsEnabled =
|
||||
statusReactionsConfig?.enabled === true && Boolean(reactionApi) && shouldAckReaction();
|
||||
const statusReactionController: StatusReactionController | null =
|
||||
statusReactionsEnabled && msg.message_id
|
||||
? createStatusReactionController({
|
||||
enabled: true,
|
||||
adapter: {
|
||||
setReaction: async (emoji: string) => {
|
||||
if (reactionApi) {
|
||||
await reactionApi(chatId, msg.message_id, [{ type: "emoji", emoji }]);
|
||||
}
|
||||
},
|
||||
// Telegram replaces atomically — no removeReaction needed
|
||||
},
|
||||
initialEmoji: ackReaction,
|
||||
emojis: statusReactionsConfig?.emojis,
|
||||
timing: statusReactionsConfig?.timing,
|
||||
onError: (err) => {
|
||||
logVerbose(`telegram status-reaction error for chat ${chatId}: ${String(err)}`);
|
||||
},
|
||||
})
|
||||
: null;
|
||||
|
||||
// When status reactions are enabled, setQueued() replaces the simple ack reaction
|
||||
const ackReactionPromise = statusReactionController
|
||||
? shouldAckReaction()
|
||||
? Promise.resolve(statusReactionController.setQueued()).then(
|
||||
() => true,
|
||||
() => false,
|
||||
)
|
||||
: null
|
||||
: shouldAckReaction() && msg.message_id && reactionApi
|
||||
? withTelegramApiErrorLogging({
|
||||
operation: "setMessageReaction",
|
||||
fn: () => reactionApi(chatId, msg.message_id, [{ type: "emoji", emoji: ackReaction }]),
|
||||
@@ -741,6 +778,7 @@ export const buildTelegramMessageContext = async ({
|
||||
ackReactionPromise,
|
||||
reactionApi,
|
||||
removeAckAfterReply,
|
||||
statusReactionController,
|
||||
accountId: account.accountId,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user