feat: support per-channel ackReaction config (#17092) (thanks @zerone0x)

This commit is contained in:
Shadow
2026-02-15 11:29:51 -06:00
committed by Shadow
parent b3ef3fca75
commit b6069fc68c
14 changed files with 189 additions and 4 deletions

View File

@@ -10,11 +10,37 @@ export function resolveAgentIdentity(
return resolveAgentConfig(cfg, agentId)?.identity;
}
export function resolveAckReaction(cfg: OpenClawConfig, agentId: string): string {
export function resolveAckReaction(
cfg: OpenClawConfig,
agentId: string,
opts?: { channel?: string; accountId?: string },
): string {
// L1: Channel account level
if (opts?.channel && opts?.accountId) {
const channelCfg = getChannelConfig(cfg, opts.channel);
const accounts = channelCfg?.accounts as Record<string, Record<string, unknown>> | undefined;
const accountReaction = accounts?.[opts.accountId]?.ackReaction as string | undefined;
if (accountReaction !== undefined) {
return accountReaction.trim();
}
}
// L2: Channel level
if (opts?.channel) {
const channelCfg = getChannelConfig(cfg, opts.channel);
const channelReaction = channelCfg?.ackReaction as string | undefined;
if (channelReaction !== undefined) {
return channelReaction.trim();
}
}
// L3: Global messages level
const configured = cfg.messages?.ackReaction;
if (configured !== undefined) {
return configured.trim();
}
// L4: Agent identity emoji fallback
const emoji = resolveAgentIdentity(cfg, agentId)?.emoji?.trim();
return emoji || DEFAULT_ACK_REACTION;
}