mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 21:08:25 +00:00
feat: support per-channel ackReaction config (#17092) (thanks @zerone0x)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user