@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
package/src/client.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* iPad WeChat API Client
|
|
2
|
+
* iPad WeChat API Client (聚合聊天开放平台)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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/
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
export interface
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
export interface JuHeBotConfig {
|
|
10
|
+
appKey: string;
|
|
11
|
+
appSecret: string;
|
|
12
|
+
guid: string; // 实例/设备 ID
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export interface WebhookPayload {
|
|
@@ -24,6 +26,18 @@ export interface WebhookPayload {
|
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
export interface JuHeBotResponse {
|
|
30
|
+
code?: number;
|
|
31
|
+
msg?: string;
|
|
32
|
+
err_code?: number;
|
|
33
|
+
err_msg?: string;
|
|
34
|
+
data?: any;
|
|
35
|
+
contactUsernameList?: string[];
|
|
36
|
+
currentWxcontactSeq?: number;
|
|
37
|
+
currentChatRoomContactSeq?: number;
|
|
38
|
+
continueFlag?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
27
41
|
export interface SendTextResponse {
|
|
28
42
|
messageId: string;
|
|
29
43
|
msgSvrId: string;
|
|
@@ -48,225 +62,716 @@ export interface RoomInfo {
|
|
|
48
62
|
memberCount: number;
|
|
49
63
|
}
|
|
50
64
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
export interface DeviceInfo {
|
|
66
|
+
guid: string;
|
|
67
|
+
name: string;
|
|
68
|
+
status: string;
|
|
69
|
+
wechatId?: string;
|
|
70
|
+
nickName?: string;
|
|
56
71
|
}
|
|
57
72
|
|
|
58
|
-
|
|
59
|
-
|
|
73
|
+
const GATEWAY_URL = "https://chat-api.juhebot.com/open/GuidRequest";
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Call JuHeBot API Gateway
|
|
77
|
+
*/
|
|
78
|
+
async function callApi(config: JuHeBotConfig, path: string, data: any): Promise<JuHeBotResponse> {
|
|
79
|
+
const requestBody = {
|
|
80
|
+
app_key: config.appKey,
|
|
81
|
+
app_secret: config.appSecret,
|
|
82
|
+
path,
|
|
83
|
+
data: {
|
|
84
|
+
guid: config.guid,
|
|
85
|
+
...data,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
console.log('[JuHeBot API] Request:', { path, data: requestBody.data });
|
|
90
|
+
|
|
91
|
+
const response = await fetch(GATEWAY_URL, {
|
|
92
|
+
method: "POST",
|
|
93
|
+
headers: {
|
|
94
|
+
"Content-Type": "application/json",
|
|
95
|
+
},
|
|
96
|
+
body: JSON.stringify(requestBody),
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const result = await response.json() as any;
|
|
100
|
+
console.log('[JuHeBot API] Response:', result);
|
|
101
|
+
|
|
102
|
+
// Handle error response
|
|
103
|
+
if (result.err_code !== undefined && result.err_code !== 0) {
|
|
104
|
+
throw new Error(`API Error: ${result.err_msg} (code: ${result.err_code})`);
|
|
105
|
+
}
|
|
106
|
+
if (result.code !== undefined && result.code !== 0) {
|
|
107
|
+
throw new Error(`API Error: ${result.msg} (code: ${result.code})`);
|
|
108
|
+
}
|
|
60
109
|
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function createIPadClient(config: JuHeBotConfig) {
|
|
61
114
|
return {
|
|
62
|
-
// ==========
|
|
115
|
+
// ========== 实例管理 (Instance) ==========
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 获取实例状态
|
|
119
|
+
* Path: /instance/get_status
|
|
120
|
+
*/
|
|
121
|
+
async getDeviceStatus(): Promise<any> {
|
|
122
|
+
return await callApi(config, "/instance/get_status", {});
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 恢复实例
|
|
127
|
+
* Path: /instance/restore
|
|
128
|
+
*/
|
|
129
|
+
async restoreInstance(): Promise<any> {
|
|
130
|
+
return await callApi(config, "/instance/restore", {});
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* 停止实例
|
|
135
|
+
* Path: /instance/stop
|
|
136
|
+
*/
|
|
137
|
+
async stopInstance(): Promise<any> {
|
|
138
|
+
return await callApi(config, "/instance/stop", {});
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 设置实例通知地址 (回调地址)
|
|
143
|
+
* Path: /instance/set_notify_url
|
|
144
|
+
*/
|
|
145
|
+
async setNotifyUrl(notifyUrl: string): Promise<void> {
|
|
146
|
+
await callApi(config, "/instance/set_notify_url", { notifyUrl });
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 设置实例桥接ID
|
|
151
|
+
* Path: /instance/set_bridge_id
|
|
152
|
+
*/
|
|
153
|
+
async setBridgeId(bridgeId: string): Promise<void> {
|
|
154
|
+
await callApi(config, "/instance/set_bridge_id", { bridgeId });
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
// ========== 用户 (User) ==========
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 获取登录账号信息
|
|
161
|
+
* Path: /user/get_profile
|
|
162
|
+
*/
|
|
163
|
+
async getLoginAccountInfo(): Promise<{
|
|
164
|
+
wechatId: string;
|
|
165
|
+
nickName: string;
|
|
166
|
+
avatar: string;
|
|
167
|
+
}> {
|
|
168
|
+
const res = await callApi(config, "/user/get_profile", {});
|
|
169
|
+
return res.data || {};
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 获取个人二维码
|
|
174
|
+
* Path: /user/get_qrcode
|
|
175
|
+
*/
|
|
176
|
+
async getQRCode(): Promise<any> {
|
|
177
|
+
return await callApi(config, "/user/get_qrcode", {});
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* 退出登录
|
|
182
|
+
* Path: /user/logout
|
|
183
|
+
*/
|
|
184
|
+
async logout(): Promise<any> {
|
|
185
|
+
return await callApi(config, "/user/logout", {});
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
// ========== 联系人 (Contact) ==========
|
|
63
189
|
|
|
190
|
+
/**
|
|
191
|
+
* 同步联系人
|
|
192
|
+
* Path: /contact/init_contact
|
|
193
|
+
*/
|
|
194
|
+
async syncContacts(): Promise<Contact[]> {
|
|
195
|
+
const res = await callApi(config, "/contact/init_contact", {});
|
|
196
|
+
// API returns contactUsernameList array directly in response
|
|
197
|
+
const contactList = res.contactUsernameList || res.data?.contactUsernameList || [];
|
|
198
|
+
// Convert to Contact format (wechatId is the username)
|
|
199
|
+
return contactList.map((wechatId: string) => ({
|
|
200
|
+
wechatId,
|
|
201
|
+
nickName: "",
|
|
202
|
+
remark: "",
|
|
203
|
+
}));
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* 获取联系人详细
|
|
208
|
+
* Path: /contact/get_contact
|
|
209
|
+
*/
|
|
210
|
+
async getContactDetail(wechatId: string): Promise<Contact> {
|
|
211
|
+
const res = await callApi(config, "/contact/get_contact", { userId: wechatId });
|
|
212
|
+
return res.data || {};
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* 批量获取联系人简要信息
|
|
217
|
+
* Path: /contact/batch_get_contact_brief_info
|
|
218
|
+
*/
|
|
219
|
+
async batchGetContactBriefInfo(wechatIds: string[]): Promise<any[]> {
|
|
220
|
+
const res = await callApi(config, "/contact/batch_get_contact_brief_info", { userIds: wechatIds });
|
|
221
|
+
return res.data?.contacts || [];
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* 搜索联系人
|
|
226
|
+
* Path: /contact/search_contact
|
|
227
|
+
*/
|
|
228
|
+
async searchContact(searchType: string, value: string): Promise<any> {
|
|
229
|
+
return await callApi(config, "/contact/search_contact", { searchType, value });
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 添加好友
|
|
234
|
+
* Path: /contact/add_friend
|
|
235
|
+
*/
|
|
236
|
+
async addFriend(v3: string, verifyMessage?: string): Promise<any> {
|
|
237
|
+
return await callApi(config, "/contact/add_friend", { v3, verifyMessage });
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* 验证好友申请
|
|
242
|
+
* Path: /contact/verify_friend
|
|
243
|
+
*/
|
|
244
|
+
async verifyFriend(who: string, status: number, ticket: string): Promise<any> {
|
|
245
|
+
return await callApi(config, "/contact/verify_friend", { who, status, ticket });
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* 修改好友备注
|
|
250
|
+
* Path: /contact/modify_remark
|
|
251
|
+
*/
|
|
252
|
+
async updateFriendRemark(wechatId: string, remark: string): Promise<void> {
|
|
253
|
+
await callApi(config, "/contact/modify_remark", { userId: wechatId, remark });
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* 删除好友
|
|
258
|
+
* Path: /contact/del_friend
|
|
259
|
+
*/
|
|
260
|
+
async deleteFriend(wechatId: string): Promise<any> {
|
|
261
|
+
return await callApi(config, "/contact/del_friend", { userId: wechatId });
|
|
262
|
+
},
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* 置顶聊天
|
|
266
|
+
* Path: /contact/modify_contact_top_flag
|
|
267
|
+
*/
|
|
268
|
+
async setContactTop(wechatId: string, flag: number): Promise<any> {
|
|
269
|
+
return await callApi(config, "/contact/modify_contact_top_flag", { userId: wechatId, flag });
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
// ========== 消息发送 (Msg) ==========
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* 发送文本消息
|
|
276
|
+
* Path: /msg/send_text
|
|
277
|
+
*/
|
|
64
278
|
async sendFriendMessage(params: {
|
|
65
279
|
friendWechatId: string;
|
|
66
280
|
content: string;
|
|
67
281
|
}): Promise<SendTextResponse> {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
headers: getHeaders(apiKey),
|
|
72
|
-
body: JSON.stringify({
|
|
73
|
-
toUser: params.friendWechatId,
|
|
74
|
-
content: params.content,
|
|
75
|
-
}),
|
|
282
|
+
const res = await callApi(config, "/msg/send_text", {
|
|
283
|
+
toUser: params.friendWechatId,
|
|
284
|
+
content: params.content,
|
|
76
285
|
});
|
|
77
|
-
|
|
286
|
+
|
|
78
287
|
return {
|
|
79
|
-
messageId:
|
|
80
|
-
msgSvrId:
|
|
288
|
+
messageId: res.data?.messageId || `msg_${Date.now()}`,
|
|
289
|
+
msgSvrId: res.data?.msgSvrId || "",
|
|
81
290
|
};
|
|
82
291
|
},
|
|
83
292
|
|
|
293
|
+
/**
|
|
294
|
+
* 发送群@消息
|
|
295
|
+
* Path: /msg/send_room_at
|
|
296
|
+
*/
|
|
84
297
|
async sendRoomMessage(params: {
|
|
85
298
|
roomId: string;
|
|
86
299
|
content: string;
|
|
87
300
|
}): Promise<SendTextResponse> {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
headers: getHeaders(apiKey),
|
|
92
|
-
body: JSON.stringify({
|
|
93
|
-
roomId: params.roomId,
|
|
94
|
-
content: params.content,
|
|
95
|
-
}),
|
|
301
|
+
const res = await callApi(config, "/msg/send_room_at", {
|
|
302
|
+
roomId: params.roomId,
|
|
303
|
+
content: params.content,
|
|
96
304
|
});
|
|
97
|
-
|
|
305
|
+
|
|
98
306
|
return {
|
|
99
|
-
messageId:
|
|
100
|
-
msgSvrId:
|
|
307
|
+
messageId: res.data?.messageId || `msg_${Date.now()}`,
|
|
308
|
+
msgSvrId: res.data?.msgSvrId || "",
|
|
101
309
|
};
|
|
102
310
|
},
|
|
103
311
|
|
|
312
|
+
/**
|
|
313
|
+
* 发送图片
|
|
314
|
+
* Path: /msg/send_image
|
|
315
|
+
*/
|
|
104
316
|
async sendFriendMedia(params: {
|
|
105
317
|
friendWechatId: string;
|
|
106
318
|
filePath: string;
|
|
107
319
|
}): Promise<SendMediaResponse> {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
headers: getHeaders(apiKey),
|
|
112
|
-
body: JSON.stringify({
|
|
113
|
-
toUser: params.friendWechatId,
|
|
114
|
-
filePath: params.filePath,
|
|
115
|
-
}),
|
|
320
|
+
const res = await callApi(config, "/msg/send_image", {
|
|
321
|
+
toUser: params.friendWechatId,
|
|
322
|
+
filePath: params.filePath,
|
|
116
323
|
});
|
|
117
|
-
|
|
324
|
+
|
|
118
325
|
return {
|
|
119
|
-
messageId:
|
|
120
|
-
msgSvrId:
|
|
326
|
+
messageId: res.data?.messageId || `msg_${Date.now()}`,
|
|
327
|
+
msgSvrId: res.data?.msgSvrId || "",
|
|
121
328
|
};
|
|
122
329
|
},
|
|
123
330
|
|
|
331
|
+
/**
|
|
332
|
+
* 发送图片到群
|
|
333
|
+
* Path: /msg/send_image (复用)
|
|
334
|
+
*/
|
|
124
335
|
async sendRoomMedia(params: {
|
|
125
336
|
roomId: string;
|
|
126
337
|
filePath: string;
|
|
127
338
|
}): Promise<SendMediaResponse> {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
headers: getHeaders(apiKey),
|
|
132
|
-
body: JSON.stringify({
|
|
133
|
-
roomId: params.roomId,
|
|
134
|
-
filePath: params.filePath,
|
|
135
|
-
}),
|
|
339
|
+
const res = await callApi(config, "/msg/send_image", {
|
|
340
|
+
roomId: params.roomId,
|
|
341
|
+
filePath: params.filePath,
|
|
136
342
|
});
|
|
137
|
-
|
|
343
|
+
|
|
138
344
|
return {
|
|
139
|
-
messageId:
|
|
140
|
-
msgSvrId:
|
|
345
|
+
messageId: res.data?.messageId || `msg_${Date.now()}`,
|
|
346
|
+
msgSvrId: res.data?.msgSvrId || "",
|
|
141
347
|
};
|
|
142
348
|
},
|
|
143
349
|
|
|
144
|
-
|
|
350
|
+
/**
|
|
351
|
+
* 发送视频
|
|
352
|
+
* Path: /msg/send_video
|
|
353
|
+
*/
|
|
354
|
+
async sendVideo(params: { toUser: string; filePath: string }): Promise<SendMediaResponse> {
|
|
355
|
+
const res = await callApi(config, "/msg/send_video", params);
|
|
356
|
+
return {
|
|
357
|
+
messageId: res.data?.messageId || `msg_${Date.now()}`,
|
|
358
|
+
msgSvrId: res.data?.msgSvrId || "",
|
|
359
|
+
};
|
|
360
|
+
},
|
|
145
361
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
362
|
+
/**
|
|
363
|
+
* 发送文件
|
|
364
|
+
* Path: /msg/send_file
|
|
365
|
+
*/
|
|
366
|
+
async sendFile(params: { toUser: string; filePath: string }): Promise<SendMediaResponse> {
|
|
367
|
+
const res = await callApi(config, "/msg/send_file", params);
|
|
368
|
+
return {
|
|
369
|
+
messageId: res.data?.messageId || `msg_${Date.now()}`,
|
|
370
|
+
msgSvrId: res.data?.msgSvrId || "",
|
|
371
|
+
};
|
|
155
372
|
},
|
|
156
373
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
});
|
|
164
|
-
const data = await response.json();
|
|
165
|
-
return data.data || {};
|
|
374
|
+
/**
|
|
375
|
+
* 发送位置
|
|
376
|
+
* Path: /msg/send_location
|
|
377
|
+
*/
|
|
378
|
+
async sendLocation(params: { toUser: string; lat: number; lng: number; title?: string; address?: string }): Promise<any> {
|
|
379
|
+
return await callApi(config, "/msg/send_location", params);
|
|
166
380
|
},
|
|
167
381
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
382
|
+
/**
|
|
383
|
+
* 发送名片
|
|
384
|
+
* Path: /msg/send_share_card
|
|
385
|
+
*/
|
|
386
|
+
async sendCard(params: { toUser: string; cardWxid: string }): Promise<any> {
|
|
387
|
+
return await callApi(config, "/msg/send_share_card", params);
|
|
388
|
+
},
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* 发送链接卡片
|
|
392
|
+
* Path: /msg/send_link_card
|
|
393
|
+
*/
|
|
394
|
+
async sendLink(params: { toUser: string; title: string; desc: string; url: string; thumbUrl?: string }): Promise<any> {
|
|
395
|
+
return await callApi(config, "/msg/send_link_card", params);
|
|
178
396
|
},
|
|
179
397
|
|
|
180
|
-
|
|
398
|
+
/**
|
|
399
|
+
* 发送表情
|
|
400
|
+
* Path: /msg/send_emoji
|
|
401
|
+
*/
|
|
402
|
+
async sendEmoji(params: { toUser: string; emojiPath: string }): Promise<any> {
|
|
403
|
+
return await callApi(config, "/msg/send_emoji", params);
|
|
404
|
+
},
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* 发送表情URL
|
|
408
|
+
* Path: /msg/send_emoji_url
|
|
409
|
+
*/
|
|
410
|
+
async sendEmojiUrl(params: { toUser: string; emojiUrl: string }): Promise<any> {
|
|
411
|
+
return await callApi(config, "/msg/send_emoji_url", params);
|
|
412
|
+
},
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* 发送拍一拍
|
|
416
|
+
* Path: /msg/send_pat
|
|
417
|
+
*/
|
|
418
|
+
async sendPat(roomId: string, userId: string): Promise<any> {
|
|
419
|
+
return await callApi(config, "/msg/send_pat", { roomId, userId });
|
|
420
|
+
},
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* 撤回消息
|
|
424
|
+
* Path: /msg/recall
|
|
425
|
+
*/
|
|
426
|
+
async recallMessage(msgId: string): Promise<any> {
|
|
427
|
+
return await callApi(config, "/msg/recall", { msgId });
|
|
428
|
+
},
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* 发送引用消息
|
|
432
|
+
* Path: /msg/send_refer_msg
|
|
433
|
+
*/
|
|
434
|
+
async sendReferMsg(params: { toUser: string; content: string; referMsgId: string }): Promise<any> {
|
|
435
|
+
return await callApi(config, "/msg/send_refer_msg", params);
|
|
436
|
+
},
|
|
437
|
+
|
|
438
|
+
// ========== 群组 (Room) ==========
|
|
181
439
|
|
|
440
|
+
/**
|
|
441
|
+
* 获取群信息
|
|
442
|
+
* Path: /room/get_chatroom_detail
|
|
443
|
+
*/
|
|
182
444
|
async getRoomInfo(roomId: string): Promise<RoomInfo> {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
method: "POST",
|
|
186
|
-
headers: getHeaders(apiKey),
|
|
187
|
-
body: JSON.stringify({ roomId }),
|
|
188
|
-
});
|
|
189
|
-
const data = await response.json();
|
|
190
|
-
return data.data || {};
|
|
445
|
+
const res = await callApi(config, "/room/get_chatroom_detail", { roomId });
|
|
446
|
+
return res.data || {};
|
|
191
447
|
},
|
|
192
448
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const data = await response.json();
|
|
201
|
-
return data.data?.members || [];
|
|
449
|
+
/**
|
|
450
|
+
* 获取群成员详细
|
|
451
|
+
* Path: /room/get_chatroom_member_detail
|
|
452
|
+
*/
|
|
453
|
+
async getRoomMembers(roomId: string): Promise<any[]> {
|
|
454
|
+
const res = await callApi(config, "/room/get_chatroom_member_detail", { roomId });
|
|
455
|
+
return res.data?.members || [];
|
|
202
456
|
},
|
|
203
457
|
|
|
458
|
+
/**
|
|
459
|
+
* 创建群组
|
|
460
|
+
* Path: /room/create_chatroom
|
|
461
|
+
*/
|
|
204
462
|
async createRoom(memberIds: string[]): Promise<{ roomId: string }> {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
method: "POST",
|
|
208
|
-
headers: getHeaders(apiKey),
|
|
209
|
-
body: JSON.stringify({ memberIds }),
|
|
210
|
-
});
|
|
211
|
-
const data = await response.json();
|
|
212
|
-
return { roomId: data.data?.roomId || "" };
|
|
463
|
+
const res = await callApi(config, "/room/create_chatroom", { memberIds });
|
|
464
|
+
return { roomId: res.data?.roomId || "" };
|
|
213
465
|
},
|
|
214
466
|
|
|
467
|
+
/**
|
|
468
|
+
* 添加群成员
|
|
469
|
+
* Path: /room/add_chatroom_member
|
|
470
|
+
*/
|
|
215
471
|
async addRoomMember(roomId: string, memberId: string): Promise<void> {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
472
|
+
await callApi(config, "/room/add_chatroom_member", { roomId, memberId });
|
|
473
|
+
},
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* 邀请群成员
|
|
477
|
+
* Path: /room/invite_chatroom_member
|
|
478
|
+
*/
|
|
479
|
+
async inviteRoomMember(roomId: string, memberId: string): Promise<void> {
|
|
480
|
+
await callApi(config, "/room/invite_chatroom_member", { roomId, memberId });
|
|
222
481
|
},
|
|
223
482
|
|
|
483
|
+
/**
|
|
484
|
+
* 移除群成员
|
|
485
|
+
* Path: /room/del_chatroom_member
|
|
486
|
+
*/
|
|
224
487
|
async removeRoomMember(roomId: string, memberId: string): Promise<void> {
|
|
225
|
-
|
|
226
|
-
await fetch(`${baseUrl}/api-316658234`, {
|
|
227
|
-
method: "POST",
|
|
228
|
-
headers: getHeaders(apiKey),
|
|
229
|
-
body: JSON.stringify({ roomId, memberId }),
|
|
230
|
-
});
|
|
488
|
+
await callApi(config, "/room/del_chatroom_member", { roomId, memberId });
|
|
231
489
|
},
|
|
232
490
|
|
|
233
|
-
|
|
491
|
+
/**
|
|
492
|
+
* 修改群名称
|
|
493
|
+
* Path: /room/modify_chatroom_name
|
|
494
|
+
*/
|
|
495
|
+
async updateRoomName(roomId: string, name: string): Promise<void> {
|
|
496
|
+
await callApi(config, "/room/modify_chatroom_name", { roomId, name });
|
|
497
|
+
},
|
|
234
498
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
499
|
+
/**
|
|
500
|
+
* 设置群公告
|
|
501
|
+
* Path: /room/set_chatroom_announcement
|
|
502
|
+
*/
|
|
503
|
+
async setRoomAnnouncement(roomId: string, announcement: string): Promise<void> {
|
|
504
|
+
await callApi(config, "/room/set_chatroom_announcement", { roomId, announcement });
|
|
505
|
+
},
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* 修改群显示昵称
|
|
509
|
+
* Path: /room/modify_chatroom_display_name
|
|
510
|
+
*/
|
|
511
|
+
async setRoomDisplayName(roomId: string, displayName: string): Promise<void> {
|
|
512
|
+
await callApi(config, "/room/modify_chatroom_display_name", { roomId, displayName });
|
|
513
|
+
},
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* 是否显示群成员昵称
|
|
517
|
+
* Path: /room/modify_chatroom_show_name_flag
|
|
518
|
+
*/
|
|
519
|
+
async setRoomShowNameFlag(roomId: string, flag: number): Promise<void> {
|
|
520
|
+
await callApi(config, "/room/modify_chatroom_show_name_flag", { roomId, flag });
|
|
521
|
+
},
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* 是否保存到通讯录
|
|
525
|
+
* Path: /room/modify_chatroom_contact_flag
|
|
526
|
+
*/
|
|
527
|
+
async setRoomContactFlag(roomId: string, flag: number): Promise<void> {
|
|
528
|
+
await callApi(config, "/room/modify_chatroom_contact_flag", { roomId, flag });
|
|
248
529
|
},
|
|
249
530
|
|
|
250
|
-
|
|
531
|
+
/**
|
|
532
|
+
* 是否折叠群
|
|
533
|
+
* Path: /room/modify_chatroom_fold_flag
|
|
534
|
+
*/
|
|
535
|
+
async setRoomFoldFlag(roomId: string, flag: number): Promise<void> {
|
|
536
|
+
await callApi(config, "/room/modify_chatroom_fold_flag", { roomId, flag });
|
|
537
|
+
},
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* 消息免打扰
|
|
541
|
+
* Path: /room/modify_chatroom_disturb_flag
|
|
542
|
+
*/
|
|
543
|
+
async setRoomDisturbFlag(roomId: string, flag: number): Promise<void> {
|
|
544
|
+
await callApi(config, "/room/modify_chatroom_disturb_flag", { roomId, flag });
|
|
545
|
+
},
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* 添加群成员为好友
|
|
549
|
+
* Path: /room/add_chatroom_member_friend
|
|
550
|
+
*/
|
|
551
|
+
async addRoomMemberAsFriend(roomId: string, memberId: string): Promise<any> {
|
|
552
|
+
return await callApi(config, "/room/add_chatroom_member_friend", { roomId, memberId });
|
|
553
|
+
},
|
|
251
554
|
|
|
555
|
+
/**
|
|
556
|
+
* 退出群
|
|
557
|
+
* Path: /room/quit_chatroom
|
|
558
|
+
*/
|
|
559
|
+
async quitRoom(roomId: string): Promise<any> {
|
|
560
|
+
return await callApi(config, "/room/quit_chatroom", { roomId });
|
|
561
|
+
},
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* 转让群主
|
|
565
|
+
* Path: /room/tranfer_chatroom_owner
|
|
566
|
+
*/
|
|
567
|
+
async transferRoomOwner(roomId: string, newOwnerId: string): Promise<any> {
|
|
568
|
+
return await callApi(config, "/room/tranfer_chatroom_owner", { roomId, newOwnerId });
|
|
569
|
+
},
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* 获取群二维码
|
|
573
|
+
* Path: /room/get_chatroom_qrcode
|
|
574
|
+
*/
|
|
575
|
+
async getRoomQRCode(roomId: string): Promise<any> {
|
|
576
|
+
return await callApi(config, "/room/get_chatroom_qrcode", { roomId });
|
|
577
|
+
},
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* 置顶消息
|
|
581
|
+
* Path: /room/set_top_msg
|
|
582
|
+
*/
|
|
583
|
+
async setTopMsg(roomId: string, msgId: string): Promise<any> {
|
|
584
|
+
return await callApi(config, "/room/set_top_msg", { roomId, msgId });
|
|
585
|
+
},
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* 取消置顶消息
|
|
589
|
+
* Path: /room/remove_top_msg
|
|
590
|
+
*/
|
|
591
|
+
async removeTopMsg(roomId: string, msgId: string): Promise<any> {
|
|
592
|
+
return await callApi(config, "/room/remove_top_msg", { roomId, msgId });
|
|
593
|
+
},
|
|
594
|
+
|
|
595
|
+
// ========== 朋友圈 (SNS) ==========
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* 获取朋友圈动态
|
|
599
|
+
* Path: /sns/sns_timeline
|
|
600
|
+
*/
|
|
601
|
+
async getMoments(limit: number = 20): Promise<any[]> {
|
|
602
|
+
const res = await callApi(config, "/sns/sns_timeline", { limit });
|
|
603
|
+
return res.data?.moments || [];
|
|
604
|
+
},
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* 获取好友朋友圈动态
|
|
608
|
+
* Path: /sns/sns_userpage
|
|
609
|
+
*/
|
|
252
610
|
async getFriendMoments(wechatId: string, limit: number = 20): Promise<any[]> {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
method: "POST",
|
|
256
|
-
headers: getHeaders(apiKey),
|
|
257
|
-
body: JSON.stringify({ userId: wechatId, limit }),
|
|
258
|
-
});
|
|
259
|
-
const data = await response.json();
|
|
260
|
-
return data.data?.moments || [];
|
|
611
|
+
const res = await callApi(config, "/sns/sns_userpage", { userId: wechatId, limit });
|
|
612
|
+
return res.data?.moments || [];
|
|
261
613
|
},
|
|
262
614
|
|
|
615
|
+
/**
|
|
616
|
+
* 发布朋友圈
|
|
617
|
+
* Path: /sns/sns_post
|
|
618
|
+
*/
|
|
263
619
|
async publishMoment(content: string, images: string[]): Promise<void> {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
620
|
+
await callApi(config, "/sns/sns_post", { content, images });
|
|
621
|
+
},
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* 删除朋友圈
|
|
625
|
+
* Path: /sns/sns_delete
|
|
626
|
+
*/
|
|
627
|
+
async deleteMoment(snsId: string): Promise<void> {
|
|
628
|
+
await callApi(config, "/sns/sns_delete", { snsId });
|
|
629
|
+
},
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* 朋友圈评论
|
|
633
|
+
* Path: /sns/sns_comment
|
|
634
|
+
*/
|
|
635
|
+
async commentMoment(snsId: string, content: string, replyId?: string): Promise<any> {
|
|
636
|
+
return await callApi(config, "/sns/sns_comment", { snsId, content, replyId });
|
|
637
|
+
},
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* 删除评论
|
|
641
|
+
* Path: /sns/sns_delete_comment
|
|
642
|
+
*/
|
|
643
|
+
async deleteComment(snsId: string, commentId: string): Promise<void> {
|
|
644
|
+
await callApi(config, "/sns/sns_delete_comment", { snsId, commentId });
|
|
645
|
+
},
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* 点赞/取消点赞
|
|
649
|
+
* Path: /sns/sns_like
|
|
650
|
+
*/
|
|
651
|
+
async likeMoment(snsId: string, type: number): Promise<any> {
|
|
652
|
+
return await callApi(config, "/sns/sns_like", { snsId, type });
|
|
653
|
+
},
|
|
654
|
+
|
|
655
|
+
// ========== 云存储 (Cloud) ==========
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* 上传文件
|
|
659
|
+
* Path: /cloud/upload
|
|
660
|
+
*/
|
|
661
|
+
async uploadFile(filePath: string): Promise<any> {
|
|
662
|
+
return await callApi(config, "/cloud/upload", { filePath });
|
|
663
|
+
},
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* 上传大文件
|
|
667
|
+
* Path: /cloud/upload_big
|
|
668
|
+
*/
|
|
669
|
+
async uploadBigFile(filePath: string): Promise<any> {
|
|
670
|
+
return await callApi(config, "/cloud/upload_big", { filePath });
|
|
671
|
+
},
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* CDN 上传
|
|
675
|
+
* Path: /cloud/cdn_upload
|
|
676
|
+
*/
|
|
677
|
+
async cdnUpload(filePath: string): Promise<any> {
|
|
678
|
+
return await callApi(config, "/cloud/cdn_upload", { filePath });
|
|
679
|
+
},
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* 下载文件
|
|
683
|
+
* Path: /cloud/download
|
|
684
|
+
*/
|
|
685
|
+
async downloadFile(fileId: string, savePath: string): Promise<any> {
|
|
686
|
+
return await callApi(config, "/cloud/download", { fileId, savePath });
|
|
687
|
+
},
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* CDN 下载
|
|
691
|
+
* Path: /cloud/cdn_download
|
|
692
|
+
*/
|
|
693
|
+
async cdnDownload(url: string, savePath: string): Promise<any> {
|
|
694
|
+
return await callApi(config, "/cloud/cdn_download", { url, savePath });
|
|
270
695
|
},
|
|
271
696
|
};
|
|
272
|
-
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* API 路径映射表 (完整)
|
|
701
|
+
*/
|
|
702
|
+
export const API_PATHS = {
|
|
703
|
+
// 实例管理
|
|
704
|
+
instanceGetStatus: "/instance/get_status",
|
|
705
|
+
instanceRestore: "/instance/restore",
|
|
706
|
+
instanceStop: "/instance/stop",
|
|
707
|
+
instanceSetNotifyUrl: "/instance/set_notify_url",
|
|
708
|
+
instanceSetBridgeId: "/instance/set_bridge_id",
|
|
709
|
+
|
|
710
|
+
// 用户
|
|
711
|
+
userGetProfile: "/user/get_profile",
|
|
712
|
+
userGetQRCode: "/user/get_qrcode",
|
|
713
|
+
userLogout: "/user/logout",
|
|
714
|
+
|
|
715
|
+
// 联系人
|
|
716
|
+
contactInitContact: "/contact/init_contact",
|
|
717
|
+
contactGetContact: "/contact/get_contact",
|
|
718
|
+
contactBatchGetBriefInfo: "/contact/batch_get_contact_brief_info",
|
|
719
|
+
contactSearchContact: "/contact/search_contact",
|
|
720
|
+
contactAddFriend: "/contact/add_friend",
|
|
721
|
+
contactVerifyFriend: "/contact/verify_friend",
|
|
722
|
+
contactModifyRemark: "/contact/modify_remark",
|
|
723
|
+
contactDelFriend: "/contact/del_friend",
|
|
724
|
+
contactModifyTopFlag: "/contact/modify_contact_top_flag",
|
|
725
|
+
|
|
726
|
+
// 消息
|
|
727
|
+
msgSendText: "/msg/send_text",
|
|
728
|
+
msgSendRoomAt: "/msg/send_room_at",
|
|
729
|
+
msgSendImage: "/msg/send_image",
|
|
730
|
+
msgSendVideo: "/msg/send_video",
|
|
731
|
+
msgSendFile: "/msg/send_file",
|
|
732
|
+
msgSendLocation: "/msg/send_location",
|
|
733
|
+
msgSendShareCard: "/msg/send_share_card",
|
|
734
|
+
msgSendLinkCard: "/msg/send_link_card",
|
|
735
|
+
msgSendEmoji: "/msg/send_emoji",
|
|
736
|
+
msgSendEmojiUrl: "/msg/send_emoji_url",
|
|
737
|
+
msgSendPat: "/msg/send_pat",
|
|
738
|
+
msgRecall: "/msg/recall",
|
|
739
|
+
msgSendReferMsg: "/msg/send_refer_msg",
|
|
740
|
+
|
|
741
|
+
// 群组
|
|
742
|
+
roomCreateChatroom: "/room/create_chatroom",
|
|
743
|
+
roomGetDetail: "/room/get_chatroom_detail",
|
|
744
|
+
roomGetMembers: "/room/get_chatroom_member_detail",
|
|
745
|
+
roomAddMember: "/room/add_chatroom_member",
|
|
746
|
+
roomInviteMember: "/room/invite_chatroom_member",
|
|
747
|
+
roomDelMember: "/room/del_chatroom_member",
|
|
748
|
+
roomModifyName: "/room/modify_chatroom_name",
|
|
749
|
+
roomSetAnnouncement: "/room/set_chatroom_announcement",
|
|
750
|
+
roomModifyDisplayName: "/room/modify_chatroom_display_name",
|
|
751
|
+
roomModifyShowNameFlag: "/room/modify_chatroom_show_name_flag",
|
|
752
|
+
roomModifyContactFlag: "/room/modify_chatroom_contact_flag",
|
|
753
|
+
roomModifyFoldFlag: "/room/modify_chatroom_fold_flag",
|
|
754
|
+
roomModifyDisturbFlag: "/room/modify_chatroom_disturb_flag",
|
|
755
|
+
roomAddMemberFriend: "/room/add_chatroom_member_friend",
|
|
756
|
+
roomQuit: "/room/quit_chatroom",
|
|
757
|
+
roomTransferOwner: "/room/tranfer_chatroom_owner",
|
|
758
|
+
roomGetQRCode: "/room/get_chatroom_qrcode",
|
|
759
|
+
roomSetTopMsg: "/room/set_top_msg",
|
|
760
|
+
roomRemoveTopMsg: "/room/remove_top_msg",
|
|
761
|
+
|
|
762
|
+
// 朋友圈
|
|
763
|
+
snsTimeline: "/sns/sns_timeline",
|
|
764
|
+
snsUserpage: "/sns/sns_userpage",
|
|
765
|
+
snsPost: "/sns/sns_post",
|
|
766
|
+
snsDelete: "/sns/sns_delete",
|
|
767
|
+
snsComment: "/sns/sns_comment",
|
|
768
|
+
snsDeleteComment: "/sns/sns_delete_comment",
|
|
769
|
+
snsLike: "/sns/sns_like",
|
|
770
|
+
|
|
771
|
+
// 云存储
|
|
772
|
+
cloudUpload: "/cloud/upload",
|
|
773
|
+
cloudUploadBig: "/cloud/upload_big",
|
|
774
|
+
cloudCdnUpload: "/cloud/cdn_upload",
|
|
775
|
+
cloudDownload: "/cloud/download",
|
|
776
|
+
cloudCdnDownload: "/cloud/cdn_download",
|
|
777
|
+
};
|