@gloablehive/ipad-wechat-plugin 1.0.15 → 1.0.16

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.
Files changed (3) hide show
  1. package/dist/index.js +10 -35
  2. package/index.ts +11 -39
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16,11 +16,19 @@ export default defineChannelPluginEntry({
16
16
  description: "Connect OpenClaw to iPad WeChat protocol for sending and receiving WeChat messages",
17
17
  plugin: ipadWeChatPlugin,
18
18
  registerFull(api) {
19
- // Register main webhook endpoint for receiving messages
19
+ // Register webhook endpoint for receiving messages
20
+ // Using /api/channels/ prefix like other plugins
20
21
  api.registerHttpRoute({
21
- path: "/ipad-wechat/webhook",
22
+ path: "/api/channels/ipad-wechat",
22
23
  auth: "plugin",
24
+ match: "prefix",
23
25
  handler: async (req, res) => {
26
+ // Check if it's a webhook request
27
+ const path = req.url || "";
28
+ if (!path.includes("/webhook")) {
29
+ // Not a webhook request, let it pass through
30
+ return false;
31
+ }
24
32
  try {
25
33
  // Get config from request
26
34
  const cfg = req.cfg;
@@ -46,38 +54,5 @@ export default defineChannelPluginEntry({
46
54
  }
47
55
  },
48
56
  });
49
- // Register per-guid webhook endpoints for multi-account routing
50
- // These paths allow distinguishing which account received the message
51
- // Path format: /ipad-wechat/webhook/guid-12345
52
- api.registerHttpRoute({
53
- path: "/ipad-wechat/webhook/:guid",
54
- auth: "plugin",
55
- handler: async (req, res) => {
56
- try {
57
- const cfg = req.cfg;
58
- const guid = req.params?.guid;
59
- // Wait for cache manager to be ready
60
- const ready = getCacheManagerReady();
61
- if (ready) {
62
- await ready;
63
- }
64
- const payload = req.body;
65
- console.log(`[iPad WeChat] Received webhook for guid ${guid}:`, payload);
66
- if (payload) {
67
- // Pass the guid as overrideAccountId so handleInboundMessage knows which account
68
- await handleInboundMessage(api, payload, cfg, guid);
69
- }
70
- res.statusCode = 200;
71
- res.end("ok");
72
- return true;
73
- }
74
- catch (error) {
75
- console.error("[iPad WeChat] Webhook error:", error);
76
- res.statusCode = 500;
77
- res.end("Internal error");
78
- return true;
79
- }
80
- },
81
- });
82
57
  },
83
58
  });
package/index.ts CHANGED
@@ -19,11 +19,20 @@ export default defineChannelPluginEntry({
19
19
  plugin: ipadWeChatPlugin,
20
20
 
21
21
  registerFull(api) {
22
- // Register main webhook endpoint for receiving messages
22
+ // Register webhook endpoint for receiving messages
23
+ // Using /api/channels/ prefix like other plugins
23
24
  api.registerHttpRoute({
24
- path: "/ipad-wechat/webhook",
25
+ path: "/api/channels/ipad-wechat",
25
26
  auth: "plugin",
27
+ match: "prefix",
26
28
  handler: async (req, res) => {
29
+ // Check if it's a webhook request
30
+ const path = (req as any).url || "";
31
+ if (!path.includes("/webhook")) {
32
+ // Not a webhook request, let it pass through
33
+ return false;
34
+ }
35
+
27
36
  try {
28
37
  // Get config from request
29
38
  const cfg = (req as any).cfg;
@@ -52,42 +61,5 @@ export default defineChannelPluginEntry({
52
61
  }
53
62
  },
54
63
  });
55
-
56
- // Register per-guid webhook endpoints for multi-account routing
57
- // These paths allow distinguishing which account received the message
58
- // Path format: /ipad-wechat/webhook/guid-12345
59
- api.registerHttpRoute({
60
- path: "/ipad-wechat/webhook/:guid",
61
- auth: "plugin",
62
- handler: async (req, res) => {
63
- try {
64
- const cfg = (req as any).cfg;
65
- const guid = (req as any).params?.guid;
66
-
67
- // Wait for cache manager to be ready
68
- const ready = getCacheManagerReady();
69
- if (ready) {
70
- await ready;
71
- }
72
-
73
- const payload = (req as any).body;
74
- console.log(`[iPad WeChat] Received webhook for guid ${guid}:`, payload);
75
-
76
- if (payload) {
77
- // Pass the guid as overrideAccountId so handleInboundMessage knows which account
78
- await handleInboundMessage(api, payload, cfg, guid);
79
- }
80
-
81
- res.statusCode = 200;
82
- res.end("ok");
83
- return true;
84
- } catch (error) {
85
- console.error("[iPad WeChat] Webhook error:", error);
86
- res.statusCode = 500;
87
- res.end("Internal error");
88
- return true;
89
- }
90
- },
91
- });
92
64
  },
93
65
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gloablehive/ipad-wechat-plugin",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "type": "module",
5
5
  "description": "OpenClaw channel plugin for iPad WeChat protocol - enables sending/receiving WeChat messages through iPad protocol",
6
6
  "main": "index.ts",