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

@@ -0,0 +1,79 @@
import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { resolveAckReaction } from "./identity.js";
describe("resolveAckReaction", () => {
it("prefers account-level overrides", () => {
const cfg: OpenClawConfig = {
messages: { ackReaction: "👀" },
agents: { list: [{ id: "main", identity: { emoji: "✅" } }] },
channels: {
slack: {
ackReaction: "eyes",
accounts: {
acct1: { ackReaction: " party_parrot " },
},
},
},
};
expect(resolveAckReaction(cfg, "main", { channel: "slack", accountId: "acct1" })).toBe(
"party_parrot",
);
});
it("falls back to channel-level overrides", () => {
const cfg: OpenClawConfig = {
messages: { ackReaction: "👀" },
agents: { list: [{ id: "main", identity: { emoji: "✅" } }] },
channels: {
slack: {
ackReaction: "eyes",
accounts: {
acct1: { ackReaction: "party_parrot" },
},
},
},
};
expect(resolveAckReaction(cfg, "main", { channel: "slack", accountId: "missing" })).toBe(
"eyes",
);
});
it("uses the global ackReaction when channel overrides are missing", () => {
const cfg: OpenClawConfig = {
messages: { ackReaction: "✅" },
agents: { list: [{ id: "main", identity: { emoji: "😺" } }] },
};
expect(resolveAckReaction(cfg, "main", { channel: "discord" })).toBe("✅");
});
it("falls back to the agent identity emoji when global config is unset", () => {
const cfg: OpenClawConfig = {
agents: { list: [{ id: "main", identity: { emoji: "🔥" } }] },
};
expect(resolveAckReaction(cfg, "main", { channel: "discord" })).toBe("🔥");
});
it("returns the default emoji when no config is present", () => {
const cfg: OpenClawConfig = {};
expect(resolveAckReaction(cfg, "main")).toBe("👀");
});
it("allows empty strings to disable reactions", () => {
const cfg: OpenClawConfig = {
messages: { ackReaction: "👀" },
channels: {
telegram: {
ackReaction: "",
},
},
};
expect(resolveAckReaction(cfg, "main", { channel: "telegram" })).toBe("");
});
});