node-karin 0.12.13 → 0.12.15

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 (59) hide show
  1. package/lib/adapter/input/index.d.ts +1 -1
  2. package/lib/adapter/input/index.js +1 -1
  3. package/lib/adapter/onebot/11/event.js +90 -84
  4. package/lib/adapter/onebot/11/index.d.ts +89 -127
  5. package/lib/adapter/onebot/11/index.js +192 -254
  6. package/lib/cli/index.js +2 -2
  7. package/lib/core/init/config.js +1 -1
  8. package/lib/core/karin/karin.d.ts +21 -30
  9. package/lib/core/karin/karin.js +7 -9
  10. package/lib/core/listener/listener.js +11 -11
  11. package/lib/core/plugin/base.d.ts +7 -21
  12. package/lib/core/plugin/base.js +2 -6
  13. package/lib/core/plugin/loader.d.ts +5 -15
  14. package/lib/core/plugin/loader.js +5 -15
  15. package/lib/core/server/server.js +4 -4
  16. package/lib/event/handler/base.d.ts +1 -3
  17. package/lib/event/handler/base.js +1 -3
  18. package/lib/event/handler/message.js +9 -3
  19. package/lib/event/handler/notice.js +38 -32
  20. package/lib/event/handler/request.js +6 -6
  21. package/lib/index.d.ts +6 -0
  22. package/lib/index.js +6 -0
  23. package/lib/modules.d.ts +2 -2
  24. package/lib/modules.js +3 -2
  25. package/lib/types/adapter/accept.d.ts +24 -0
  26. package/lib/types/adapter/accept.js +1 -0
  27. package/lib/types/adapter/api.d.ts +88 -264
  28. package/lib/types/adapter/base.d.ts +3 -3
  29. package/lib/types/config/config.d.ts +4 -12
  30. package/lib/types/element/element.d.ts +119 -349
  31. package/lib/types/element/qqbot.d.ts +4 -12
  32. package/lib/types/event/contact.d.ts +6 -12
  33. package/lib/types/event/event.d.ts +59 -163
  34. package/lib/types/event/message.d.ts +11 -31
  35. package/lib/types/event/message.js +10 -12
  36. package/lib/types/event/notice.d.ts +118 -325
  37. package/lib/types/event/notice.js +8 -10
  38. package/lib/types/event/request.d.ts +29 -66
  39. package/lib/types/event/request.js +8 -10
  40. package/lib/types/event/sender.d.ts +7 -21
  41. package/lib/types/index.d.ts +1 -0
  42. package/lib/types/index.js +1 -0
  43. package/lib/types/onebot11/api.d.ts +49 -49
  44. package/lib/types/onebot11/event.d.ts +131 -347
  45. package/lib/types/onebot11/params.d.ts +184 -456
  46. package/lib/types/onebot11/response.d.ts +159 -381
  47. package/lib/types/onebot11/segment.d.ts +25 -75
  48. package/lib/types/onebot11/sender.d.ts +13 -39
  49. package/lib/types/plugin/app.d.ts +7 -11
  50. package/lib/types/plugin/plugin.d.ts +55 -165
  51. package/lib/types/render/render.d.ts +16 -48
  52. package/lib/utils/common/common.js +4 -2
  53. package/lib/utils/config/config.js +1 -1
  54. package/lib/utils/core/logger.js +3 -3
  55. package/lib/utils/core/segment.d.ts +28 -59
  56. package/lib/utils/core/segment.js +26 -30
  57. package/lib/utils/tools/restart.d.ts +3 -3
  58. package/lib/utils/tools/restart.js +5 -5
  59. package/package.json +1 -2
@@ -9,9 +9,7 @@ import { AdapterConvertKarin, KarinConvertAdapter } from './convert.js';
9
9
  * @extends KarinAdapter
10
10
  */
