@gloablehive/ipad-wechat-plugin 1.0.0 → 1.0.2
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/dist/index.js +40 -0
- package/dist/openclaw.plugin.json +98 -0
- package/dist/src/channel.js +243 -0
- package/dist/src/client.js +610 -0
- package/index.ts +7 -2
- package/openclaw.plugin.json +11 -7
- package/package.json +3 -2
- package/src/channel.ts +73 -27
- package/src/client.ts +660 -155
- package/test-ipad-real.ts +77 -0
- package/test-ipad.ts +150 -0
- package/tsconfig.json +8 -2
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* iPad WeChat API Client (聚合聊天开放平台)
|
|
3
|
+
*
|
|
4
|
+
* Gateway: https://chat-api.juhebot.com/open/GuidRequest
|
|
5
|
+
* 文档: data/ipad-wechat/AI-READABLE-OVERVIEW.md
|
|
6
|
+
* API Paths: data/ipad-wechat/apifox/apis/
|
|
7
|
+
*/
|
|
8
|
+
const GATEWAY_URL = "https://chat-api.juhebot.com/open/GuidRequest";
|
|
9
|
+
/**
|
|
10
|
+
* Call JuHeBot API Gateway
|
|
11
|
+
*/
|
|
12
|
+
async function callApi(config, path, data) {
|
|
13
|
+
const requestBody = {
|
|
14
|
+
app_key: config.appKey,
|
|
15
|
+
app_secret: config.appSecret,
|
|
16
|
+
path,
|
|
17
|
+
data: {
|
|
18
|
+
guid: config.guid,
|
|
19
|
+
...data,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
console.log('[JuHeBot API] Request:', { path, data: requestBody.data });
|
|
23
|
+
const response = await fetch(GATEWAY_URL, {
|
|
24
|
+
method: "POST",
|
|
25
|
+
headers: {
|
|
26
|
+
"Content-Type": "application/json",
|
|
27
|
+
},
|
|
28
|
+
body: JSON.stringify(requestBody),
|
|
29
|
+
});
|
|
30
|
+
const result = await response.json();
|
|
31
|
+
console.log('[JuHeBot API] Response:', result);
|
|
32
|
+
// Handle error response
|
|
33
|
+
if (result.err_code !== undefined && result.err_code !== 0) {
|
|
34
|
+
throw new Error(`API Error: ${result.err_msg} (code: ${result.err_code})`);
|
|
35
|
+
}
|
|
36
|
+
if (result.code !== undefined && result.code !== 0) {
|
|
37
|
+
throw new Error(`API Error: ${result.msg} (code: ${result.code})`);
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
export function createIPadClient(config) {
|
|
42
|
+
return {
|
|
43
|
+
// ========== 实例管理 (Instance) ==========
|
|
44
|
+
/**
|
|
45
|
+
* 获取实例状态
|
|
46
|
+
* Path: /instance/get_status
|
|
47
|
+
*/
|
|
48
|
+
async getDeviceStatus() {
|
|
49
|
+
return await callApi(config, "/instance/get_status", {});
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* 恢复实例
|
|
53
|
+
* Path: /instance/restore
|
|
54
|
+
*/
|
|
55
|
+
async restoreInstance() {
|
|
56
|
+
return await callApi(config, "/instance/restore", {});
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* 停止实例
|
|
60
|
+
* Path: /instance/stop
|
|
61
|
+
*/
|
|
62
|
+
async stopInstance() {
|
|
63
|
+
return await callApi(config, "/instance/stop", {});
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* 设置实例通知地址 (回调地址)
|
|
67
|
+
* Path: /instance/set_notify_url
|
|
68
|
+
*/
|
|
69
|
+
async setNotifyUrl(notifyUrl) {
|
|
70
|
+
await callApi(config, "/instance/set_notify_url", { notifyUrl });
|
|
71
|
+
},
|
|
72
|
+
/**
|
|
73
|
+
* 设置实例桥接ID
|
|
74
|
+
* Path: /instance/set_bridge_id
|
|
75
|
+
*/
|
|
76
|
+
async setBridgeId(bridgeId) {
|
|
77
|
+
await callApi(config, "/instance/set_bridge_id", { bridgeId });
|
|
78
|
+
},
|
|
79
|
+
// ========== 用户 (User) ==========
|
|
80
|
+
/**
|
|
81
|
+
* 获取登录账号信息
|
|
82
|
+
* Path: /user/get_profile
|
|
83
|
+
*/
|
|
84
|
+
async getLoginAccountInfo() {
|
|
85
|
+
const res = await callApi(config, "/user/get_profile", {});
|
|
86
|
+
return res.data || {};
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* 获取个人二维码
|
|
90
|
+
* Path: /user/get_qrcode
|
|
91
|
+
*/
|
|
92
|
+
async getQRCode() {
|
|
93
|
+
return await callApi(config, "/user/get_qrcode", {});
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* 退出登录
|
|
97
|
+
* Path: /user/logout
|
|
98
|
+
*/
|
|
99
|
+
async logout() {
|
|
100
|
+
return await callApi(config, "/user/logout", {});
|
|
101
|
+
},
|
|
102
|
+
// ========== 联系人 (Contact) ==========
|
|
103
|
+
/**
|
|
104
|
+
* 同步联系人
|
|
105
|
+
* Path: /contact/init_contact
|
|
106
|
+
*/
|
|
107
|
+
async syncContacts() {
|
|
108
|
+
const res = await callApi(config, "/contact/init_contact", {});
|
|
109
|
+
// API returns contactUsernameList array directly in response
|
|
110
|
+
const contactList = res.contactUsernameList || res.data?.contactUsernameList || [];
|
|
111
|
+
// Convert to Contact format (wechatId is the username)
|
|
112
|
+
return contactList.map((wechatId) => ({
|
|
113
|
+
wechatId,
|
|
114
|
+
nickName: "",
|
|
115
|
+
remark: "",
|
|
116
|
+
}));
|
|
117
|
+
},
|
|
118
|
+
/**
|
|
119
|
+
* 获取联系人详细
|
|
120
|
+
* Path: /contact/get_contact
|
|
121
|
+
*/
|
|
122
|
+
async getContactDetail(wechatId) {
|
|
123
|
+
const res = await callApi(config, "/contact/get_contact", { userId: wechatId });
|
|
124
|
+
return res.data || {};
|
|
125
|
+
},
|
|
126
|
+
/**
|
|
127
|
+
* 批量获取联系人简要信息
|
|
128
|
+
* Path: /contact/batch_get_contact_brief_info
|
|
129
|
+
*/
|
|
130
|
+
async batchGetContactBriefInfo(wechatIds) {
|
|
131
|
+
const res = await callApi(config, "/contact/batch_get_contact_brief_info", { userIds: wechatIds });
|
|
132
|
+
return res.data?.contacts || [];
|
|
133
|
+
},
|
|
134
|
+
/**
|
|
135
|
+
* 搜索联系人
|
|
136
|
+
* Path: /contact/search_contact
|
|
137
|
+
*/
|
|
138
|
+
async searchContact(searchType, value) {
|
|
139
|
+
return await callApi(config, "/contact/search_contact", { searchType, value });
|
|
140
|
+
},
|
|
141
|
+
/**
|
|
142
|
+
* 添加好友
|
|
143
|
+
* Path: /contact/add_friend
|
|
144
|
+
*/
|
|
145
|
+
async addFriend(v3, verifyMessage) {
|
|
146
|
+
return await callApi(config, "/contact/add_friend", { v3, verifyMessage });
|
|
147
|
+
},
|
|
148
|
+
/**
|
|
149
|
+
* 验证好友申请
|
|
150
|
+
* Path: /contact/verify_friend
|
|
151
|
+
*/
|
|
152
|
+
async verifyFriend(who, status, ticket) {
|
|
153
|
+
return await callApi(config, "/contact/verify_friend", { who, status, ticket });
|
|
154
|
+
},
|
|
155
|
+
/**
|
|
156
|
+
* 修改好友备注
|
|
157
|
+
* Path: /contact/modify_remark
|
|
158
|
+
*/
|
|
159
|
+
async updateFriendRemark(wechatId, remark) {
|
|
160
|
+
await callApi(config, "/contact/modify_remark", { userId: wechatId, remark });
|
|
161
|
+
},
|
|
162
|
+
/**
|
|
163
|
+
* 删除好友
|
|
164
|
+
* Path: /contact/del_friend
|
|
165
|
+
*/
|
|
166
|
+
async deleteFriend(wechatId) {
|
|
167
|
+
return await callApi(config, "/contact/del_friend", { userId: wechatId });
|
|
168
|
+
},
|
|
169
|
+
/**
|
|
170
|
+
* 置顶聊天
|
|
171
|
+
* Path: /contact/modify_contact_top_flag
|
|
172
|
+
*/
|
|
173
|
+
async setContactTop(wechatId, flag) {
|
|
174
|
+
return await callApi(config, "/contact/modify_contact_top_flag", { userId: wechatId, flag });
|
|
175
|
+
},
|
|
176
|
+
// ========== 消息发送 (Msg) ==========
|
|
177
|
+
/**
|
|
178
|
+
* 发送文本消息
|
|
179
|
+
* Path: /msg/send_text
|
|
180
|
+
*/
|
|
181
|
+
async sendFriendMessage(params) {
|
|
182
|
+
const res = await callApi(config, "/msg/send_text", {
|
|
183
|
+
toUser: params.friendWechatId,
|
|
184
|
+
content: params.content,
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
messageId: res.data?.messageId || `msg_${Date.now()}`,
|
|
188
|
+
msgSvrId: res.data?.msgSvrId || "",
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
/**
|
|
192
|
+
* 发送群@消息
|
|
193
|
+
* Path: /msg/send_room_at
|
|
194
|
+
*/
|
|
195
|
+
async sendRoomMessage(params) {
|
|
196
|
+
const res = await callApi(config, "/msg/send_room_at", {
|
|
197
|
+
roomId: params.roomId,
|
|
198
|
+
content: params.content,
|
|
199
|
+
});
|
|
200
|
+
return {
|
|
201
|
+
messageId: res.data?.messageId || `msg_${Date.now()}`,
|
|
202
|
+
msgSvrId: res.data?.msgSvrId || "",
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
/**
|
|
206
|
+
* 发送图片
|
|
207
|
+
* Path: /msg/send_image
|
|
208
|
+
*/
|
|
209
|
+
async sendFriendMedia(params) {
|
|
210
|
+
const res = await callApi(config, "/msg/send_image", {
|
|
211
|
+
toUser: params.friendWechatId,
|
|
212
|
+
filePath: params.filePath,
|
|
213
|
+
});
|
|
214
|
+
return {
|
|
215
|
+
messageId: res.data?.messageId || `msg_${Date.now()}`,
|
|
216
|
+
msgSvrId: res.data?.msgSvrId || "",
|
|
217
|
+
};
|
|
218
|
+
},
|
|
219
|
+
/**
|
|
220
|
+
* 发送图片到群
|
|
221
|
+
* Path: /msg/send_image (复用)
|
|
222
|
+
*/
|
|
223
|
+
async sendRoomMedia(params) {
|
|
224
|
+
const res = await callApi(config, "/msg/send_image", {
|
|
225
|
+
roomId: params.roomId,
|
|
226
|
+
filePath: params.filePath,
|
|
227
|
+
});
|
|
228
|
+
return {
|
|
229
|
+
messageId: res.data?.messageId || `msg_${Date.now()}`,
|
|
230
|
+
msgSvrId: res.data?.msgSvrId || "",
|
|
231
|
+
};
|
|
232
|
+
},
|
|
233
|
+
/**
|
|
234
|
+
* 发送视频
|
|
235
|
+
* Path: /msg/send_video
|
|
236
|
+
*/
|
|
237
|
+
async sendVideo(params) {
|
|
238
|
+
const res = await callApi(config, "/msg/send_video", params);
|
|
239
|
+
return {
|
|
240
|
+
messageId: res.data?.messageId || `msg_${Date.now()}`,
|
|
241
|
+
msgSvrId: res.data?.msgSvrId || "",
|
|
242
|
+
};
|
|
243
|
+
},
|
|
244
|
+
/**
|
|
245
|
+
* 发送文件
|
|
246
|
+
* Path: /msg/send_file
|
|
247
|
+
*/
|
|
248
|
+
async sendFile(params) {
|
|
249
|
+
const res = await callApi(config, "/msg/send_file", params);
|
|
250
|
+
return {
|
|
251
|
+
messageId: res.data?.messageId || `msg_${Date.now()}`,
|
|
252
|
+
msgSvrId: res.data?.msgSvrId || "",
|
|
253
|
+
};
|
|
254
|
+
},
|
|
255
|
+
/**
|
|
256
|
+
* 发送位置
|
|
257
|
+
* Path: /msg/send_location
|
|
258
|
+
*/
|
|
259
|
+
async sendLocation(params) {
|
|
260
|
+
return await callApi(config, "/msg/send_location", params);
|
|
261
|
+
},
|
|
262
|
+
/**
|
|
263
|
+
* 发送名片
|
|
264
|
+
* Path: /msg/send_share_card
|
|
265
|
+
*/
|
|
266
|
+
async sendCard(params) {
|
|
267
|
+
return await callApi(config, "/msg/send_share_card", params);
|
|
268
|
+
},
|
|
269
|
+
/**
|
|
270
|
+
* 发送链接卡片
|
|
271
|
+
* Path: /msg/send_link_card
|
|
272
|
+
*/
|
|
273
|
+
async sendLink(params) {
|
|
274
|
+
return await callApi(config, "/msg/send_link_card", params);
|
|
275
|
+
},
|
|
276
|
+
/**
|
|
277
|
+
* 发送表情
|
|
278
|
+
* Path: /msg/send_emoji
|
|
279
|
+
*/
|
|
280
|
+
async sendEmoji(params) {
|
|
281
|
+
return await callApi(config, "/msg/send_emoji", params);
|
|
282
|
+
},
|
|
283
|
+
/**
|
|
284
|
+
* 发送表情URL
|
|
285
|
+
* Path: /msg/send_emoji_url
|
|
286
|
+
*/
|
|
287
|
+
async sendEmojiUrl(params) {
|
|
288
|
+
return await callApi(config, "/msg/send_emoji_url", params);
|
|
289
|
+
},
|
|
290
|
+
/**
|
|
291
|
+
* 发送拍一拍
|
|
292
|
+
* Path: /msg/send_pat
|
|
293
|
+
*/
|
|
294
|
+
async sendPat(roomId, userId) {
|
|
295
|
+
return await callApi(config, "/msg/send_pat", { roomId, userId });
|
|
296
|
+
},
|
|
297
|
+
/**
|
|
298
|
+
* 撤回消息
|
|
299
|
+
* Path: /msg/recall
|
|
300
|
+
*/
|
|
301
|
+
async recallMessage(msgId) {
|
|
302
|
+
return await callApi(config, "/msg/recall", { msgId });
|
|
303
|
+
},
|
|
304
|
+
/**
|
|
305
|
+
* 发送引用消息
|
|
306
|
+
* Path: /msg/send_refer_msg
|
|
307
|
+
*/
|
|
308
|
+
async sendReferMsg(params) {
|
|
309
|
+
return await callApi(config, "/msg/send_refer_msg", params);
|
|
310
|
+
},
|
|
311
|
+
// ========== 群组 (Room) ==========
|
|
312
|
+
/**
|
|
313
|
+
* 获取群信息
|
|
314
|
+
* Path: /room/get_chatroom_detail
|
|
315
|
+
*/
|
|
316
|
+
async getRoomInfo(roomId) {
|
|
317
|
+
const res = await callApi(config, "/room/get_chatroom_detail", { roomId });
|
|
318
|
+
return res.data || {};
|
|
319
|
+
},
|
|
320
|
+
/**
|
|
321
|
+
* 获取群成员详细
|
|
322
|
+
* Path: /room/get_chatroom_member_detail
|
|
323
|
+
*/
|
|
324
|
+
async getRoomMembers(roomId) {
|
|
325
|
+
const res = await callApi(config, "/room/get_chatroom_member_detail", { roomId });
|
|
326
|
+
return res.data?.members || [];
|
|
327
|
+
},
|
|
328
|
+
/**
|
|
329
|
+
* 创建群组
|
|
330
|
+
* Path: /room/create_chatroom
|
|
331
|
+
*/
|
|
332
|
+
async createRoom(memberIds) {
|
|
333
|
+
const res = await callApi(config, "/room/create_chatroom", { memberIds });
|
|
334
|
+
return { roomId: res.data?.roomId || "" };
|
|
335
|
+
},
|
|
336
|
+
/**
|
|
337
|
+
* 添加群成员
|
|
338
|
+
* Path: /room/add_chatroom_member
|
|
339
|
+
*/
|
|
340
|
+
async addRoomMember(roomId, memberId) {
|
|
341
|
+
await callApi(config, "/room/add_chatroom_member", { roomId, memberId });
|
|
342
|
+
},
|
|
343
|
+
/**
|
|
344
|
+
* 邀请群成员
|
|
345
|
+
* Path: /room/invite_chatroom_member
|
|
346
|
+
*/
|
|
347
|
+
async inviteRoomMember(roomId, memberId) {
|
|
348
|
+
await callApi(config, "/room/invite_chatroom_member", { roomId, memberId });
|
|
349
|
+
},
|
|
350
|
+
/**
|
|
351
|
+
* 移除群成员
|
|
352
|
+
* Path: /room/del_chatroom_member
|
|
353
|
+
*/
|
|
354
|
+
async removeRoomMember(roomId, memberId) {
|
|
355
|
+
await callApi(config, "/room/del_chatroom_member", { roomId, memberId });
|
|
356
|
+
},
|
|
357
|
+
/**
|
|
358
|
+
* 修改群名称
|
|
359
|
+
* Path: /room/modify_chatroom_name
|
|
360
|
+
*/
|
|
361
|
+
async updateRoomName(roomId, name) {
|
|
362
|
+
await callApi(config, "/room/modify_chatroom_name", { roomId, name });
|
|
363
|
+
},
|
|
364
|
+
/**
|
|
365
|
+
* 设置群公告
|
|
366
|
+
* Path: /room/set_chatroom_announcement
|
|
367
|
+
*/
|
|
368
|
+
async setRoomAnnouncement(roomId, announcement) {
|
|
369
|
+
await callApi(config, "/room/set_chatroom_announcement", { roomId, announcement });
|
|
370
|
+
},
|
|
371
|
+
/**
|
|
372
|
+
* 修改群显示昵称
|
|
373
|
+
* Path: /room/modify_chatroom_display_name
|
|
374
|
+
*/
|
|
375
|
+
async setRoomDisplayName(roomId, displayName) {
|
|
376
|
+
await callApi(config, "/room/modify_chatroom_display_name", { roomId, displayName });
|
|
377
|
+
},
|
|
378
|
+
/**
|
|
379
|
+
* 是否显示群成员昵称
|
|
380
|
+
* Path: /room/modify_chatroom_show_name_flag
|
|
381
|
+
*/
|
|
382
|
+
async setRoomShowNameFlag(roomId, flag) {
|
|
383
|
+
await callApi(config, "/room/modify_chatroom_show_name_flag", { roomId, flag });
|
|
384
|
+
},
|
|
385
|
+
/**
|
|
386
|
+
* 是否保存到通讯录
|
|
387
|
+
* Path: /room/modify_chatroom_contact_flag
|
|
388
|
+
*/
|
|
389
|
+
async setRoomContactFlag(roomId, flag) {
|
|
390
|
+
await callApi(config, "/room/modify_chatroom_contact_flag", { roomId, flag });
|
|
391
|
+
},
|
|
392
|
+
/**
|
|
393
|
+
* 是否折叠群
|
|
394
|
+
* Path: /room/modify_chatroom_fold_flag
|
|
395
|
+
*/
|
|
396
|
+
async setRoomFoldFlag(roomId, flag) {
|
|
397
|
+
await callApi(config, "/room/modify_chatroom_fold_flag", { roomId, flag });
|
|
398
|
+
},
|
|
399
|
+
/**
|
|
400
|
+
* 消息免打扰
|
|
401
|
+
* Path: /room/modify_chatroom_disturb_flag
|
|
402
|
+
*/
|
|
403
|
+
async setRoomDisturbFlag(roomId, flag) {
|
|
404
|
+
await callApi(config, "/room/modify_chatroom_disturb_flag", { roomId, flag });
|
|
405
|
+
},
|
|
406
|
+
/**
|
|
407
|
+
* 添加群成员为好友
|
|
408
|
+
* Path: /room/add_chatroom_member_friend
|
|
409
|
+
*/
|
|
410
|
+
async addRoomMemberAsFriend(roomId, memberId) {
|
|
411
|
+
return await callApi(config, "/room/add_chatroom_member_friend", { roomId, memberId });
|
|
412
|
+
},
|
|
413
|
+
/**
|
|
414
|
+
* 退出群
|
|
415
|
+
* Path: /room/quit_chatroom
|
|
416
|
+
*/
|
|
417
|
+
async quitRoom(roomId) {
|
|
418
|
+
return await callApi(config, "/room/quit_chatroom", { roomId });
|
|
419
|
+
},
|
|
420
|
+
/**
|
|
421
|
+
* 转让群主
|
|
422
|
+
* Path: /room/tranfer_chatroom_owner
|
|
423
|
+
*/
|
|
424
|
+
async transferRoomOwner(roomId, newOwnerId) {
|
|
425
|
+
return await callApi(config, "/room/tranfer_chatroom_owner", { roomId, newOwnerId });
|
|
426
|
+
},
|
|
427
|
+
/**
|
|
428
|
+
* 获取群二维码
|
|
429
|
+
* Path: /room/get_chatroom_qrcode
|
|
430
|
+
*/
|
|
431
|
+
async getRoomQRCode(roomId) {
|
|
432
|
+
return await callApi(config, "/room/get_chatroom_qrcode", { roomId });
|
|
433
|
+
},
|
|
434
|
+
/**
|
|
435
|
+
* 置顶消息
|
|
436
|
+
* Path: /room/set_top_msg
|
|
437
|
+
*/
|
|
438
|
+
async setTopMsg(roomId, msgId) {
|
|
439
|
+
return await callApi(config, "/room/set_top_msg", { roomId, msgId });
|
|
440
|
+
},
|
|
441
|
+
/**
|
|
442
|
+
* 取消置顶消息
|
|
443
|
+
* Path: /room/remove_top_msg
|
|
444
|
+
*/
|
|
445
|
+
async removeTopMsg(roomId, msgId) {
|
|
446
|
+
return await callApi(config, "/room/remove_top_msg", { roomId, msgId });
|
|
447
|
+
},
|
|
448
|
+
// ========== 朋友圈 (SNS) ==========
|
|
449
|
+
/**
|
|
450
|
+
* 获取朋友圈动态
|
|
451
|
+
* Path: /sns/sns_timeline
|
|
452
|
+
*/
|
|
453
|
+
async getMoments(limit = 20) {
|
|
454
|
+
const res = await callApi(config, "/sns/sns_timeline", { limit });
|
|
455
|
+
return res.data?.moments || [];
|
|
456
|
+
},
|
|
457
|
+
/**
|
|
458
|
+
* 获取好友朋友圈动态
|
|
459
|
+
* Path: /sns/sns_userpage
|
|
460
|
+
*/
|
|
461
|
+
async getFriendMoments(wechatId, limit = 20) {
|
|
462
|
+
const res = await callApi(config, "/sns/sns_userpage", { userId: wechatId, limit });
|
|
463
|
+
return res.data?.moments || [];
|
|
464
|
+
},
|
|
465
|
+
/**
|
|
466
|
+
* 发布朋友圈
|
|
467
|
+
* Path: /sns/sns_post
|
|
468
|
+
*/
|
|
469
|
+
async publishMoment(content, images) {
|
|
470
|
+
await callApi(config, "/sns/sns_post", { content, images });
|
|
471
|
+
},
|
|
472
|
+
/**
|
|
473
|
+
* 删除朋友圈
|
|
474
|
+
* Path: /sns/sns_delete
|
|
475
|
+
*/
|
|
476
|
+
async deleteMoment(snsId) {
|
|
477
|
+
await callApi(config, "/sns/sns_delete", { snsId });
|
|
478
|
+
},
|
|
479
|
+
/**
|
|
480
|
+
* 朋友圈评论
|
|
481
|
+
* Path: /sns/sns_comment
|
|
482
|
+
*/
|
|
483
|
+
async commentMoment(snsId, content, replyId) {
|
|
484
|
+
return await callApi(config, "/sns/sns_comment", { snsId, content, replyId });
|
|
485
|
+
},
|
|
486
|
+
/**
|
|
487
|
+
* 删除评论
|
|
488
|
+
* Path: /sns/sns_delete_comment
|
|
489
|
+
*/
|
|
490
|
+
async deleteComment(snsId, commentId) {
|
|
491
|
+
await callApi(config, "/sns/sns_delete_comment", { snsId, commentId });
|
|
492
|
+
},
|
|
493
|
+
/**
|
|
494
|
+
* 点赞/取消点赞
|
|
495
|
+
* Path: /sns/sns_like
|
|
496
|
+
*/
|
|
497
|
+
async likeMoment(snsId, type) {
|
|
498
|
+
return await callApi(config, "/sns/sns_like", { snsId, type });
|
|
499
|
+
},
|
|
500
|
+
// ========== 云存储 (Cloud) ==========
|
|
501
|
+
/**
|
|
502
|
+
* 上传文件
|
|
503
|
+
* Path: /cloud/upload
|
|
504
|
+
*/
|
|
505
|
+
async uploadFile(filePath) {
|
|
506
|
+
return await callApi(config, "/cloud/upload", { filePath });
|
|
507
|
+
},
|
|
508
|
+
/**
|
|
509
|
+
* 上传大文件
|
|
510
|
+
* Path: /cloud/upload_big
|
|
511
|
+
*/
|
|
512
|
+
async uploadBigFile(filePath) {
|
|
513
|
+
return await callApi(config, "/cloud/upload_big", { filePath });
|
|
514
|
+
},
|
|
515
|
+
/**
|
|
516
|
+
* CDN 上传
|
|
517
|
+
* Path: /cloud/cdn_upload
|
|
518
|
+
*/
|
|
519
|
+
async cdnUpload(filePath) {
|
|
520
|
+
return await callApi(config, "/cloud/cdn_upload", { filePath });
|
|
521
|
+
},
|
|
522
|
+
/**
|
|
523
|
+
* 下载文件
|
|
524
|
+
* Path: /cloud/download
|
|
525
|
+
*/
|
|
526
|
+
async downloadFile(fileId, savePath) {
|
|
527
|
+
return await callApi(config, "/cloud/download", { fileId, savePath });
|
|
528
|
+
},
|
|
529
|
+
/**
|
|
530
|
+
* CDN 下载
|
|
531
|
+
* Path: /cloud/cdn_download
|
|
532
|
+
*/
|
|
533
|
+
async cdnDownload(url, savePath) {
|
|
534
|
+
return await callApi(config, "/cloud/cdn_download", { url, savePath });
|
|
535
|
+
},
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* API 路径映射表 (完整)
|
|
540
|
+
*/
|
|
541
|
+
export const API_PATHS = {
|
|
542
|
+
// 实例管理
|
|
543
|
+
instanceGetStatus: "/instance/get_status",
|
|
544
|
+
instanceRestore: "/instance/restore",
|
|
545
|
+
instanceStop: "/instance/stop",
|
|
546
|
+
instanceSetNotifyUrl: "/instance/set_notify_url",
|
|
547
|
+
instanceSetBridgeId: "/instance/set_bridge_id",
|
|
548
|
+
// 用户
|
|
549
|
+
userGetProfile: "/user/get_profile",
|
|
550
|
+
userGetQRCode: "/user/get_qrcode",
|
|
551
|
+
userLogout: "/user/logout",
|
|
552
|
+
// 联系人
|
|
553
|
+
contactInitContact: "/contact/init_contact",
|
|
554
|
+
contactGetContact: "/contact/get_contact",
|
|
555
|
+
contactBatchGetBriefInfo: "/contact/batch_get_contact_brief_info",
|
|
556
|
+
contactSearchContact: "/contact/search_contact",
|
|
557
|
+
contactAddFriend: "/contact/add_friend",
|
|
558
|
+
contactVerifyFriend: "/contact/verify_friend",
|
|
559
|
+
contactModifyRemark: "/contact/modify_remark",
|
|
560
|
+
contactDelFriend: "/contact/del_friend",
|
|
561
|
+
contactModifyTopFlag: "/contact/modify_contact_top_flag",
|
|
562
|
+
// 消息
|
|
563
|
+
msgSendText: "/msg/send_text",
|
|
564
|
+
msgSendRoomAt: "/msg/send_room_at",
|
|
565
|
+
msgSendImage: "/msg/send_image",
|
|
566
|
+
msgSendVideo: "/msg/send_video",
|
|
567
|
+
msgSendFile: "/msg/send_file",
|
|
568
|
+
msgSendLocation: "/msg/send_location",
|
|
569
|
+
msgSendShareCard: "/msg/send_share_card",
|
|
570
|
+
msgSendLinkCard: "/msg/send_link_card",
|
|
571
|
+
msgSendEmoji: "/msg/send_emoji",
|
|
572
|
+
msgSendEmojiUrl: "/msg/send_emoji_url",
|
|
573
|
+
msgSendPat: "/msg/send_pat",
|
|
574
|
+
msgRecall: "/msg/recall",
|
|
575
|
+
msgSendReferMsg: "/msg/send_refer_msg",
|
|
576
|
+
// 群组
|
|
577
|
+
roomCreateChatroom: "/room/create_chatroom",
|
|
578
|
+
roomGetDetail: "/room/get_chatroom_detail",
|
|
579
|
+
roomGetMembers: "/room/get_chatroom_member_detail",
|
|
580
|
+
roomAddMember: "/room/add_chatroom_member",
|
|
581
|
+
roomInviteMember: "/room/invite_chatroom_member",
|
|
582
|
+
roomDelMember: "/room/del_chatroom_member",
|
|
583
|
+
roomModifyName: "/room/modify_chatroom_name",
|
|
584
|
+
roomSetAnnouncement: "/room/set_chatroom_announcement",
|
|
585
|
+
roomModifyDisplayName: "/room/modify_chatroom_display_name",
|
|
586
|
+
roomModifyShowNameFlag: "/room/modify_chatroom_show_name_flag",
|
|
587
|
+
roomModifyContactFlag: "/room/modify_chatroom_contact_flag",
|
|
588
|
+
roomModifyFoldFlag: "/room/modify_chatroom_fold_flag",
|
|
589
|
+
roomModifyDisturbFlag: "/room/modify_chatroom_disturb_flag",
|
|
590
|
+
roomAddMemberFriend: "/room/add_chatroom_member_friend",
|
|
591
|
+
roomQuit: "/room/quit_chatroom",
|
|
592
|
+
roomTransferOwner: "/room/tranfer_chatroom_owner",
|
|
593
|
+
roomGetQRCode: "/room/get_chatroom_qrcode",
|
|
594
|
+
roomSetTopMsg: "/room/set_top_msg",
|
|
595
|
+
roomRemoveTopMsg: "/room/remove_top_msg",
|
|
596
|
+
// 朋友圈
|
|
597
|
+
snsTimeline: "/sns/sns_timeline",
|
|
598
|
+
snsUserpage: "/sns/sns_userpage",
|
|
599
|
+
snsPost: "/sns/sns_post",
|
|
600
|
+
snsDelete: "/sns/sns_delete",
|
|
601
|
+
snsComment: "/sns/sns_comment",
|
|
602
|
+
snsDeleteComment: "/sns/sns_delete_comment",
|
|
603
|
+
snsLike: "/sns/sns_like",
|
|
604
|
+
// 云存储
|
|
605
|
+
cloudUpload: "/cloud/upload",
|
|
606
|
+
cloudUploadBig: "/cloud/upload_big",
|
|
607
|
+
cloudCdnUpload: "/cloud/cdn_upload",
|
|
608
|
+
cloudDownload: "/cloud/download",
|
|
609
|
+
cloudCdnDownload: "/cloud/cdn_download",
|
|
610
|
+
};
|
package/index.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { defineChannelPluginEntry } from "openclaw/plugin-sdk/core";
|
|
9
|
-
import { ipadWeChatPlugin } from "./src/channel.js";
|
|
9
|
+
import { ipadWeChatPlugin, handleInboundMessage } from "./src/channel.js";
|
|
10
10
|
|
|
11
11
|
export default defineChannelPluginEntry({
|
|
12
12
|
id: "ipad-wechat",
|
|
@@ -21,9 +21,14 @@ export default defineChannelPluginEntry({
|
|
|
21
21
|
auth: "plugin",
|
|
22
22
|
handler: async (req, res) => {
|
|
23
23
|
try {
|
|
24
|
-
const payload = req.body;
|
|
24
|
+
const payload = (req as any).body;
|
|
25
25
|
// Handle inbound message
|
|
26
26
|
console.log("[iPad WeChat] Received webhook:", payload);
|
|
27
|
+
|
|
28
|
+
if (payload) {
|
|
29
|
+
await handleInboundMessage(api, payload);
|
|
30
|
+
}
|
|
31
|
+
|
|
27
32
|
res.statusCode = 200;
|
|
28
33
|
res.end("ok");
|
|
29
34
|
return true;
|
package/openclaw.plugin.json
CHANGED
|
@@ -39,15 +39,19 @@
|
|
|
39
39
|
"configSchema": {
|
|
40
40
|
"type": "object",
|
|
41
41
|
"properties": {
|
|
42
|
-
"
|
|
42
|
+
"appKey": {
|
|
43
43
|
"type": "string",
|
|
44
|
-
"description": "
|
|
45
|
-
"secret": true
|
|
46
|
-
"required": true
|
|
44
|
+
"description": "JuHeBot App Key (聚合聊天开放平台)",
|
|
45
|
+
"secret": true
|
|
47
46
|
},
|
|
48
|
-
"
|
|
47
|
+
"appSecret": {
|
|
49
48
|
"type": "string",
|
|
50
|
-
"description": "
|
|
49
|
+
"description": "JuHeBot App Secret",
|
|
50
|
+
"secret": true
|
|
51
|
+
},
|
|
52
|
+
"guid": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "实例/设备 ID (Guid)"
|
|
51
55
|
},
|
|
52
56
|
"accountId": {
|
|
53
57
|
"type": "string",
|
|
@@ -78,7 +82,7 @@
|
|
|
78
82
|
"default": "allowlist"
|
|
79
83
|
}
|
|
80
84
|
},
|
|
81
|
-
"required": ["
|
|
85
|
+
"required": ["appKey", "appSecret", "guid"]
|
|
82
86
|
},
|
|
83
87
|
"permissions": {
|
|
84
88
|
"channels": ["ipad-wechat"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gloablehive/ipad-wechat-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
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",
|
|
@@ -20,11 +20,12 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@gloablehive/wechat-cache": "^1.0.
|
|
23
|
+
"@gloablehive/wechat-cache": "^1.0.1",
|
|
24
24
|
"openclaw": ">=1.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^20.0.0",
|
|
28
|
+
"tsx": "^4.21.0",
|
|
28
29
|
"typescript": "^5.0.0"
|
|
29
30
|
}
|
|
30
31
|
}
|