@openclaw-channel/socket-chat 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/channel.ts +2 -2
- package/src/outbound.test.ts +9 -11
- package/src/outbound.ts +2 -2
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -242,7 +242,7 @@ export const socketChatPlugin: ChannelPlugin<ResolvedSocketChatAccount> = {
|
|
|
242
242
|
normalizeTarget: normalizeSocketChatTarget,
|
|
243
243
|
targetResolver: {
|
|
244
244
|
looksLikeId: looksLikeSocketChatTargetId,
|
|
245
|
-
hint: "<contactId|group:groupId|group:groupId@
|
|
245
|
+
hint: "<contactId|group:groupId|group:groupId@userId1,userId2>",
|
|
246
246
|
},
|
|
247
247
|
},
|
|
248
248
|
|
|
@@ -386,7 +386,7 @@ export const socketChatPlugin: ChannelPlugin<ResolvedSocketChatAccount> = {
|
|
|
386
386
|
"- socket-chat: to send to a group, use target format `group:<groupId>`. " +
|
|
387
387
|
"To @mention users in a group: `group:<groupId>@<userId1>,<userId2>`.",
|
|
388
388
|
"- socket-chat: to send an image, provide a public HTTP URL as the media parameter.",
|
|
389
|
-
"- socket-chat: direct messages use the sender's contactId
|
|
389
|
+
"- socket-chat: direct messages use the sender's contactId as the target.",
|
|
390
390
|
],
|
|
391
391
|
},
|
|
392
392
|
};
|
package/src/outbound.test.ts
CHANGED
|
@@ -81,25 +81,23 @@ describe("normalizeSocketChatTarget", () => {
|
|
|
81
81
|
// ---------------------------------------------------------------------------
|
|
82
82
|
|
|
83
83
|
describe("looksLikeSocketChatTargetId", () => {
|
|
84
|
-
it("
|
|
84
|
+
it("accepts any non-empty id", () => {
|
|
85
85
|
expect(looksLikeSocketChatTargetId("wxid_abc123")).toBe(true);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("recognizes roomid_ prefix", () => {
|
|
89
86
|
expect(looksLikeSocketChatTargetId("roomid_xyz")).toBe(true);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("recognizes group: prefix", () => {
|
|
93
87
|
expect(looksLikeSocketChatTargetId("group:roomid_xxx")).toBe(true);
|
|
88
|
+
expect(looksLikeSocketChatTargetId("alice")).toBe(true);
|
|
89
|
+
expect(looksLikeSocketChatTargetId("user@example.com")).toBe(true);
|
|
94
90
|
});
|
|
95
91
|
|
|
96
|
-
it("rejects
|
|
97
|
-
expect(looksLikeSocketChatTargetId("alice")).toBe(false);
|
|
98
|
-
expect(looksLikeSocketChatTargetId("user@example.com")).toBe(false);
|
|
92
|
+
it("rejects empty string", () => {
|
|
99
93
|
expect(looksLikeSocketChatTargetId("")).toBe(false);
|
|
100
94
|
});
|
|
101
95
|
|
|
102
|
-
it("
|
|
96
|
+
it("rejects whitespace-only string", () => {
|
|
97
|
+
expect(looksLikeSocketChatTargetId(" ")).toBe(false);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("trims before checking", () => {
|
|
103
101
|
expect(looksLikeSocketChatTargetId(" wxid_abc")).toBe(true);
|
|
104
102
|
});
|
|
105
103
|
});
|
package/src/outbound.ts
CHANGED
|
@@ -46,10 +46,10 @@ export function normalizeSocketChatTarget(raw: string): string | undefined {
|
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* 判断字符串是否像一个 socket-chat 原生 ID
|
|
49
|
-
*
|
|
49
|
+
* socket-chat 的 chatId 格式不固定,任何非空字符串均视为原生 ID
|
|
50
50
|
*/
|
|
51
51
|
export function looksLikeSocketChatTargetId(s: string): boolean {
|
|
52
|
-
return
|
|
52
|
+
return s.trim().length > 0;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|