11
11
  export class AdapterOneBot11 {
12
- /**
13
- * - 重连次数 仅正向ws使用
14
- */
12
+ /** 重连次数 仅正向ws使用 */
15
13
  index;
16
14
  socket;
17
15
  account;
@@ -28,13 +26,13 @@ export class AdapterOneBot11 {
28
26
  */
29
27
  async server(socket, request) {
30
28
  this.socket = socket;
31
- const self_id = String(request.headers['x-self-id']);
29
+ const selfId = String(request.headers['x-self-id']);
32
30
  const connect = 'ws://' + request.headers.host + request.url;
33
- this.account.uin = self_id;
34
- this.account.uid = self_id;
31
+ this.account.uin = selfId;
32
+ this.account.uid = selfId;
35
33
  this.adapter.connect = connect;
36
34
  this.adapter.sub_type = 'server';
37
- this.logger('info', `[反向WS][onebot11-${request.headers.upgrade}][${self_id}] ` + logger.green(connect));
35
+ this.logger('info', `[反向WS][onebot11-${request.headers.upgrade}][${selfId}] ` + logger.green(connect));
38
36
  await this.#initListener(connect);
39
37
  }
40
38
  /**
@@ -104,16 +102,16 @@ export class AdapterOneBot11 {
104
102
  async getSelf() {
105
103
  const data = await this.GetCurrentAccount();
106
104
  try {
107
- const { app_name, version } = await this.GetVersion();
108
- this.version.name = app_name;
109
- this.version.app_name = app_name;
105
+ const { app_name: appName, version } = await this.GetVersion();
106
+ this.version.name = appName;
107
+ this.version.app_name = appName;
110
108
  this.version.version = version;
111
109
  }
112
110
  catch (e) {
113
111
  /** 兼容onebots */
114
- const { app_name, version } = await this.SendApi("get_version" /* OB11Api['get_version'] */);
115
- this.version.name = app_name;
116
- this.version.app_name = app_name;
112
+ const { app_name: appName, version } = await this.SendApi("get_version" /* OB11Api.getVersion */);
113
+ this.version.name = appName;
114
+ this.version.app_name = appName;
117
115
  this.version.version = version;
118
116
  }
119
117
  this.account.uid = data.account_uid;
@@ -156,13 +154,13 @@ export class AdapterOneBot11 {
156
154
  }
157
155
  /**
158
156
  * 获取群头像
159
- * @param group_id - 群号
157
+ * @param groupId - 群号
160
158
  * @param size - 头像大小,默认`0`
161
159
  * @param history - 历史头像记录,默认`0`,若要获取历史群头像则填写1,2,3...
162
160
  * @returns - 群头像的url地址
163
161
  */
164
- getGroupAvatarUrl(group_id, size = 0, history = 0) {
165
- return `https://p.qlogo.cn/gh/${group_id}/${group_id}${history ? '_' + history : ''}/` + size;
162
+ getGroupAvatarUrl(groupId, size = 0, history = 0) {
163
+ return `https://p.qlogo.cn/gh/${groupId}/${groupId}${history ? '_' + history : ''}/` + size;
166
164
  }
167
165
  /**
168
166
  * 发送消息
@@ -175,14 +173,14 @@ export class AdapterOneBot11 {
175
173
  const { scene, peer } = contact;
176
174
  let res;
177
175
  if (scene === "group" /* Scene.Group */) {
178
- res = await this.SendApi("send_msg" /* OB11Api['send_msg'] */, {
176
+ res = await this.SendApi("send_msg" /* OB11Api.sendMsg */, {
179
177
  message_type: "group" /* MessageType.Group */,
180
178
  group_id: Number(peer),
181
179
  message: this.KarinConvertAdapter(elements),
182
180
  });
183
181
  }
184
182
  else {
185
- res = await this.SendApi("send_msg" /* OB11Api['send_msg'] */, {
183
+ res = await this.SendApi("send_msg" /* OB11Api.sendMsg */, {
186
184
  message_type: "private" /* MessageType.Private */,
187
185
  user_id: Number(peer),
188
186
  message: this.KarinConvertAdapter(elements),
@@ -203,7 +201,7 @@ export class AdapterOneBot11 {
203
201
  throw new Error('elements should be all node type');
204
202
  }
205
203
  const { scene, peer } = contact;
206
- const message_type = scene === 'group' ? 'group_id' : 'user_id';
204
+ const messageType = scene === 'group' ? 'group_id' : 'user_id';
207
205
  const messages = [];
208
206
  const selfUin = this.account.uin;
209
207
  const selfNick = this.account.name;
@@ -214,13 +212,13 @@ export class AdapterOneBot11 {
214
212
  }
215
213
  else {
216
214
  const content = this.KarinConvertAdapter(i.content);
217
- const user_id = String(i.user_id || selfUin);
215
+ const userId = String(i.user_id || selfUin);
218
216
  const nickname = String(i.nickname || selfNick);
219
- messages.push({ type, data: { user_id, nickname, content } });
217
+ messages.push({ type, data: { user_id: userId, nickname, content } });
220
218
  }
221
219
  }
222
- const params = { [message_type]: String(peer), messages };
223
- return await this.SendApi("send_forward_msg" /* OB11Api['send_forward_msg'] */, params);
220
+ const params = { [messageType]: String(peer), messages };
221
+ return await this.SendApi("send_forward_msg" /* OB11Api.sendForwardMsg */, params);
224
222
  }
225
223
  /**
226
224
  * 通过资源id发送转发消息
@@ -231,14 +229,14 @@ export class AdapterOneBot11 {
231
229
  let res;
232
230
  const { scene, peer } = contact;
233
231
  if (scene === "group" /* Scene.Group */) {
234
- res = await this.SendApi("send_msg" /* OB11Api['send_msg'] */, {
232
+ res = await this.SendApi("send_msg" /* OB11Api.sendMsg */, {
235
233
  message_type: "group" /* MessageType.Group */,
236
234
  group_id: Number(peer),
237
235
  message: [{ type: "forward" /* OB11SegmentType.Forward */, data: { id } }],
238
236
  });
239
237
  }
240
238
  else {
241
- res = await this.SendApi("send_msg" /* OB11Api['send_msg'] */, {
239
+ res = await this.SendApi("send_msg" /* OB11Api.sendMsg */, {
242
240
  message_type: "private" /* MessageType.Private */,
243
241
  user_id: Number(peer),
244
242
  message: [{ type: "forward" /* OB11SegmentType.Forward */, data: { id } }],
@@ -249,11 +247,11 @@ export class AdapterOneBot11 {
249
247
  /**
250
248
  * 撤回消息
251
249
  * @param _contact - ob11无需提供contact参数
252
- * @param message_id - 消息ID
250
+ * @param messageId - 消息ID
253
251
  */
254
- async RecallMessage(_contact, message_id) {
252
+ async RecallMessage(_contact, messageId) {
255
253
  try {
256
- await this.SendApi("delete_msg" /* OB11Api['delete_msg'] */, { message_id: Number(message_id) });
254
+ await this.SendApi("delete_msg" /* OB11Api.deleteMsg */, { message_id: Number(messageId) });
257
255
  return true;
258
256
  }
259
257
  catch {
@@ -263,10 +261,10 @@ export class AdapterOneBot11 {
263
261
  /**
264
262
  * 获取消息
265
263
  * @param contact - 联系人信息
266
- * @param message_id - 消息ID
264
+ * @param messageId - 消息ID
267
265
  */
268
- async GetMessage(contact, message_id) {
269
- const res = await this.SendApi("get_msg" /* OB11Api['get_msg'] */, { message_id: Number(message_id) });
266
+ async GetMessage(contact, messageId) {
267
+ const res = await this.SendApi("get_msg" /* OB11Api.getMsg */, { message_id: Number(messageId) });
270
268
  return {
271
269
  time: res.time,
272
270
  message_id: res.message_id + '',
@@ -288,24 +286,24 @@ export class AdapterOneBot11 {
288
286
  * 获取msg_id获取历史消息
289
287
  * @description 此api各平台实现不同
290
288
  */
291
- async GetHistoryMessage(contact, start_message_id, count = 1) {
292
- const message_seq = (await this.GetMessage(contact, start_message_id)).message_seq;
289
+ async GetHistoryMessage(contact, startMessageId, count = 1) {
290
+ const messageSeq = (await this.GetMessage(contact, startMessageId)).message_seq;
293
291
  // 先拿到消息的seq
294
292
  let options;
295
293
  if (this.version.name === 'Lagrange.OneBot') {
296
- options = { message_id: Number(start_message_id), message_count: count };
294
+ options = { message_id: Number(startMessageId), message_count: count };
297
295
  }
298
296
  else {
299
- options = { message_seq, message_count: count };
297
+ options = { message_seq: messageSeq, message_count: count };
300
298
  }
301
299
  let res;
302
300
  if (contact.scene === 'group') {
303
301
  options.group_id = Number(contact.peer);
304
- res = await this.SendApi("get_group_msg_history" /* OB11Api['get_group_msg_history'] */, options);
302
+ res = await this.SendApi("get_group_msg_history" /* OB11Api.getGroupMsgHistory */, options);
305
303
  }
306
304
  else {
307
305
  options.user_id = Number(contact.peer);
308
- res = await this.SendApi("get_friend_msg_history" /* OB11Api['get_friend_msg_history'] */, options);
306
+ res = await this.SendApi("get_friend_msg_history" /* OB11Api.getFriendMsgHistory */, options);
309
307
  }
310
308
  const all = [];
311
309
  const elements = this.AdapterConvertKarin(res);
@@ -333,13 +331,13 @@ export class AdapterOneBot11 {
333
331
  }
334
332
  /**
335
333
  * 发送好友赞
336
- * @param target_uid_or_uin - 用户ID
337
- * @param vote_count - 赞的次数,默认为`10`
334
+ * @param targetId - 用户ID
335
+ * @param voteCount - 赞的次数,默认为`10`
338
336
  */
339
- async VoteUser(target_uid_or_uin, vote_count = 10) {
340
- const user_id = Number(target_uid_or_uin);
337
+ async VoteUser(targetId, voteCount = 10) {
338
+ const userId = Number(targetId);
341
339
  try {
342
- await this.SendApi("send_like" /* OB11Api['send_like'] */, { user_id, times: vote_count });
340
+ await this.SendApi("send_like" /* OB11Api.sendLike */, { user_id: userId, times: voteCount });
343
341
  return true;
344
342
  }
345
343
  catch {
@@ -348,11 +346,15 @@ export class AdapterOneBot11 {
348
346
  }
349
347
  /**
350
348
  * 群组踢人
349
+ * @param groupId - 群号
350
+ * @param targetId - 用户ID
351
+ * @param rejectAddRequest - 是否拒绝此人的加群请求
352
+ * @param kickReason - 踢人理由
351
353
  */
352
- async KickMember(group_id, target_uid_or_uin, reject_add_request = false, kick_reason = '') {
353
- const user_id = Number(target_uid_or_uin);
354
+ async KickMember(groupId, targetId, rejectAddRequest = false, kickReason = '') {
355
+ const userId = Number(targetId);
354
356
  try {
355
- await this.SendApi("set_group_kick" /* OB11Api['set_group_kick'] */, { group_id: Number(group_id), user_id, reject_add_request });
357
+ await this.SendApi("set_group_kick" /* OB11Api.setGroupKick */, { group_id: Number(groupId), user_id: userId, reject_add_request: rejectAddRequest });
356
358
  return true;
357
359
  }
358
360
  catch {
@@ -361,14 +363,14 @@ export class AdapterOneBot11 {
361
363
  }
362
364
  /**
363
365
  * 禁言用户
364
- * @param group_id - 群号
365
- * @param target_uid_or_uin - 用户ID
366
+ * @param groupId - 群号
367
+ * @param targetId - 用户ID
366
368
  * @param duration - 禁言时长,单位秒,0 表示取消禁言
367
369
  */
368
- async BanMember(group_id, target_uid_or_uin, duration) {
369
- const user_id = Number(target_uid_or_uin);
370
+ async BanMember(groupId, targetId, duration) {
371
+ const userId = Number(targetId);
370
372
  try {
371
- await this.SendApi("set_group_ban" /* OB11Api['set_group_ban'] */, { group_id: Number(group_id), user_id, duration });
373
+ await this.SendApi("set_group_ban" /* OB11Api.setGroupBan */, { group_id: Number(groupId), user_id: userId, duration });
372
374
  return true;
373
375
  }
374
376
  catch {
@@ -377,12 +379,12 @@ export class AdapterOneBot11 {
377
379
  }
378
380
  /**
379
381
  * 群组全员禁言
380
- * @param group_id - 群号
381
- * @param is_ban - 是否全员禁言
382
+ * @param groupId - 群号
383
+ * @param isBan - 是否全员禁言
382
384
  */
383
- async SetGroupWholeBan(group_id, is_ban = true) {
385
+ async SetGroupWholeBan(groupId, isBan = true) {
384
386
  try {
385
- await this.SendApi("set_group_whole_ban" /* OB11Api['set_group_whole_ban'] */, { group_id: Number(group_id), enable: is_ban });
387
+ await this.SendApi("set_group_whole_ban" /* OB11Api.setGroupWholeBan */, { group_id: Number(groupId), enable: isBan });
386
388
  return true;
387
389
  }
388
390
  catch {
@@ -391,14 +393,14 @@ export class AdapterOneBot11 {
391
393
  }
392
394
  /**
393
395
  * 设置群管理员
394
- * @param group_id - 群号
395
- * @param target_uid_or_uin - 目标用户ID
396
- * @param is_admin - 是否设置为管理员
396
+ * @param groupId - 群号
397
+ * @param targetId - 目标用户ID
398
+ * @param isAdmin - 是否设置为管理员
397
399
  */
398
- async SetGroupAdmin(group_id, target_uid_or_uin, is_admin) {
400
+ async SetGroupAdmin(groupId, targetId, isAdmin) {
399
401
  try {
400
- const user_id = Number(target_uid_or_uin);
401
- await this.SendApi("set_group_admin" /* OB11Api['set_group_admin'] */, { group_id: Number(group_id), user_id, enable: is_admin });
402
+ const userId = Number(targetId);
403
+ await this.SendApi("set_group_admin" /* OB11Api.setGroupAdmin */, { group_id: Number(groupId), user_id: userId, enable: isAdmin });
402
404
  return true;
403
405
  }
404
406
  catch {
@@ -407,14 +409,14 @@ export class AdapterOneBot11 {
407
409
  }
408
410
  /**
409
411
  * 修改群名片
410
- * @param group_id - 群号
411
- * @param target_uid_or_uin - 目标用户ID
412
+ * @param groupId - 群号
413
+ * @param targetId - 目标用户ID
412
414
  * @param card - 新名片
413
415
  */
414
- async ModifyMemberCard(group_id, target_uid_or_uin, card) {
416
+ async ModifyMemberCard(groupId, targetId, card) {
415
417
  try {
416
- const user_id = Number(target_uid_or_uin);
417
- await this.SendApi("set_group_card" /* OB11Api['set_group_card'] */, { group_id: Number(group_id), user_id, card });
418
+ const userId = Number(targetId);
419
+ await this.SendApi("set_group_card" /* OB11Api.setGroupCard */, { group_id: Number(groupId), user_id: userId, card });
418
420
  return true;
419
421
  }
420
422
  catch {
@@ -423,12 +425,12 @@ export class AdapterOneBot11 {
423
425
  }
424
426
  /**
425
427
  * 设置群名
426
- * @param group_id - 群号
427
- * @param group_name - 新群名
428
+ * @param groupId - 群号
429
+ * @param groupName - 新群名
428
430
  */
429
- async ModifyGroupName(group_id, group_name) {
431
+ async ModifyGroupName(groupId, groupName) {
430
432
  try {
431
- await this.SendApi("set_group_name" /* OB11Api['set_group_name'] */, { group_id: Number(group_id), group_name });
433
+ await this.SendApi("set_group_name" /* OB11Api.setGroupName */, { group_id: Number(groupId), group_name: groupName });
432
434
  return true;
433
435
  }
434
436
  catch {
@@ -437,12 +439,12 @@ export class AdapterOneBot11 {
437
439
  }
438
440
  /**
439
441
  * 退出群组
440
- * @param group_id - 群号
441
- * @param is_dismiss - 是否解散,如果登录号是群主,则仅在此项为 true 时能够解散
442
+ * @param groupId - 群号
443
+ * @param isDismiss - 是否解散,如果登录号是群主,则仅在此项为 true 时能够解散
442
444
  */
443
- async LeaveGroup(group_id, is_dismiss = false) {
445
+ async LeaveGroup(groupId, isDismiss = false) {
444
446
  try {
445
- await this.SendApi("set_group_leave" /* OB11Api['set_group_leave'] */, { group_id: Number(group_id), is_dismiss });
447
+ await this.SendApi("set_group_leave" /* OB11Api.setGroupLeave */, { group_id: Number(groupId), is_dismiss: isDismiss });
446
448
  }
447
449
  catch {
448
450
  return false;
@@ -450,16 +452,16 @@ export class AdapterOneBot11 {
450
452
  }
451
453
  /**
452
454
  * 设置群专属头衔
453
- * @param group_id - 群号
454
- * @param target_uid_or_uin - 目标用户ID
455
+ * @param groupId - 群号
456
+ * @param targetId - 目标用户ID
455
457
  * @param special_title - 专属头衔
456
458
  */
457
- async SetGroupUniqueTitle(group_id, target_uid_or_uin, unique_title) {
458
- const user_id = Number(target_uid_or_uin);
459
- const special_title = unique_title;
459
+ async SetGroupUniqueTitle(groupId, targetId, uniqueTitle) {
460
+ const userId = Number(targetId);
461
+ const specialTitle = uniqueTitle;
460
462
  const duration = -1;
461
463
  try {
462
- await this.SendApi("set_group_special_title" /* OB11Api['set_group_special_title'] */, { group_id: Number(group_id), user_id, special_title, duration });
464
+ await this.SendApi("set_group_special_title" /* OB11Api.setGroupSpecialTitle */, { group_id: Number(groupId), user_id: userId, special_title: specialTitle, duration });
463
465
  }
464
466
  catch {
465
467
  return false;
@@ -469,7 +471,7 @@ export class AdapterOneBot11 {
469
471
  * 获取登录号信息
470
472
  */
471
473
  async GetCurrentAccount() {
472
- const res = await this.SendApi("get_login_info" /* OB11Api['get_login_info'] */);
474
+ const res = await this.SendApi("get_login_info" /* OB11Api.getLoginInfo */);
473
475
  return {
474
476
  account_uid: res.user_id + '',
475
477
  account_uin: res.user_id + '',
@@ -478,52 +480,32 @@ export class AdapterOneBot11 {
478
480
  }
479
481
  /**
480
482
  * 获取陌生人信息 不支持批量获取 只支持一个
481
- * @param target_uid_or_uin - 目标用户ID
483
+ * @param targetId - 目标用户ID
482
484
  */
483
- async GetStrangerProfileCard(target_uid_or_uin) {
484
- const user_id = Number(target_uid_or_uin[0]);
485
- const res = await this.SendApi("get_stranger_info" /* OB11Api['get_stranger_info'] */, { user_id, no_cache: true });
485
+ async GetStrangerProfileCard(targetId) {
486
+ const userId = Number(targetId[0]);
487
+ const res = await this.SendApi("get_stranger_info" /* OB11Api.getStrangerInfo */, { user_id: userId, no_cache: true });
486
488
  return [
487
489
  {
488
- /**
489
- * - 用户UID
490
- */
490
+ /** 用户UID */
491
491
  uid: res.user_id + '',
492
- /**
493
- * - 用户UIN
494
- */
492
+ /** 用户UIN */
495
493
  uin: res.user_id + '',
496
- /**
497
- * - qid
498
- */
494
+ /** qid */
499
495
  qid: '',
500
- /**
501
- * - 名称
502
- */
496
+ /** 名称 */
503
497
  nick: res.nickname,
504
- /**
505
- * - 备注
506
- */
498
+ /** 备注 */
507
499
  remark: '',
508
- /**
509
- * - 用户等级
510
- */
500
+ /** 用户等级 */
511
501
  level: 0,
512
- /**
513
- * - 生日
514
- */
502
+ /** 生日 */
515
503
  birthday: '',
516
- /**
517
- * - 登录天数
518
- */
504
+ /** 登录天数 */
519
505
  login_day: 0,
520
- /**
521
- * - 点赞数
522
- */
506
+ /** 点赞数 */
523
507
  vote_cnt: 0,
524
- /**
525
- * - 学校是否已核实
526
- */
508
+ /** 学校是否已核实 */
527
509
  is_school_verified: undefined,
528
510
  /**
529
511
  * - 年龄
@@ -564,49 +546,29 @@ export class AdapterOneBot11 {
564
546
  * 获取好友列表
565
547
  */
566
548
  async GetFriendList() {
567
- const friendList = await this.SendApi("get_friend_list" /* OB11Api['get_friend_list'] */);
549
+ const friendList = await this.SendApi("get_friend_list" /* OB11Api.getFriendList */);
568
550
  return friendList.map(v => {
569
- const user_id = v.user_id + '';
551
+ const userId = v.user_id + '';
570
552
  return {
571
- /**
572
- * - 用户UID
573
- */
574
- uid: user_id,
575
- /**
576
- * - 用户UIN
577
- */
578
- uin: user_id,
579
- /**
580
- * - qid
581
- */
553
+ /** 用户UID */
554
+ uid: userId,
555
+ /** 用户UIN */
556
+ uin: userId,
557
+ /** qid */
582
558
  qid: '',
583
- /**
584
- * - 名称
585
- */
559
+ /** 名称 */
586
560
  nick: v.nickname,
587
- /**
588
- * - 备注
589
- */
561
+ /** 备注 */
590
562
  remark: '',
591
- /**
592
- * - 用户等级
593
- */
563
+ /** 用户等级 */
594
564
  level: 0,
595
- /**
596
- * - 生日
597
- */
565
+ /** 生日 */
598
566
  birthday: '',
599
- /**
600
- * - 登录天数
601
- */
567
+ /** 登录天数 */
602
568
  login_day: 0,
603
- /**
604
- * - 点赞数
605
- */
569
+ /** 点赞数 */
606
570
  vote_cnt: 0,
607
- /**
608
- * - 学校是否已核实
609
- */
571
+ /** 学校是否已核实 */
610
572
  is_school_verified: undefined,
611
573
  /**
612
574
  * - 年龄
@@ -645,11 +607,11 @@ export class AdapterOneBot11 {
645
607
  }
646
608
  /**
647
609
  * 获取群信息
648
- * @param group_id - 群号
649
- * @param no_cache - 是否不使用缓存
610
+ * @param _groupId - 群号
611
+ * @param noCache - 是否不使用缓存
650
612
  */
651
- async GetGroupInfo(group_id, no_cache = false) {
652
- const info = await this.SendApi("get_group_info" /* OB11Api['get_group_info'] */, { group_id: Number(group_id), no_cache });
613
+ async GetGroupInfo(_groupId, noCache = false) {
614
+ const info = await this.SendApi("get_group_info" /* OB11Api.getGroupInfo */, { group_id: Number(_groupId), no_cache: noCache });
653
615
  const groupId = info.group_id + '';
654
616
  const groupName = info.group_name;
655
617
  // todo 可以走群成员列表获取群主
@@ -668,7 +630,7 @@ export class AdapterOneBot11 {
668
630
  * 获取群列表
669
631
  */
670
632
  async GetGroupList() {
671
- const groupList = await this.SendApi("get_group_list" /* OB11Api['get_group_list'] */);
633
+ const groupList = await this.SendApi("get_group_list" /* OB11Api.getGroupList */);
672
634
  return groupList.map(v => {
673
635
  const groupId = v.group_id + '';
674
636
  const groupName = v.group_name;
@@ -686,16 +648,16 @@ export class AdapterOneBot11 {
686
648
  }
687
649
  /**
688
650
  * 获取群成员信息
689
- * @param group_id - 群号
690
- * @param target_uid_or_uin - 目标用户ID
651
+ * @param groupId - 群号
652
+ * @param targetId - 目标用户ID
691
653
  * @param refresh - 是否刷新缓存,默认为 false
692
654
  */
693
- async GetGroupMemberInfo(group_id, target_uid_or_uin, refresh = false) {
694
- const user_id = Number(target_uid_or_uin);
695
- const info = await this.SendApi("get_group_member_info" /* OB11Api['get_group_member_info'] */, { group_id: Number(group_id), user_id, no_cache: refresh });
655
+ async GetGroupMemberInfo(groupId, targetId, refresh = false) {
656
+ const userId = Number(targetId);
657
+ const info = await this.SendApi("get_group_member_info" /* OB11Api.getGroupMemberInfo */, { group_id: Number(groupId), user_id: userId, no_cache: refresh });
696
658
  return {
697
- uid: target_uid_or_uin,
698
- uin: target_uid_or_uin,
659
+ uid: targetId,
660
+ uin: targetId,
699
661
  nick: info.nickname,
700
662
  role: info.role,
701
663
  age: info.age,
@@ -714,16 +676,16 @@ export class AdapterOneBot11 {
714
676
  }
715
677
  /**
716
678
  * 获取群成员列表
717
- * @param group_id - 群号
679
+ * @param groupId - 群号
718
680
  * @param refresh - 是否刷新缓存,默认为 false
719
681
  */
720
- async GetGroupMemberList(group_id, refresh = false) {
721
- const gl = await this.SendApi("get_group_member_list" /* OB11Api['get_group_member_list'] */, { group_id: Number(group_id), no_cache: refresh });
682
+ async GetGroupMemberList(groupId, refresh = false) {
683
+ const gl = await this.SendApi("get_group_member_list" /* OB11Api.getGroupMemberList */, { group_id: Number(groupId), no_cache: refresh });
722
684
  return gl.map(v => {
723
- const user_id = v.user_id + '';
685
+ const userId = v.user_id + '';
724
686
  return {
725
- uid: user_id,
726
- uin: user_id,
687
+ uid: userId,
688
+ uin: userId,
727
689
  nick: v.nickname,
728
690
  role: v.role,
729
691
  age: v.age,
@@ -744,14 +706,14 @@ export class AdapterOneBot11 {
744
706
  /**
745
707
  * 获取群荣誉信息
746
708
  */
747
- async GetGroupHonor(group_id, refresh = false) {
748
- const groupHonor = await this.SendApi("get_group_honor_info" /* OB11Api['get_group_honor_info'] */, { group_id: Number(group_id), type: 'all' });
709
+ async GetGroupHonor(groupId, refresh = false) {
710
+ const groupHonor = await this.SendApi("get_group_honor_info" /* OB11Api.getGroupHonorInfo */, { group_id: Number(groupId), type: 'all' });
749
711
  const result = [];
750
712
  groupHonor.talkative_list.forEach(honor => {
751
- const user_id = honor.user_id + '';
713
+ const userId = honor.user_id + '';
752
714
  result.push({
753
- uin: user_id,
754
- uid: user_id,
715
+ uin: userId,
716
+ uid: userId,
755
717
  nick: honor.nickname,
756
718
  honor_name: '历史龙王',
757
719
  id: 0,
@@ -760,10 +722,10 @@ export class AdapterOneBot11 {
760
722
  });
761
723
  });
762
724
  groupHonor.performer_list.forEach(honor => {
763
- const user_id = honor.user_id + '';
725
+ const userId = honor.user_id + '';
764
726
  result.push({
765
- uin: user_id,
766
- uid: user_id,
727
+ uin: userId,
728
+ uid: userId,
767
729
  nick: honor.nickname,
768
730
  honor_name: '群聊之火',
769
731
  avatar: honor.avatar,
@@ -772,10 +734,10 @@ export class AdapterOneBot11 {
772
734
  });
773
735
  });
774
736
  groupHonor.legend_list.forEach(honor => {
775
- const user_id = honor.user_id + '';
737
+ const userId = honor.user_id + '';
776
738
  result.push({
777
- uin: user_id,
778
- uid: user_id,
739
+ uin: userId,
740
+ uid: userId,
779
741
  nick: honor.nickname,
780
742
  honor_name: '群聊炽焰',
781
743
  avatar: honor.avatar,
@@ -784,10 +746,10 @@ export class AdapterOneBot11 {
784
746
  });
785
747
  });
786
748
  groupHonor.strong_newbie_list.forEach(honor => {
787
- const user_id = honor.user_id + '';
749
+ const userId = honor.user_id + '';
788
750
  result.push({
789
- uin: user_id,
790
- uid: user_id,
751
+ uin: userId,
752
+ uid: userId,
791
753
  nick: honor.nickname,
792
754
  honor_name: '冒尖小春笋',
793
755
  avatar: honor.avatar,
@@ -796,10 +758,10 @@ export class AdapterOneBot11 {
796
758
  });
797
759
  });
798
760
  groupHonor.emotion_list.forEach(honor => {
799
- const user_id = honor.user_id + '';
761
+ const userId = honor.user_id + '';
800
762
  result.push({
801
- uin: user_id,
802
- uid: user_id,
763
+ uin: userId,
764
+ uid: userId,
803
765
  nick: honor.nickname,
804
766
  honor_name: '快乐之源',
805
767
  avatar: honor.avatar,
@@ -812,12 +774,12 @@ export class AdapterOneBot11 {
812
774
  /**
813
775
  * 对消息进行表情回应
814
776
  * @param contact - 联系人信息
815
- * @param message_id - 消息ID
816
- * @param face_id - 表情ID
777
+ * @param messageId - 消息ID
778
+ * @param faceId - 表情ID
817
779
  */
818
- async ReactMessageWithEmoji(contact, message_id, face_id, is_set = true) {
780
+ async ReactMessageWithEmoji(contact, messageId, faceId, isSet = true) {
819
781
  try {
820
- await this.SendApi("set_msg_emoji_like" /* OB11Api['set_msg_emoji_like'] */, { message_id, emoji_id: face_id, is_set });
782
+ await this.SendApi("set_msg_emoji_like" /* OB11Api.setMsgEmojiLike */, { message_id: messageId, emoji_id: faceId, is_set: isSet });
821
783
  return true;
822
784
  }
823
785
  catch {
@@ -828,7 +790,7 @@ export class AdapterOneBot11 {
828
790
  * 获取版本信息
829
791
  */
830
792
  async GetVersion() {
831
- const res = await this.SendApi("get_version_info" /* OB11Api['get_version_info'] */);
793
+ const res = await this.SendApi("get_version_info" /* OB11Api.getVersionInfo */);
832
794
  return {
833
795
  name: res.app_name,
834
796
  app_name: res.app_name,
@@ -836,65 +798,41 @@ export class AdapterOneBot11 {
836
798
  protocol: res.protocol_version,
837
799
  };
838
800
  }
839
- async DownloadForwardMessage(res_id) {
801
+ async DownloadForwardMessage(resId) {
840
802
  throw new Error('Method not implemented.');
841
803
  }
842
804
  /**
843
805
  * 精华消息
844
806
  */
845
- async GetEssenceMessageList(group_id, page, page_size) {
807
+ async GetEssenceMessageList(groupId, page, pageSize) {
846
808
  const list = [];
847
- const res = await this.SendApi("get_essence_msg_list" /* OB11Api['get_essence_msg_list'] */, { group_id: Number(group_id) });
809
+ const res = await this.SendApi("get_essence_msg_list" /* OB11Api.getEssenceMsgList */, { group_id: Number(groupId) });
848
810
  for (const v of res) {
849
- const { message_seq, elements } = await this.GetMessage({ scene: "group" /* Scene.Group */, peer: group_id }, v.message_id + '');
811
+ const { message_seq: messageSeq, elements } = await this.GetMessage({ scene: "group" /* Scene.Group */, peer: groupId }, v.message_id + '');
850
812
  list.push({
851
- /**
852
- * - 群ID
853
- */
854
- group_id,
855
- /**
856
- * - 发送者uid
857
- */
813
+ /** 群ID */
814
+ group_id: groupId,
815
+ /** 发送者uid */
858
816
  sender_uid: v.sender_id + '',
859
- /**
860
- * - 发送者uin
861
- */
817
+ /** 发送者uin */
862
818
  sender_uin: v.sender_id + '',
863
- /**
864
- * - 发送者昵称
865
- */
819
+ /** 发送者昵称 */
866
820
  sender_nick: v.sender_nick,
867
- /**
868
- * - 操作者uid
869
- */
821
+ /** 操作者uid */
870
822
  operator_uid: v.operator_id + '',
871
- /**
872
- * - 操作者uin
873
- */
823
+ /** 操作者uin */
874
824
  operator_uin: v.operator_id + '',
875
- /**
876
- * - 操作者昵称
877
- */
825
+ /** 操作者昵称 */
878
826
  operator_nick: v.operator_nick,
879
- /**
880
- * - 操作时间
881
- */
827
+ /** 操作时间 */
882
828
  operation_time: v.operator_time,
883
- /**
884
- * - 消息时间
885
- */
829
+ /** 消息时间 */
886
830
  message_time: v.sender_time,
887
- /**
888
- * - 消息ID
889
- */
831
+ /** 消息ID */
890
832
  message_id: v.message_id + '',
891
- /**
892
- * - 消息序列号
893
- */
894
- message_seq,
895
- /**
896
- * - 被设置的精华消息元素文本
897
- */
833
+ /** 消息序列号 */
834
+ message_seq: messageSeq,
835
+ /** 被设置的精华消息元素文本 */
898
836
  json_elements: JSON.stringify(elements),
899
837
  });
900
838
  }
@@ -902,14 +840,14 @@ export class AdapterOneBot11 {
902
840
  }
903
841
  /**
904
842
  * 上传群文件
905
- * @param group_id - 群号
843
+ * @param groupId - 群号
906
844
  * @param file - 本地文件绝对路径
907
845
  * @param name - 文件名称 必须提供
908
846
  * @param folder - 父目录ID 不提供则上传到根目录
909
847
  */
910
- async UploadGroupFile(group_id, file, name, folder) {
848
+ async UploadGroupFile(groupId, file, name, folder) {
911
849
  try {
912
- await this.SendApi("upload_group_file" /* OB11Api['upload_group_file'] */, { group_id: Number(group_id), file, name, folder });
850
+ await this.SendApi("upload_group_file" /* OB11Api.uploadGroupFile */, { group_id: Number(groupId), file, name, folder });
913
851
  return true;
914
852
  }
915
853
  catch {
@@ -918,13 +856,13 @@ export class AdapterOneBot11 {
918
856
  }
919
857
  /**
920
858
  * 上传私聊文件
921
- * @param user_id - 用户ID
859
+ * @param userId - 用户ID
922
860
  * @param file - 本地文件绝对路径
923
861
  * @param name - 文件名称 必须提供
924
862
  */
925
- async UploadPrivateFile(user_id, file, name) {
863
+ async UploadPrivateFile(userId, file, name) {
926
864
  try {
927
- await this.SendApi("upload_private_file" /* OB11Api['upload_private_file'] */, { user_id: Number(user_id), file, name });
865
+ await this.SendApi("upload_private_file" /* OB11Api.uploadPrivateFile */, { user_id: Number(userId), file, name });
928
866
  return true;
929
867
  }
930
868
  catch {
@@ -933,12 +871,12 @@ export class AdapterOneBot11 {
933
871
  }
934
872
  /**
935
873
  * 设置精华消息
936
- * @param _group_id - 群号
937
- * @param message_id - 消息ID
874
+ * @param _groupId - 群号
875
+ * @param messageId - 消息ID
938
876
  */
939
- async SetEssenceMessage(_group_id, message_id) {
877
+ async SetEssenceMessage(_groupId, messageId) {
940
878
  try {
941
- await this.SendApi("set_essence_msg" /* OB11Api['set_essence_msg'] */, { message_id: Number(message_id) });
879
+ await this.SendApi("set_essence_msg" /* OB11Api.setEssenceMsg */, { message_id: Number(messageId) });
942
880
  return true;
943
881
  }
944
882
  catch {
@@ -947,43 +885,43 @@ export class AdapterOneBot11 {
947
885
  }
948
886
  /**
949
887
  * 移除精华消息
950
- * @param _group_id - 群号
951
- * @param message_id - 消息ID
888
+ * @param _groupId - 群号
889
+ * @param messageId - 消息ID
952
890
  */
953
- async DeleteEssenceMessage(_group_id, message_id) {
891
+ async DeleteEssenceMessage(_groupId, messageId) {
954
892
  try {
955
- await this.SendApi("delete_essence_msg" /* OB11Api['delete_essence_msg'] */, { message_id: Number(message_id) });
893
+ await this.SendApi("delete_essence_msg" /* OB11Api.deleteEssenceMsg */, { message_id: Number(messageId) });
956
894
  return true;
957
895
  }
958
896
  catch {
959
897
  return false;
960
898
  }
961
899
  }
962
- async PokeMember(group_id, target_uid_or_uin) {
900
+ async PokeMember(groupId, targetId) {
963
901
  // 这个接口比较特殊 暂时先搁置 lgl单独接口 shamrock单独接口 gocq字段不一样 llob貌似没实现?
964
902
  throw new Error('Method not implemented.');
965
903
  }
966
- async SetFriendApplyResult(request_id, is_approve, remark) {
904
+ async SetFriendApplyResult(requestId, isApprove, remark) {
967
905
  try {
968
- await this.SendApi("set_friend_add_request" /* OB11Api['set_friend_add_request'] */, { flag: request_id, approve: is_approve, remark });
906
+ await this.SendApi("set_friend_add_request" /* OB11Api.setFriendAddRequest */, { flag: requestId, approve: isApprove, remark });
969
907
  return true;
970
908
  }
971
909
  catch {
972
910
  return false;
973
911
  }
974
912
  }
975
- async SetGroupApplyResult(request_id, is_approve, deny_reason) {
913
+ async SetGroupApplyResult(requestId, isApprove, denyReason) {
976
914
  try {
977
- await this.SendApi("set_group_add_request" /* OB11Api['set_group_add_request'] */, { flag: request_id, approve: is_approve, sub_type: 'add', reason: deny_reason });
915
+ await this.SendApi("set_group_add_request" /* OB11Api.setGroupAddRequest */, { flag: requestId, approve: isApprove, sub_type: 'add', reason: denyReason });
978
916
  return true;
979
917
  }
980
918
  catch {
981
919
  return false;
982
920
  }
983
921
  }
984
- async SetInvitedJoinGroupResult(request_id, is_approve, deny_reason) {
922
+ async SetInvitedJoinGroupResult(requestId, isApprove, denyReason) {
985
923
  try {
986
- await this.SendApi("set_group_add_request" /* OB11Api['set_group_add_request'] */, { flag: request_id, approve: is_approve, sub_type: 'invite', reason: deny_reason });
924
+ await this.SendApi("set_group_add_request" /* OB11Api.setGroupAddRequest */, { flag: requestId, approve: isApprove, sub_type: 'invite', reason: denyReason });
987
925
  return true;
988
926
  }
989
927
  catch {
@@ -1003,11 +941,11 @@ export class AdapterOneBot11 {
1003
941
  GetProhibitedUserList() { throw new Error('Method not implemented.'); }
1004
942
  SetMessageReaded() { throw new Error('Method not implemented.'); }
1005
943
  async sendForwardMessage(contact, elements) {
1006
- let message_id = await this.UploadForwardMessage(contact, elements);
944
+ let messageId = await this.UploadForwardMessage(contact, elements);
1007
945
  if (this.version.name === 'Lagrange.OneBot') {
1008
- message_id = (await this.SendMessage(contact, [segment.forward(message_id)])).message_id;
946
+ messageId = (await this.SendMessage(contact, [segment.forward(messageId)])).message_id;
1009
947
  }
1010
- return { message_id };
948
+ return { message_id: messageId };
1011
949
  }
1012
950
  /**
1013
951
  * 发送API请求