@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw-channel/socket-chat",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "OpenClaw Socket Chat channel plugin — MQTT-based IM bridge",
5
5
  "type": "module",
6
6
  "publishConfig": {
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@wxid_mention1,wxid_mention2>",
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 (e.g. `wxid_xxx`) as the target.",
389
+ "- socket-chat: direct messages use the sender's contactId as the target.",
390
390
  ],
391
391
  },
392
392
  };
@@ -81,25 +81,23 @@ describe("normalizeSocketChatTarget", () => {
81
81
  // ---------------------------------------------------------------------------
82
82
 
83
83
  describe("looksLikeSocketChatTargetId", () => {
84
- it("recognizes wxid_ prefix", () => {
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 arbitrary strings", () => {
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("trims leading whitespace before checking", () => {
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
- * wxid_xxx / roomid_xxx 格式,或带 group: 前缀
49
+ * socket-chat chatId 格式不固定,任何非空字符串均视为原生 ID
50
50
  */
51
51
  export function looksLikeSocketChatTargetId(s: string): boolean {
52
- return /^(wxid_|roomid_|group:)/.test(s.trim());
52
+ return s.trim().length > 0;
53
53
  }
54
54
 
55
55
  /**