Skip to content

Commit 8ca6bce

Browse files
committed
fix(twitch): send channel-prefixed targets to Twitch channels
1 parent a674ce5 commit 8ca6bce

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎extensions/twitch/src/plugin.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@ describe("twitchPlugin pairing", () => {
1111
});
1212

1313
describe("twitchPlugin outbound session routing", () => {
14+
it("normalizes channel-prefixed Twitch targets for message sends", () => {
15+
expect(twitchPlugin.messaging?.targetPrefixes).toEqual(["twitch", "twitch-chat"]);
16+
expect(twitchPlugin.messaging?.normalizeTarget?.(" twitch:channel:OpenClaw ")).toBe(
17+
"openclaw",
18+
);
19+
expect(twitchPlugin.messaging?.normalizeTarget?.("twitch-chat:group:OpenClaw")).toBe(
20+
"openclaw",
21+
);
22+
expect(twitchPlugin.messaging?.normalizeTarget?.("#OpenClaw")).toBe("openclaw");
23+
});
24+
25+
it.each(["twitch:user:alice", "twitch:dm:alice"])(
26+
"normalizes unsupported direct target %s to an empty target",
27+
(target) => {
28+
expect(twitchPlugin.messaging?.normalizeTarget?.(target)).toBe("");
29+
},
30+
);
31+
1432
it("reproduces the canonical inbound channel session", async () => {
1533
const route = await twitchPlugin.messaging?.resolveOutboundSessionRoute?.({
1634
cfg: {},

‎extensions/twitch/src/plugin.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ export const twitchPlugin: ChannelPlugin<ResolvedTwitchAccount> =
9797
chatTypes: ["group"],
9898
},
9999
messaging: {
100+
targetPrefixes: ["twitch", "twitch-chat"],
101+
normalizeTarget: normalizeTwitchMessagingTarget,
100102
resolveOutboundSessionRoute: ({ cfg, agentId, accountId, target }) => {
101103
const channel = normalizeTwitchMessagingTarget(target);
102104
if (!channel) {

0 commit comments

Comments
 (0)