@naplink/naplink 0.0.1 → 0.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 CHANGED
@@ -594,6 +594,20 @@ var ResponseRegistry = class {
594
594
  this.pending.set(echo, entry);
595
595
  return entry;
596
596
  }
597
+ get(echo) {
598
+ return this.pending.get(echo);
599
+ }
600
+ refresh(echo) {
601
+ const req = this.pending.get(echo);
602
+ if (!req) return false;
603
+ clearTimeout(req.timer);
604
+ req.createdAt = Date.now();
605
+ req.timer = setTimeout(() => {
606
+ this.pending.delete(echo);
607
+ req.reject(new ApiTimeoutError(req.method, req.timeoutMs));
608
+ }, req.timeoutMs);
609
+ return true;
610
+ }
597
611
  resolve(echo, data) {
598
612
  const req = this.pending.get(echo);
599
613
  if (!req) return false;
@@ -661,6 +675,52 @@ async function withRetry(fn, retries, method, logger, delayFn) {
661
675
  }
662
676
 
663
677
  // src/core/api-client.ts
678
+ var AsyncQueue = class {
679
+ values = [];
680
+ waiters = [];
681
+ closed = false;
682
+ push(value) {
683
+ if (this.closed) return;
684
+ const waiter = this.waiters.shift();
685
+ if (waiter) {
686
+ waiter.resolve({ value, done: false });
687
+ } else {
688
+ this.values.push(value);
689
+ }
690
+ }
691
+ close() {
692
+ if (this.closed) return;
693
+ this.closed = true;
694
+ while (this.waiters.length) {
695
+ this.waiters.shift().resolve({ value: void 0, done: true });
696
+ }
697
+ }
698
+ fail(error) {
699
+ if (this.closed) return;
700
+ this.closed = true;
701
+ while (this.waiters.length) {
702
+ this.waiters.shift().reject(error);
703
+ }
704
+ this.values = [];
705
+ }
706
+ async next() {
707
+ if (this.values.length) {
708
+ return { value: this.values.shift(), done: false };
709
+ }
710
+ if (this.closed) {
711
+ return { value: void 0, done: true };
712
+ }
713
+ return await new Promise((resolve, reject) => {
714
+ this.waiters.push({
715
+ resolve,
716
+ reject: (err) => reject(err)
717
+ });
718
+ });
719
+ }
720
+ [Symbol.asyncIterator]() {
721
+ return this;
722
+ }
723
+ };
664
724
  var ApiClient = class {
665
725
  constructor(connection, config, logger) {
666
726
  this.connection = connection;
@@ -688,32 +748,68 @@ var ApiClient = class {
688
748
  this.delay.bind(this)
689
749
  );
690
750
  }
751
+ /**
752
+ * 调用流式 API(NapCat stream-action)
753
+ * 会持续产出 data.type=stream 的分片包,并在 data.type=response 时结束。
754
+ */
755
+ callStream(method, params = {}, options) {
756
+ const timeout = options?.timeout ?? this.config.api.timeout;
757
+ const queue = new AsyncQueue();
758
+ const result = this.sendRequest(method, params, timeout, {
759
+ onPacket: (packet) => queue.push(packet),
760
+ onEnd: () => queue.close(),
761
+ onError: (error) => queue.fail(error)
762
+ });
763
+ return { packets: queue, result };
764
+ }
691
765
  /**
692
766
  * 处理API响应
693
767
  * 由连接管理器调用
694
768
  */
695
769
  handleResponse(echo, response) {
696
- const request = this.registry.take(echo);
770
+ const request = this.registry.get(echo);
697
771
  if (!request) {
698
- this.logger.warn(`\u6536\u5230\u672A\u77E5\u8BF7\u6C42\u7684\u54CD\u5E94: ${echo}`);
772
+ if (response?.stream === "stream-action") {
773
+ this.logger.debug(`\u6536\u5230\u672A\u77E5\u6D41\u5F0F\u54CD\u5E94: ${echo}`);
774
+ } else {
775
+ this.logger.warn(`\u6536\u5230\u672A\u77E5\u8BF7\u6C42\u7684\u54CD\u5E94: ${echo}`);
776
+ }
699
777
  return;
700
778
  }
779
+ const isStreamAction = response?.stream === "stream-action" || typeof response?.data?.type === "string" && ["stream", "response", "reset", "error"].includes(response.data.type);
701
780
  if (response.status === "ok" || response.retcode === 0) {
781
+ if (isStreamAction) {
782
+ const packet = response.data;
783
+ const packetType = packet?.type;
784
+ if (request.onPacket) {
785
+ this.registry.refresh(echo);
786
+ request.onPacket(packet);
787
+ if (packetType === "response") {
788
+ this.logger.debug(`API\u6D41\u5F0F\u5B8C\u6210: ${request.method}`);
789
+ this.registry.resolve(echo, packet);
790
+ request.onEnd?.();
791
+ }
792
+ return;
793
+ }
794
+ this.logger.debug(`API\u6210\u529F(stream): ${request.method}`);
795
+ this.registry.resolve(echo, packet);
796
+ return;
797
+ }
702
798
  this.logger.debug(`API\u6210\u529F: ${request.method}`);
703
- request.resolve(response.data);
799
+ this.registry.resolve(echo, response.data);
704
800
  } else {
705
801
  this.logger.warn(`API\u5931\u8D25: ${request.method}`, {
706
802
  retcode: response.retcode,
707
803
  message: response.message
708
804
  });
709
- request.reject(
710
- new ApiError(
711
- request.method,
712
- response.retcode,
713
- response.message,
714
- response.wording
715
- )
805
+ const error = new ApiError(
806
+ request.method,
807
+ response.retcode,
808
+ response.message,
809
+ response.wording
716
810
  );
811
+ request.onError?.(error);
812
+ this.registry.reject(echo, error);
717
813
  }
718
814
  }
719
815
  /**
@@ -729,17 +825,19 @@ var ApiClient = class {
729
825
  /**
730
826
  * 发送API请求
731
827
  */
732
- sendRequest(method, params, timeout) {
828
+ sendRequest(method, params, timeout, hooks) {
733
829
  return new Promise((resolve, reject) => {
734
830
  const echo = this.generateRequestId();
735
831
  this.logger.debug(`\u53D1\u9001API\u8BF7\u6C42: ${method}`, { echo, params });
736
832
  this.registry.add(
737
833
  echo,
738
834
  {
739
- resolve,
740
- reject,
835
+ resolve: (data) => resolve(data),
836
+ reject: (error) => reject(error),
741
837
  createdAt: Date.now(),
742
- method
838
+ method,
839
+ timeoutMs: timeout,
840
+ ...hooks ?? {}
743
841
  },
744
842
  timeout
745
843
  );
@@ -751,6 +849,7 @@ var ApiClient = class {
751
849
  this.connection.send(payload);
752
850
  } catch (error) {
753
851
  this.registry.reject(echo, error);
852
+ hooks?.onError?.(error);
754
853
  reject(error);
755
854
  }
756
855
  });
@@ -1002,6 +1101,15 @@ function createMessageApi(client) {
1002
1101
  markMessageAsRead(messageId) {
1003
1102
  return client.call("mark_msg_as_read", { message_id: messageId });
1004
1103
  },
1104
+ markGroupMsgAsRead(groupId) {
1105
+ return client.call("mark_group_msg_as_read", { group_id: groupId });
1106
+ },
1107
+ markPrivateMsgAsRead(userId) {
1108
+ return client.call("mark_private_msg_as_read", { user_id: userId });
1109
+ },
1110
+ markAllMsgAsRead() {
1111
+ return client.call("_mark_all_as_read");
1112
+ },
1005
1113
  getGroupAtAllRemain(groupId) {
1006
1114
  return client.call("get_group_at_all_remain", { group_id: groupId });
1007
1115
  },
@@ -1010,6 +1118,30 @@ function createMessageApi(client) {
1010
1118
  },
1011
1119
  getGroupHonorInfo(groupId, type) {
1012
1120
  return client.call("get_group_honor_info", { group_id: groupId, type });
1121
+ },
1122
+ getGroupMsgHistory(params) {
1123
+ return client.call("get_group_msg_history", params);
1124
+ },
1125
+ getFriendMsgHistory(params) {
1126
+ return client.call("get_friend_msg_history", params);
1127
+ },
1128
+ getRecentContact(count) {
1129
+ return client.call("get_recent_contact", { count });
1130
+ },
1131
+ setMsgEmojiLike(messageId, emojiId, set) {
1132
+ return client.call("set_msg_emoji_like", { message_id: messageId, emoji_id: emojiId, set });
1133
+ },
1134
+ fetchEmojiLike(params) {
1135
+ return client.call("fetch_emoji_like", params);
1136
+ },
1137
+ sendGroupPoke(groupId, userId) {
1138
+ return client.call("group_poke", { group_id: groupId, user_id: userId });
1139
+ },
1140
+ sendFriendPoke(userId) {
1141
+ return client.call("friend_poke", { user_id: userId });
1142
+ },
1143
+ sendPoke(targetId, groupId) {
1144
+ return client.call("send_poke", groupId ? { group_id: groupId, target_id: targetId } : { user_id: targetId });
1013
1145
  }
1014
1146
  };
1015
1147
  }
@@ -1033,26 +1165,29 @@ function createMediaApi(client, logger) {
1033
1165
  const data = segment?.data;
1034
1166
  if (!type || !data) return;
1035
1167
  if (["image", "video", "record", "audio", "file"].includes(type)) {
1036
- const fileId = data.file;
1168
+ const fileId = data.file ?? data.file_id;
1037
1169
  if (typeof fileId === "string" && !/^https?:\/\//.test(fileId) && !fileId.startsWith("file://")) {
1038
1170
  try {
1039
1171
  const res = await api.getFile(fileId);
1040
- if (res?.file) {
1041
- data.url = res.file;
1042
- data.file = res.file;
1172
+ const hydratedUrl = res?.file ?? res?.url;
1173
+ if (hydratedUrl) {
1174
+ data.url = hydratedUrl;
1175
+ data.file = hydratedUrl;
1043
1176
  return;
1044
1177
  }
1045
1178
  if (type === "record" || type === "audio") {
1046
1179
  const rec = await api.getRecord(fileId, "mp3");
1047
- if (rec?.file) {
1048
- data.url = rec.file;
1049
- data.file = rec.file;
1180
+ const recUrl = rec?.file ?? rec?.url;
1181
+ if (recUrl) {
1182
+ data.url = recUrl;
1183
+ data.file = recUrl;
1050
1184
  }
1051
1185
  } else if (type === "image") {
1052
1186
  const img = await api.getImage(fileId);
1053
- if (img?.file) {
1054
- data.url = img.file;
1055
- data.file = img.file;
1187
+ const imgUrl = img?.file ?? img?.url;
1188
+ if (imgUrl) {
1189
+ data.url = imgUrl;
1190
+ data.file = imgUrl;
1056
1191
  }
1057
1192
  }
1058
1193
  } catch (e) {
@@ -1272,7 +1407,39 @@ async function computeSha256(source) {
1272
1407
  }
1273
1408
 
1274
1409
  // src/api/onebot/stream.ts
1410
+ import { createWriteStream as createWriteStream3 } from "fs";
1411
+ import { promises as fs3 } from "fs";
1412
+ import { tmpdir as tmpdir3 } from "os";
1413
+ import { join as join3 } from "path";
1275
1414
  function createStreamApi(client) {
1415
+ const downloadToFile = async (action, params, filenameHint) => {
1416
+ const { packets } = client.callStream(action, params);
1417
+ let fileInfo;
1418
+ const tempPath = join3(tmpdir3(), `${randomUUID3()}-${filenameHint || "naplink.download"}`);
1419
+ const writeStream = createWriteStream3(tempPath);
1420
+ try {
1421
+ for await (const packet of packets) {
1422
+ if (packet?.data_type === "file_info") {
1423
+ fileInfo = packet;
1424
+ }
1425
+ if (packet?.data_type === "file_chunk" && typeof packet.data === "string") {
1426
+ writeStream.write(Buffer.from(packet.data, "base64"));
1427
+ }
1428
+ }
1429
+ await new Promise((resolve, reject) => {
1430
+ writeStream.once("error", reject);
1431
+ writeStream.end(() => resolve());
1432
+ });
1433
+ return { path: tempPath, info: fileInfo };
1434
+ } catch (error) {
1435
+ try {
1436
+ writeStream.destroy();
1437
+ } catch {
1438
+ }
1439
+ await fs3.unlink(tempPath).catch(() => void 0);
1440
+ throw error;
1441
+ }
1442
+ };
1276
1443
  return {
1277
1444
  async uploadFileStream(file, options) {
1278
1445
  const chunkSize = options?.chunkSize ?? 256 * 1024;
@@ -1311,7 +1478,48 @@ function createStreamApi(client) {
1311
1478
  return completion;
1312
1479
  },
1313
1480
  getUploadStreamStatus(streamId) {
1314
- return client.call("upload_file_stream", { stream_id: streamId });
1481
+ return client.call("upload_file_stream", { stream_id: streamId, verify_only: true });
1482
+ },
1483
+ downloadFileStream(fileId, options) {
1484
+ const chunkSize = options?.chunkSize ?? 64 * 1024;
1485
+ return client.callStream("download_file_stream", {
1486
+ file: fileId,
1487
+ chunk_size: chunkSize
1488
+ });
1489
+ },
1490
+ async downloadFileStreamToFile(fileId, options) {
1491
+ const chunkSize = options?.chunkSize ?? 64 * 1024;
1492
+ return downloadToFile("download_file_stream", { file: fileId, chunk_size: chunkSize }, options?.filename);
1493
+ },
1494
+ downloadFileImageStream(fileId, options) {
1495
+ const chunkSize = options?.chunkSize ?? 64 * 1024;
1496
+ return client.callStream("download_file_image_stream", {
1497
+ file: fileId,
1498
+ chunk_size: chunkSize
1499
+ });
1500
+ },
1501
+ async downloadFileImageStreamToFile(fileId, options) {
1502
+ const chunkSize = options?.chunkSize ?? 64 * 1024;
1503
+ return downloadToFile("download_file_image_stream", { file: fileId, chunk_size: chunkSize }, options?.filename);
1504
+ },
1505
+ downloadFileRecordStream(fileId, outFormat, options) {
1506
+ const chunkSize = options?.chunkSize ?? 64 * 1024;
1507
+ return client.callStream("download_file_record_stream", {
1508
+ file: fileId,
1509
+ chunk_size: chunkSize,
1510
+ out_format: outFormat
1511
+ });
1512
+ },
1513
+ async downloadFileRecordStreamToFile(fileId, outFormat, options) {
1514
+ const chunkSize = options?.chunkSize ?? 64 * 1024;
1515
+ return downloadToFile(
1516
+ "download_file_record_stream",
1517
+ { file: fileId, chunk_size: chunkSize, out_format: outFormat },
1518
+ options?.filename
1519
+ );
1520
+ },
1521
+ cleanStreamTempFile() {
1522
+ return client.call("clean_stream_temp_file");
1315
1523
  }
1316
1524
  };
1317
1525
  }
@@ -1328,6 +1536,328 @@ function createRequestApi(client) {
1328
1536
  };
1329
1537
  }
1330
1538
 
1539
+ // src/api/onebot/system.ts
1540
+ function createSystemApi(client) {
1541
+ return {
1542
+ getOnlineClients(noCache = false) {
1543
+ return client.call("get_online_clients", { no_cache: noCache });
1544
+ },
1545
+ getRobotUinRange() {
1546
+ return client.call("get_robot_uin_range");
1547
+ },
1548
+ canSendImage() {
1549
+ return client.call("can_send_image");
1550
+ },
1551
+ canSendRecord() {
1552
+ return client.call("can_send_record");
1553
+ },
1554
+ getCookies(domain) {
1555
+ return client.call("get_cookies", { domain });
1556
+ },
1557
+ getCsrfToken() {
1558
+ return client.call("get_csrf_token");
1559
+ },
1560
+ getCredentials(domain) {
1561
+ return client.call("get_credentials", { domain });
1562
+ },
1563
+ setInputStatus(userId, eventType) {
1564
+ return client.call("set_input_status", { user_id: userId, event_type: eventType, eventType });
1565
+ },
1566
+ ocrImage(image, dot = false) {
1567
+ return client.call(dot ? ".ocr_image" : "ocr_image", { image });
1568
+ },
1569
+ translateEn2zh(words) {
1570
+ return client.call("translate_en2zh", { words });
1571
+ },
1572
+ checkUrlSafely(url) {
1573
+ return client.call("check_url_safely", { url });
1574
+ },
1575
+ handleQuickOperation(context, operation) {
1576
+ return client.call(".handle_quick_operation", { context, operation });
1577
+ },
1578
+ getModelShow(model) {
1579
+ return client.call("_get_model_show", { model });
1580
+ },
1581
+ setModelShow(model, modelShow) {
1582
+ return client.call("_set_model_show", { model, model_show: modelShow });
1583
+ },
1584
+ getPacketStatus() {
1585
+ return client.call("nc_get_packet_status");
1586
+ }
1587
+ };
1588
+ }
1589
+
1590
+ // src/api/onebot/napcat.ts
1591
+ function createNapCatApi(client) {
1592
+ return {
1593
+ getRkeyEx() {
1594
+ return client.call("get_rkey");
1595
+ },
1596
+ getRkeyServer() {
1597
+ return client.call("get_rkey_server");
1598
+ },
1599
+ getRkey() {
1600
+ return client.call("nc_get_rkey");
1601
+ },
1602
+ setFriendRemark(userId, remark) {
1603
+ return client.call("set_friend_remark", { user_id: userId, remark });
1604
+ },
1605
+ deleteFriend(userId) {
1606
+ return client.call("delete_friend", { user_id: userId });
1607
+ },
1608
+ getUnidirectionalFriendList() {
1609
+ return client.call("get_unidirectional_friend_list");
1610
+ },
1611
+ setGroupRemark(groupId, remark) {
1612
+ return client.call("set_group_remark", { group_id: String(groupId), remark });
1613
+ },
1614
+ getGroupInfoEx(groupId) {
1615
+ return client.call("get_group_info_ex", { group_id: groupId });
1616
+ },
1617
+ getGroupDetailInfo(groupId) {
1618
+ return client.call("get_group_detail_info", { group_id: groupId });
1619
+ },
1620
+ getGroupIgnoredNotifies() {
1621
+ return client.call("get_group_ignored_notifies");
1622
+ },
1623
+ getGroupShutList(groupId) {
1624
+ return client.call("get_group_shut_list", { group_id: groupId });
1625
+ },
1626
+ sendPrivateForwardMessage(params) {
1627
+ return client.call("send_private_forward_msg", params);
1628
+ },
1629
+ forwardFriendSingleMsg(userId, messageId) {
1630
+ return client.call("forward_friend_single_msg", { user_id: userId, message_id: messageId });
1631
+ },
1632
+ forwardGroupSingleMsg(groupId, messageId) {
1633
+ return client.call("forward_group_single_msg", { group_id: groupId, message_id: messageId });
1634
+ },
1635
+ sendForwardMsg(params) {
1636
+ return client.call("send_forward_msg", params);
1637
+ },
1638
+ sendGroupNotice(params) {
1639
+ return client.call("_send_group_notice", params);
1640
+ },
1641
+ getGroupNotice(groupId) {
1642
+ return client.call("_get_group_notice", { group_id: groupId });
1643
+ },
1644
+ delGroupNotice(groupId, noticeId) {
1645
+ return client.call("_del_group_notice", { group_id: groupId, notice_id: +noticeId });
1646
+ },
1647
+ setOnlineStatus(status, extStatus, batteryStatus) {
1648
+ return client.call("set_online_status", { status, ext_status: extStatus, battery_status: batteryStatus });
1649
+ },
1650
+ setDiyOnlineStatus(faceId, wording = " ", faceType = 1) {
1651
+ return client.call("set_diy_online_status", { face_id: faceId, wording, face_type: faceType });
1652
+ },
1653
+ sendArkShare(params) {
1654
+ return client.call("send_ark_share", params);
1655
+ },
1656
+ sendGroupArkShare(groupId) {
1657
+ return client.call("send_group_ark_share", { group_id: groupId });
1658
+ },
1659
+ getMiniAppArk(payload) {
1660
+ return client.call("get_mini_app_ark", payload);
1661
+ },
1662
+ getAiCharacters(groupId, chatType = 1) {
1663
+ return client.call("get_ai_characters", { group_id: groupId, chat_type: chatType });
1664
+ },
1665
+ getAiRecord(groupId, character, text) {
1666
+ return client.call("get_ai_record", { group_id: groupId, character, text });
1667
+ },
1668
+ sendGroupAiRecord(groupId, character, text) {
1669
+ return client.call("send_group_ai_record", { group_id: groupId, character, text });
1670
+ },
1671
+ setGroupSign(groupId) {
1672
+ return client.call("set_group_sign", { group_id: groupId });
1673
+ },
1674
+ sendGroupSign(groupId) {
1675
+ return client.call("send_group_sign", { group_id: groupId });
1676
+ },
1677
+ fetchCustomFace(params) {
1678
+ return client.call("fetch_custom_face", params ?? {});
1679
+ },
1680
+ getClientkey() {
1681
+ return client.call("get_clientkey");
1682
+ },
1683
+ clickInlineKeyboardButton(params) {
1684
+ return client.call("click_inline_keyboard_button", {
1685
+ ...params,
1686
+ button_id: params.button_id ?? "",
1687
+ callback_data: params.callback_data ?? "",
1688
+ msg_seq: params.msg_seq ?? "10086"
1689
+ });
1690
+ }
1691
+ };
1692
+ }
1693
+
1694
+ // src/api/onebot/raw.ts
1695
+ var NAPCAT_ACTIONS = [
1696
+ ".get_word_slices",
1697
+ ".handle_quick_operation",
1698
+ ".ocr_image",
1699
+ "ArkShareGroup",
1700
+ "ArkSharePeer",
1701
+ "_del_group_notice",
1702
+ "_get_group_notice",
1703
+ "_get_model_show",
1704
+ "_mark_all_as_read",
1705
+ "_send_group_notice",
1706
+ "_set_model_show",
1707
+ "bot_exit",
1708
+ "can_send_image",
1709
+ "can_send_record",
1710
+ "check_url_safely",
1711
+ "clean_cache",
1712
+ "clean_stream_temp_file",
1713
+ "click_inline_keyboard_button",
1714
+ "create_collection",
1715
+ "create_group_file_folder",
1716
+ "del_group_album_media",
1717
+ "delete_essence_msg",
1718
+ "delete_friend",
1719
+ "delete_group_file",
1720
+ "delete_group_folder",
1721
+ "delete_msg",
1722
+ "delete_unidirectional_friend",
1723
+ "do_group_album_comment",
1724
+ "download_file",
1725
+ "download_file_image_stream",
1726
+ "download_file_record_stream",
1727
+ "download_file_stream",
1728
+ "fetch_custom_face",
1729
+ "fetch_emoji_like",
1730
+ "forward_friend_single_msg",
1731
+ "forward_group_single_msg",
1732
+ "friend_poke",
1733
+ "get_ai_characters",
1734
+ "get_ai_record",
1735
+ "get_clientkey",
1736
+ "get_collection_list",
1737
+ "get_cookies",
1738
+ "get_credentials",
1739
+ "get_csrf_token",
1740
+ "get_doubt_friends_add_request",
1741
+ "get_essence_msg_list",
1742
+ "get_file",
1743
+ "get_forward_msg",
1744
+ "get_friend_list",
1745
+ "get_friend_msg_history",
1746
+ "get_friends_with_category",
1747
+ "get_group_album_media_list",
1748
+ "get_group_at_all_remain",
1749
+ "get_group_detail_info",
1750
+ "get_group_file_system_info",
1751
+ "get_group_file_url",
1752
+ "get_group_files_by_folder",
1753
+ "get_group_honor_info",
1754
+ "get_group_ignore_add_request",
1755
+ "get_group_ignored_notifies",
1756
+ "get_group_info",
1757
+ "get_group_info_ex",
1758
+ "get_group_list",
1759
+ "get_group_member_info",
1760
+ "get_group_member_list",
1761
+ "get_group_msg_history",
1762
+ "get_group_root_files",
1763
+ "get_group_shut_list",
1764
+ "get_group_system_msg",
1765
+ "get_guild_list",
1766
+ "get_guild_service_profile",
1767
+ "get_image",
1768
+ "get_login_info",
1769
+ "get_mini_app_ark",
1770
+ "get_msg",
1771
+ "get_online_clients",
1772
+ "get_private_file_url",
1773
+ "get_profile_like",
1774
+ "get_qun_album_list",
1775
+ "get_recent_contact",
1776
+ "get_record",
1777
+ "get_rkey",
1778
+ "get_rkey_server",
1779
+ "get_robot_uin_range",
1780
+ "get_status",
1781
+ "get_stranger_info",
1782
+ "get_unidirectional_friend_list",
1783
+ "get_version_info",
1784
+ "group_poke",
1785
+ "mark_group_msg_as_read",
1786
+ "mark_msg_as_read",
1787
+ "mark_private_msg_as_read",
1788
+ "move_group_file",
1789
+ "nc_get_packet_status",
1790
+ "nc_get_rkey",
1791
+ "nc_get_user_status",
1792
+ "ocr_image",
1793
+ "qidian_get_account_info",
1794
+ "reboot_normal",
1795
+ "reload_event_filter",
1796
+ "rename_group_file",
1797
+ "send_ark_share",
1798
+ "send_forward_msg",
1799
+ "send_group_ai_record",
1800
+ "send_group_ark_share",
1801
+ "send_group_forward_msg",
1802
+ "send_group_msg",
1803
+ "send_group_sign",
1804
+ "send_like",
1805
+ "send_msg",
1806
+ "send_packet",
1807
+ "send_poke",
1808
+ "send_private_forward_msg",
1809
+ "send_private_msg",
1810
+ "set_diy_online_status",
1811
+ "set_doubt_friends_add_request",
1812
+ "set_essence_msg",
1813
+ "set_friend_add_request",
1814
+ "set_friend_remark",
1815
+ "set_group_add_option",
1816
+ "set_group_add_request",
1817
+ "set_group_admin",
1818
+ "set_group_album_media_like",
1819
+ "set_group_anonymous",
1820
+ "set_group_anonymous_ban",
1821
+ "set_group_ban",
1822
+ "set_group_card",
1823
+ "set_group_kick",
1824
+ "set_group_kick_members",
1825
+ "set_group_leave",
1826
+ "set_group_name",
1827
+ "set_group_portrait",
1828
+ "set_group_remark",
1829
+ "set_group_robot_add_option",
1830
+ "set_group_search",
1831
+ "set_group_sign",
1832
+ "set_group_special_title",
1833
+ "set_group_todo",
1834
+ "set_group_whole_ban",
1835
+ "set_input_status",
1836
+ "set_msg_emoji_like",
1837
+ "set_online_status",
1838
+ "set_qq_avatar",
1839
+ "set_qq_profile",
1840
+ "set_restart",
1841
+ "set_self_longnick",
1842
+ "test_auto_register_01",
1843
+ "test_auto_register_02",
1844
+ "test_download_stream",
1845
+ "trans_group_file",
1846
+ "translate_en2zh",
1847
+ "unknown",
1848
+ "upload_file_stream",
1849
+ "upload_group_file",
1850
+ "upload_image_to_qun_album",
1851
+ "upload_private_file"
1852
+ ];
1853
+ function createRawActionApi(client) {
1854
+ const entries = NAPCAT_ACTIONS.map((action) => [
1855
+ action,
1856
+ (params) => client.call(action, params ?? {})
1857
+ ]);
1858
+ return Object.fromEntries(entries);
1859
+ }
1860
+
1331
1861
  // src/api/onebot/index.ts
1332
1862
  var OneBotApi = class {
1333
1863
  messageApi;
@@ -1337,6 +1867,9 @@ var OneBotApi = class {
1337
1867
  fileApi;
1338
1868
  streamApi;
1339
1869
  requestApi;
1870
+ systemApi;
1871
+ napcatApi;
1872
+ raw;
1340
1873
  constructor(client, logger) {
1341
1874
  this.messageApi = createMessageApi(client);
1342
1875
  this.mediaApi = createMediaApi(client, logger);
@@ -1345,6 +1878,9 @@ var OneBotApi = class {
1345
1878
  this.fileApi = createFileApi(client);
1346
1879
  this.streamApi = createStreamApi(client);
1347
1880
  this.requestApi = createRequestApi(client);
1881
+ this.systemApi = createSystemApi(client);
1882
+ this.napcatApi = createNapCatApi(client);
1883
+ this.raw = createRawActionApi(client);
1348
1884
  Object.assign(
1349
1885
  this,
1350
1886
  this.messageApi,
@@ -1353,7 +1889,9 @@ var OneBotApi = class {
1353
1889
  this.groupApi,
1354
1890
  this.fileApi,
1355
1891
  this.streamApi,
1356
- this.requestApi
1892
+ this.requestApi,
1893
+ this.systemApi,
1894
+ this.napcatApi
1357
1895
  );
1358
1896
  }
1359
1897
  };
@@ -1371,6 +1909,9 @@ function bindOneBotApiMethods(api, target) {
1371
1909
  getForwardMessage: (id) => api.getForwardMessage(id),
1372
1910
  getEssenceMessageList: (groupId) => api.getEssenceMessageList(groupId),
1373
1911
  markMessageAsRead: (messageId) => api.markMessageAsRead(messageId),
1912
+ markGroupMsgAsRead: (groupId) => api.markGroupMsgAsRead(groupId),
1913
+ markPrivateMsgAsRead: (userId) => api.markPrivateMsgAsRead(userId),
1914
+ markAllMsgAsRead: () => api.markAllMsgAsRead(),
1374
1915
  getGroupAtAllRemain: (groupId) => api.getGroupAtAllRemain(groupId),
1375
1916
  getGroupSystemMsg: () => api.getGroupSystemMsg(),
1376
1917
  getGroupHonorInfo: (groupId, type) => api.getGroupHonorInfo(groupId, type),
@@ -1384,7 +1925,22 @@ function bindOneBotApiMethods(api, target) {
1384
1925
  downloadFile: (url, threadCount, headers) => api.downloadFile(url, threadCount, headers),
1385
1926
  uploadFileStream: (file, options) => api.uploadFileStream(file, options),
1386
1927
  getUploadStreamStatus: (streamId) => api.getUploadStreamStatus(streamId),
1928
+ downloadFileStream: (fileId, options) => api.downloadFileStream(fileId, options),
1929
+ downloadFileStreamToFile: (fileId, options) => api.downloadFileStreamToFile(fileId, options),
1930
+ downloadFileImageStream: (fileId, options) => api.downloadFileImageStream(fileId, options),
1931
+ downloadFileImageStreamToFile: (fileId, options) => api.downloadFileImageStreamToFile(fileId, options),
1932
+ downloadFileRecordStream: (fileId, outFormat, options) => api.downloadFileRecordStream(fileId, outFormat, options),
1933
+ downloadFileRecordStreamToFile: (fileId, outFormat, options) => api.downloadFileRecordStreamToFile(fileId, outFormat, options),
1934
+ cleanStreamTempFile: () => api.cleanStreamTempFile(),
1387
1935
  sendGroupForwardMessage: (groupId, messages) => api.sendGroupForwardMessage(groupId, messages),
1936
+ getGroupMsgHistory: (params) => api.getGroupMsgHistory(params),
1937
+ getFriendMsgHistory: (params) => api.getFriendMsgHistory(params),
1938
+ getRecentContact: (count) => api.getRecentContact(count),
1939
+ setMsgEmojiLike: (messageId, emojiId, set) => api.setMsgEmojiLike(messageId, emojiId, set),
1940
+ fetchEmojiLike: (params) => api.fetchEmojiLike(params),
1941
+ sendGroupPoke: (groupId, userId) => api.sendGroupPoke(groupId, userId),
1942
+ sendFriendPoke: (userId) => api.sendFriendPoke(userId),
1943
+ sendPoke: (targetId, groupId) => api.sendPoke(targetId, groupId),
1388
1944
  getImage: (file) => api.getImage(file),
1389
1945
  getRecord: (file, outFormat) => api.getRecord(file, outFormat),
1390
1946
  getFile: (file) => api.getFile(file),
@@ -1412,7 +1968,56 @@ function bindOneBotApiMethods(api, target) {
1412
1968
  getStrangerInfo: (userId, noCache = false) => api.getStrangerInfo(userId, noCache),
1413
1969
  getVersionInfo: () => api.getVersionInfo(),
1414
1970
  handleFriendRequest: (flag, approve = true, remark) => api.handleFriendRequest(flag, approve, remark),
1415
- handleGroupRequest: (flag, subType, approve = true, reason) => api.handleGroupRequest(flag, subType, approve, reason)
1971
+ handleGroupRequest: (flag, subType, approve = true, reason) => api.handleGroupRequest(flag, subType, approve, reason),
1972
+ // SystemApi
1973
+ getOnlineClients: (noCache = false) => api.getOnlineClients(noCache),
1974
+ getRobotUinRange: () => api.getRobotUinRange(),
1975
+ canSendImage: () => api.canSendImage(),
1976
+ canSendRecord: () => api.canSendRecord(),
1977
+ getCookies: (domain) => api.getCookies(domain),
1978
+ getCsrfToken: () => api.getCsrfToken(),
1979
+ getCredentials: (domain) => api.getCredentials(domain),
1980
+ setInputStatus: (userId, eventType) => api.setInputStatus(userId, eventType),
1981
+ ocrImage: (image, dot) => api.ocrImage(image, dot),
1982
+ translateEn2zh: (words) => api.translateEn2zh(words),
1983
+ checkUrlSafely: (url) => api.checkUrlSafely(url),
1984
+ handleQuickOperation: (context, operation) => api.handleQuickOperation(context, operation),
1985
+ getModelShow: (model) => api.getModelShow(model),
1986
+ setModelShow: (model, modelShow) => api.setModelShow(model, modelShow),
1987
+ getPacketStatus: () => api.getPacketStatus(),
1988
+ // NapCatApi
1989
+ getRkeyEx: () => api.getRkeyEx(),
1990
+ getRkeyServer: () => api.getRkeyServer(),
1991
+ getRkey: () => api.getRkey(),
1992
+ setFriendRemark: (userId, remark) => api.setFriendRemark(userId, remark),
1993
+ deleteFriend: (userId) => api.deleteFriend(userId),
1994
+ getUnidirectionalFriendList: () => api.getUnidirectionalFriendList(),
1995
+ setGroupRemark: (groupId, remark) => api.setGroupRemark(groupId, remark),
1996
+ getGroupInfoEx: (groupId) => api.getGroupInfoEx(groupId),
1997
+ getGroupDetailInfo: (groupId) => api.getGroupDetailInfo(groupId),
1998
+ getGroupIgnoredNotifies: () => api.getGroupIgnoredNotifies(),
1999
+ getGroupShutList: (groupId) => api.getGroupShutList(groupId),
2000
+ sendPrivateForwardMessage: (params) => api.sendPrivateForwardMessage(params),
2001
+ forwardFriendSingleMsg: (userId, messageId) => api.forwardFriendSingleMsg(userId, messageId),
2002
+ forwardGroupSingleMsg: (groupId, messageId) => api.forwardGroupSingleMsg(groupId, messageId),
2003
+ sendForwardMsg: (params) => api.sendForwardMsg(params),
2004
+ sendGroupNotice: (params) => api.sendGroupNotice(params),
2005
+ getGroupNotice: (groupId) => api.getGroupNotice(groupId),
2006
+ delGroupNotice: (groupId, noticeId) => api.delGroupNotice(groupId, noticeId),
2007
+ setOnlineStatus: (status, extStatus, batteryStatus) => api.setOnlineStatus(status, extStatus, batteryStatus),
2008
+ setDiyOnlineStatus: (faceId, wording, faceType) => api.setDiyOnlineStatus(faceId, wording, faceType),
2009
+ sendArkShare: (params) => api.sendArkShare(params),
2010
+ sendGroupArkShare: (groupId) => api.sendGroupArkShare(groupId),
2011
+ getMiniAppArk: (payload) => api.getMiniAppArk(payload),
2012
+ getAiCharacters: (groupId, chatType) => api.getAiCharacters(groupId, chatType),
2013
+ getAiRecord: (groupId, character, text) => api.getAiRecord(groupId, character, text),
2014
+ sendGroupAiRecord: (groupId, character, text) => api.sendGroupAiRecord(groupId, character, text),
2015
+ setGroupSign: (groupId) => api.setGroupSign(groupId),
2016
+ sendGroupSign: (groupId) => api.sendGroupSign(groupId),
2017
+ fetchCustomFace: (params) => api.fetchCustomFace(params),
2018
+ getClientkey: () => api.getClientkey(),
2019
+ clickInlineKeyboardButton: (params) => api.clickInlineKeyboardButton(params),
2020
+ raw: api.raw
1416
2021
  };
1417
2022
  Object.assign(target, bindings);
1418
2023
  }