@napuketto/adapter 0.21.0 → 0.22.0
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/{essence-Cn1oRaLw.mjs → essence-ChxJJipr.mjs} +1 -1
- package/dist/{index-DsGLfZOl.d.mts → index-Beq1S5ad.d.mts} +13 -1
- package/dist/{index-Cwq1NPKE.d.mts → index-CWUA38Aw.d.mts} +2 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +4 -4
- package/dist/kurobot/index.mjs +1 -1
- package/dist/{kurobot-8YrYipGI.mjs → kurobot-BrKT5cJA.mjs} +1 -1
- package/dist/milky/index.d.mts +1 -1
- package/dist/milky/index.mjs +1 -1
- package/dist/{milky-v3TqHlCp.mjs → milky-CI0qDQpV.mjs} +33 -31
- package/dist/onebot11/index.d.mts +1 -1
- package/dist/onebot11/index.mjs +1 -1
- package/dist/{onebot11-CZUzbgSG.mjs → onebot11-CaSEVtLy.mjs} +92 -98
- package/dist/{raw-message-DU8YOhLV.mjs → raw-message-B0kwCfKE.mjs} +1 -1
- package/dist/satori/index.mjs +1 -1
- package/dist/{satori-Cna8fauQ.mjs → satori-B-vWj1fa.mjs} +73 -37
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as ErrorCodeMap, m as ActionRegistry, s as BaseProtocolAdapter, t as ConfigBase$1 } from "./index-BO1TgLTT.mjs";
|
|
2
2
|
import { n as AdapterLoggerLike, t as MediaCache } from "./media-cache-BaTQ_l_b.mjs";
|
|
3
3
|
import "./gray-tip-CcpfI1Og.mjs";
|
|
4
|
-
import { BuddyCacheEventChannel, BuddyEventChannel, CanonicalElement, FlashTransferApi, FriendApi, GroupApi, GroupCache, GroupEventChannel, GroupNotifyApi, MsgApi, MsgEventChannel, Peer, ProfileApi, ProfileLikeApi, RichMediaApi, TicketApi, WebApi } from "@napuketto/kernel";
|
|
4
|
+
import { BuddyCacheEventChannel, BuddyEventChannel, CanonicalElement, FlashTransferApi, FriendApi, GroupApi, GroupCache, GroupEventChannel, GroupNotifyApi, GroupRequestKind, MsgApi, MsgEventChannel, Peer, ProfileApi, ProfileLikeApi, RichMediaApi, TicketApi, WebApi } from "@napuketto/kernel";
|
|
5
5
|
import { EventBroadcaster, TransportAdapter } from "@napuketto/network";
|
|
6
6
|
import { ZodType, z } from "zod";
|
|
7
7
|
import { MediaOutboundPolicy } from "@napuketto/media";
|
|
@@ -120,6 +120,8 @@ interface OB11MessageInfo {
|
|
|
120
120
|
raw_message: string;
|
|
121
121
|
group_id?: number;
|
|
122
122
|
user_id?: number;
|
|
123
|
+
/** 群临时会话的来源群号,0 表示未知。 */
|
|
124
|
+
temp_source?: number;
|
|
123
125
|
}
|
|
124
126
|
/** 性别枚举。 */
|
|
125
127
|
type Sex = "male" | "female" | "unknown";
|
|
@@ -651,6 +653,8 @@ interface OB11GroupRecallNoticeEvent extends OB11BaseEvent {
|
|
|
651
653
|
user_id: number;
|
|
652
654
|
operator_id: number;
|
|
653
655
|
message_id: number;
|
|
656
|
+
tip_message_id?: string;
|
|
657
|
+
tip_message_seq?: string;
|
|
654
658
|
}
|
|
655
659
|
/** 好友消息撤回。 */
|
|
656
660
|
interface OB11FriendRecallNoticeEvent extends OB11BaseEvent {
|
|
@@ -658,6 +662,8 @@ interface OB11FriendRecallNoticeEvent extends OB11BaseEvent {
|
|
|
658
662
|
notice_type: "friend_recall";
|
|
659
663
|
user_id: number;
|
|
660
664
|
message_id: number;
|
|
665
|
+
tip_message_id?: string;
|
|
666
|
+
tip_message_seq?: string;
|
|
661
667
|
}
|
|
662
668
|
/** 群成员名片变更(go-cqhttp 扩展)。 */
|
|
663
669
|
interface OB11GroupCardNoticeEvent extends OB11BaseEvent {
|
|
@@ -690,6 +696,8 @@ interface OB11NotifyNoticeEvent extends OB11BaseEvent {
|
|
|
690
696
|
group_id: number;
|
|
691
697
|
user_id: number;
|
|
692
698
|
target_id: number;
|
|
699
|
+
/** 群临时会话戳一戳的来源群号(原生字段存在时)。 */
|
|
700
|
+
temp_source?: number;
|
|
693
701
|
/** honor 子类型时的荣誉类型(talkative 龙王 / performer 群聊之火 / emotion 快乐源泉)。 */
|
|
694
702
|
honor_type?: "talkative" | "performer" | "emotion";
|
|
695
703
|
}
|
|
@@ -746,6 +754,10 @@ interface OB11GroupRequestEvent extends OB11BaseEvent {
|
|
|
746
754
|
user_id: number;
|
|
747
755
|
comment: string;
|
|
748
756
|
flag: string;
|
|
757
|
+
/** 通知队列。审批时随 flag 一并回传。 */
|
|
758
|
+
doubt: boolean;
|
|
759
|
+
/** 区分邀请本账号、邀请他人待审批与入群申请。 */
|
|
760
|
+
request_kind: GroupRequestKind;
|
|
749
761
|
}
|
|
750
762
|
/** OB11 请求事件联合。 */
|
|
751
763
|
type OB11RequestEvent = OB11FriendRequestEvent | OB11GroupRequestEvent;
|
|
@@ -645,6 +645,7 @@ interface GroupJoinRequestData {
|
|
|
645
645
|
interface GroupInvitedJoinRequestData {
|
|
646
646
|
group_id: number;
|
|
647
647
|
notification_seq: number;
|
|
648
|
+
is_filtered: boolean;
|
|
648
649
|
initiator_id: number;
|
|
649
650
|
target_user_id: number;
|
|
650
651
|
}
|
|
@@ -652,6 +653,7 @@ interface GroupInvitedJoinRequestData {
|
|
|
652
653
|
interface GroupInvitationData {
|
|
653
654
|
group_id: number;
|
|
654
655
|
invitation_seq: number;
|
|
656
|
+
is_filtered: boolean;
|
|
655
657
|
initiator_id: number;
|
|
656
658
|
source_group_id: number | null;
|
|
657
659
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { _ as ErrorCodeMap, a as ProtocolConfig, c as ProtocolHooks, g as ActionOutcome, h as ActionKernelSpec, i as ConfigSchema, m as ActionRegistry, n as ConfigFormat, o as createServerSchema, r as ConfigOptions, s as BaseProtocolAdapter, t as ConfigBase, v as runAction } from "./index-BO1TgLTT.mjs";
|
|
19
19
|
import { et as KurobotConfig, l as KurobotAdapterOptions, nt as kurobotConfigSchema, u as NapukettoKurobotAdapter } from "./index-tW3a05Du.mjs";
|
|
20
|
-
import { G as MilkyConfig, K as milkyConfigSchema, L as MilkyAdapterOptions, R as NapukettoMilkyAdapter } from "./index-
|
|
21
|
-
import { C as ob11ConfigSchema, S as OB11Config, o as NapukettoOneBot11Adapter, s as OneBot11AdapterOptions } from "./index-
|
|
20
|
+
import { G as MilkyConfig, K as milkyConfigSchema, L as MilkyAdapterOptions, R as NapukettoMilkyAdapter } from "./index-CWUA38Aw.mjs";
|
|
21
|
+
import { C as ob11ConfigSchema, S as OB11Config, o as NapukettoOneBot11Adapter, s as OneBot11AdapterOptions } from "./index-Beq1S5ad.mjs";
|
|
22
22
|
import { R as SatoriConfig, d as NapukettoSatoriAdapter, f as SatoriAdapterOptions, z as satoriConfigSchema } from "./index-DAoLsewN.mjs";
|
|
23
23
|
import { z } from "zod";
|
|
24
24
|
declare const protocolMediaSchema: z.ZodObject<{
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { f as ActionRegistry, n as ProtocolConfig, o as BaseProtocolAdapter, p as runAction, r as createServerSchema, t as ConfigBase } from "./framework-CA3087JP.mjs";
|
|
2
|
-
import { N as kurobotConfigSchema, t as NapukettoKurobotAdapter } from "./kurobot-
|
|
3
|
-
import { r as milkyConfigSchema, t as NapukettoMilkyAdapter } from "./milky-
|
|
4
|
-
import { t as NapukettoOneBot11Adapter, u as ob11ConfigSchema } from "./onebot11-
|
|
5
|
-
import { m as satoriConfigSchema, t as NapukettoSatoriAdapter } from "./satori-
|
|
2
|
+
import { N as kurobotConfigSchema, t as NapukettoKurobotAdapter } from "./kurobot-BrKT5cJA.mjs";
|
|
3
|
+
import { r as milkyConfigSchema, t as NapukettoMilkyAdapter } from "./milky-CI0qDQpV.mjs";
|
|
4
|
+
import { t as NapukettoOneBot11Adapter, u as ob11ConfigSchema } from "./onebot11-CaSEVtLy.mjs";
|
|
5
|
+
import { m as satoriConfigSchema, t as NapukettoSatoriAdapter } from "./satori-B-vWj1fa.mjs";
|
|
6
6
|
export { ActionRegistry, BaseProtocolAdapter, ConfigBase, NapukettoKurobotAdapter, NapukettoMilkyAdapter, NapukettoOneBot11Adapter, NapukettoSatoriAdapter, ProtocolConfig, createServerSchema, kurobotConfigSchema, milkyConfigSchema, ob11ConfigSchema, runAction, satoriConfigSchema };
|
package/dist/kurobot/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { u as KurobotConnection, n as MAX_GROUP_TEXT_LENGTH, t as NapukettoKurobotAdapter, d as PROTOCOL_NAME, f as PROTOCOL_VERSION, p as WS_SUBPROTOCOL, m as bindingsUpdatedFrame, h as commandFrame, g as commandResultFrame, _ as deathFrame, r as degradeElements, i as degradeMessage, v as encodeFrame, y as gameChatFrame, b as helloAckFrame, x as helloFrame, S as isProtocolVersionCompatible, C as joinFrame, M as kurobotConfigDefaults, N as kurobotConfigSchema, w as leaveFrame, T as pingFrame, E as platformChatFrame, D as pongFrame, O as queryFrame, k as queryResultFrame, a as renderCommandResult, o as renderDeathText, s as renderTemplate, c as resolveSenderName, A as statusFrame, l as truncateForGroup, j as wireFrameSchema } from "../kurobot-
|
|
1
|
+
export { u as KurobotConnection, n as MAX_GROUP_TEXT_LENGTH, t as NapukettoKurobotAdapter, d as PROTOCOL_NAME, f as PROTOCOL_VERSION, p as WS_SUBPROTOCOL, m as bindingsUpdatedFrame, h as commandFrame, g as commandResultFrame, _ as deathFrame, r as degradeElements, i as degradeMessage, v as encodeFrame, y as gameChatFrame, b as helloAckFrame, x as helloFrame, S as isProtocolVersionCompatible, C as joinFrame, M as kurobotConfigDefaults, N as kurobotConfigSchema, w as leaveFrame, T as pingFrame, E as platformChatFrame, D as pongFrame, O as queryFrame, k as queryResultFrame, a as renderCommandResult, o as renderDeathText, s as renderTemplate, c as resolveSenderName, A as statusFrame, l as truncateForGroup, j as wireFrameSchema } from "../kurobot-BrKT5cJA.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as BaseProtocolAdapter, s as resolveProtocolConfig } from "./framework-CA3087JP.mjs";
|
|
2
|
-
import { r as subscribeRawMessages } from "./raw-message-
|
|
2
|
+
import { r as subscribeRawMessages } from "./raw-message-B0kwCfKE.mjs";
|
|
3
3
|
import { ChatType, errorMessage, getOwnProp, isRecord, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { z } from "zod";
|
package/dist/milky/index.d.mts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* 对齐 ./onebot11 与 ./satori 的导出口径。装配方(loader assemble-protocols)
|
|
6
6
|
* 动态 import 本入口。
|
|
7
7
|
*/
|
|
8
|
-
import { A as MessageRecallData, B as MilkyApi, C as GroupMuteData, D as IncomingForwardedMessage, E as GroupWholeMuteData, F as PeerPinChangeData, G as MilkyConfig, H as MilkyLoggerLike, I as SendMessageOutput, J as milkyErrorCodeMap, K as milkyConfigSchema, L as MilkyAdapterOptions, M as MilkyEvent, N as OutgoingForwardedMessage, O as IncomingMessage, P as OutgoingSegment, R as NapukettoMilkyAdapter, S as GroupMessageReactionData, T as GroupNotificationEntity, U as MilkyTransportSet, V as MilkyApiOptions, W as assembleMilkyTransports, _ as GroupInvitedJoinRequestData, a as FriendRequestEntity, b as GroupMemberEntity, c as GetLoginInfoOutput, d as GroupEntity, f as GroupEssenceMessage, g as GroupInvitationData, h as GroupFolderEntity, i as FriendRequestData, j as MessageScene, k as IncomingSegment, l as GroupAnnouncementEntity, m as GroupFileUploadData, n as FriendCategoryEntity, o as GetCookiesOutput, p as GroupFileEntity, q as MilkyAction, r as FriendEntity, s as GetImplInfoOutput, t as BotOfflineData, u as GroupDisbandData, v as GroupJoinRequestData, w as GroupNameChangeData, x as GroupMemberIncreaseData, y as GroupMemberDecreaseData, z as createMilkyActionRegistry } from "../index-
|
|
8
|
+
import { A as MessageRecallData, B as MilkyApi, C as GroupMuteData, D as IncomingForwardedMessage, E as GroupWholeMuteData, F as PeerPinChangeData, G as MilkyConfig, H as MilkyLoggerLike, I as SendMessageOutput, J as milkyErrorCodeMap, K as milkyConfigSchema, L as MilkyAdapterOptions, M as MilkyEvent, N as OutgoingForwardedMessage, O as IncomingMessage, P as OutgoingSegment, R as NapukettoMilkyAdapter, S as GroupMessageReactionData, T as GroupNotificationEntity, U as MilkyTransportSet, V as MilkyApiOptions, W as assembleMilkyTransports, _ as GroupInvitedJoinRequestData, a as FriendRequestEntity, b as GroupMemberEntity, c as GetLoginInfoOutput, d as GroupEntity, f as GroupEssenceMessage, g as GroupInvitationData, h as GroupFolderEntity, i as FriendRequestData, j as MessageScene, k as IncomingSegment, l as GroupAnnouncementEntity, m as GroupFileUploadData, n as FriendCategoryEntity, o as GetCookiesOutput, p as GroupFileEntity, q as MilkyAction, r as FriendEntity, s as GetImplInfoOutput, t as BotOfflineData, u as GroupDisbandData, v as GroupJoinRequestData, w as GroupNameChangeData, x as GroupMemberIncreaseData, y as GroupMemberDecreaseData, z as createMilkyActionRegistry } from "../index-CWUA38Aw.mjs";
|
|
9
9
|
export { type BotOfflineData, type FriendCategoryEntity, type FriendEntity, type FriendRequestData, type FriendRequestEntity, type GetCookiesOutput, type GetImplInfoOutput, type GetLoginInfoOutput, type GroupAnnouncementEntity, type GroupDisbandData, type GroupEntity, type GroupEssenceMessage, type GroupFileEntity, type GroupFileUploadData, type GroupFolderEntity, type GroupInvitationData, type GroupInvitedJoinRequestData, type GroupJoinRequestData, type GroupMemberDecreaseData, type GroupMemberEntity, type GroupMemberIncreaseData, type GroupMessageReactionData, type GroupMuteData, type GroupNameChangeData, type GroupNotificationEntity, type GroupWholeMuteData, type IncomingForwardedMessage, type MessageRecallData, type MessageScene, type MilkyAction, type MilkyAdapterOptions, MilkyApi, type MilkyApiOptions, type MilkyConfig, type MilkyEvent, type IncomingMessage as MilkyIncomingMessage, type IncomingSegment as MilkyIncomingSegment, type MilkyLoggerLike, type OutgoingSegment as MilkyOutgoingSegment, type MilkyTransportSet, NapukettoMilkyAdapter, type OutgoingForwardedMessage, type PeerPinChangeData, type SendMessageOutput, assembleMilkyTransports, createMilkyActionRegistry, milkyConfigSchema, milkyErrorCodeMap };
|
package/dist/milky/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { a as MilkyApi, t as NapukettoMilkyAdapter, n as assembleMilkyTransports, i as createMilkyActionRegistry, r as milkyConfigSchema, o as milkyErrorCodeMap } from "../milky-
|
|
1
|
+
export { a as MilkyApi, t as NapukettoMilkyAdapter, n as assembleMilkyTransports, i as createMilkyActionRegistry, r as milkyConfigSchema, o as milkyErrorCodeMap } from "../milky-CI0qDQpV.mjs";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { c as BEARER_PREFIX, f as ActionRegistry, i as validateListenerToken, l as createTokenAuthorize, o as BaseProtocolAdapter, p as runAction, s as resolveProtocolConfig } from "./framework-CA3087JP.mjs";
|
|
2
2
|
import { _ as cacheMediaFile, a as logEventFailure, c as protocolMediaSchema, d as mediaDownloader, g as MediaCache, h as resolveLocalMedia, i as hasGrayTip, n as findRevokeElement, o as sliceRaw, p as bindLocalMediaRoots, r as firstUntranslatedGrayTip, t as collectGrayTipUids, y as withMediaScope } from "./gray-tip-D0SfHr7q.mjs";
|
|
3
|
-
import { a as firstNonEmptyString, c as MS_TO_SEC, d as numericUin, f as resolveUidToUinWithFallback, i as toUnixSeconds, l as NUMERIC_RE, m as toUin, o as stringOrUndefined, p as resolveUin, r as subscribeRawMessages, s as startupBaselineSec, t as forEachRawMessage } from "./raw-message-
|
|
4
|
-
import { a as processSysMsgBlob, c as varintAt, d as processInboundBuddyReqs, i as nodeAt, l as varintOf, n as OBSERVED_UNNAMED_SYSMSG_KEYS, o as recognizeSysMsg, r as narrowSysMsgBlobs, s as textOf, t as extractEssenceSetSysMsg, u as BuddyReqDedup } from "./essence-
|
|
5
|
-
import { ChatType, EssenceListSync, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, errorMessage, hasNumberProp, hasStringProp, isRecord, kernelError, narrowEssenceGroupArg, toCanonicalElements } from "@napuketto/kernel";
|
|
3
|
+
import { a as firstNonEmptyString, c as MS_TO_SEC, d as numericUin, f as resolveUidToUinWithFallback, i as toUnixSeconds, l as NUMERIC_RE, m as toUin, o as stringOrUndefined, p as resolveUin, r as subscribeRawMessages, s as startupBaselineSec, t as forEachRawMessage } from "./raw-message-B0kwCfKE.mjs";
|
|
4
|
+
import { a as processSysMsgBlob, c as varintAt, d as processInboundBuddyReqs, i as nodeAt, l as varintOf, n as OBSERVED_UNNAMED_SYSMSG_KEYS, o as recognizeSysMsg, r as narrowSysMsgBlobs, s as textOf, t as extractEssenceSetSysMsg, u as BuddyReqDedup } from "./essence-ChxJJipr.mjs";
|
|
5
|
+
import { ChatType, EssenceListSync, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, errorMessage, findPendingGroupRequest, hasNumberProp, hasStringProp, isRecord, kernelError, narrowEssenceGroupArg, toCanonicalElements } from "@napuketto/kernel";
|
|
6
6
|
import { HttpClient, HttpServer, createSseResponse, sendWsText } from "@napuketto/network";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { rename, writeFile } from "node:fs/promises";
|
|
@@ -670,20 +670,6 @@ function requireSelfUid(api) {
|
|
|
670
670
|
if (uid === void 0 || uid === "") throw kernelError("登录身份缺 uid(无法发起戳一戳)", "INVALID_PARAM");
|
|
671
671
|
return uid;
|
|
672
672
|
}
|
|
673
|
-
/**
|
|
674
|
-
* 按通知 seq 查找群通知(先非可疑后可疑两屏依序,OB11 set_group_add_request
|
|
675
|
-
* 同路径)。屏序惰性拉取:前一屏命中则不拉后续屏(群通知规范序)。
|
|
676
|
-
* 未找到抛 NOT_FOUND(应答动作的 seq 无效或已过期)。
|
|
677
|
-
* 模块级函数(非类成员):应答动作的公共入口,OB11 同路径。
|
|
678
|
-
*/
|
|
679
|
-
async function findGroupNotify(api, seq) {
|
|
680
|
-
const screens = [() => api.groupNotifyApi.getSingleScreenNotifies(false, 100), () => api.groupNotifyApi.getSingleScreenNotifies(true, 100)];
|
|
681
|
-
for (const fetchScreen of screens) {
|
|
682
|
-
const hit = (await fetchScreen()).find((item) => item.seq === seq);
|
|
683
|
-
if (hit !== void 0) return hit;
|
|
684
|
-
}
|
|
685
|
-
throw kernelError(`未找到通知 ${seq}(无效或已过期)`, "NOT_FOUND");
|
|
686
|
-
}
|
|
687
673
|
/** 按发起者 uid 查找好友申请(getBuddyReqList 匹配 friendUid);未找到抛 NOT_FOUND。 */
|
|
688
674
|
async function findBuddyReq(api, initiatorUid) {
|
|
689
675
|
const hit = (await api.friendApi.getBuddyReqList()).find((req) => req.friendUid === initiatorUid);
|
|
@@ -760,7 +746,7 @@ function createGroupManageActions(api) {
|
|
|
760
746
|
schema: z.object({
|
|
761
747
|
...groupIdField,
|
|
762
748
|
...userIdField,
|
|
763
|
-
duration: z.
|
|
749
|
+
duration: z.int32().nonnegative().nullable().optional()
|
|
764
750
|
}),
|
|
765
751
|
handle: async (payload) => {
|
|
766
752
|
const uid = await api.resolveUidFromUin(payload.user_id);
|
|
@@ -902,6 +888,7 @@ function toGroupRequestEvent(notify, doubt, ctx) {
|
|
|
902
888
|
data: {
|
|
903
889
|
group_id: groupId,
|
|
904
890
|
notification_seq: seq,
|
|
891
|
+
is_filtered: doubt,
|
|
905
892
|
initiator_id: toUin(notify.user1?.uid, ctx),
|
|
906
893
|
target_user_id: toUin(notify.user2?.uid, ctx)
|
|
907
894
|
}
|
|
@@ -913,6 +900,7 @@ function toGroupRequestEvent(notify, doubt, ctx) {
|
|
|
913
900
|
data: {
|
|
914
901
|
group_id: groupId,
|
|
915
902
|
invitation_seq: seq,
|
|
903
|
+
is_filtered: doubt,
|
|
916
904
|
initiator_id: toUin(notify.user1?.uid, ctx),
|
|
917
905
|
source_group_id: null
|
|
918
906
|
}
|
|
@@ -931,6 +919,14 @@ function collectNotifyUids(notifies) {
|
|
|
931
919
|
return [...uids];
|
|
932
920
|
}
|
|
933
921
|
// src/milky/action/group-notice.ts
|
|
922
|
+
/**
|
|
923
|
+
* Milky 群通知域动作:get_group_notifications / accept_group_request /
|
|
924
|
+
* reject_group_request / accept_group_invitation / reject_group_invitation。
|
|
925
|
+
* - 通知列表:kernel getSingleScreenNotifies 为单屏快照(无翻页)——
|
|
926
|
+
* start_notification_seq 作客户端过滤;实体类型 7=入群申请 / 5=成员邀请他人 /
|
|
927
|
+
* 8,12,13=管理员变更 / 9,10=踢出 / 11=退群(1=邀请自身无实体变体,不产出)。
|
|
928
|
+
* - 应答:在指定队列匹配群号、序号与请求类型,再携带队列审批。
|
|
929
|
+
*/
|
|
934
930
|
/** get_group_notifications 默认 limit(规范 default 20)。 */
|
|
935
931
|
const NOTIFICATIONS_DEFAULT_LIMIT = 20;
|
|
936
932
|
/** 群通知域动作工厂(通知列表 + 应答四动作)。 */
|
|
@@ -961,33 +957,33 @@ function createGroupNoticeActions(api) {
|
|
|
961
957
|
defineMilkyAction({
|
|
962
958
|
name: "accept_group_request",
|
|
963
959
|
schema: respondRequestSchema,
|
|
964
|
-
handle:
|
|
960
|
+
handle: (payload) => respondGroupNotify(api, payload.notification_seq, payload.group_id, payload.notification_type, payload.is_filtered, true)
|
|
965
961
|
}),
|
|
966
962
|
defineMilkyAction({
|
|
967
963
|
name: "reject_group_request",
|
|
968
964
|
schema: rejectRequestSchema,
|
|
969
|
-
handle:
|
|
965
|
+
handle: (payload) => respondGroupNotify(api, payload.notification_seq, payload.group_id, payload.notification_type, payload.is_filtered, false, payload.reason ?? "")
|
|
970
966
|
}),
|
|
971
967
|
defineMilkyAction({
|
|
972
968
|
name: "accept_group_invitation",
|
|
973
969
|
schema: invitationSchema,
|
|
974
|
-
handle:
|
|
970
|
+
handle: (payload) => respondGroupNotify(api, payload.invitation_seq, payload.group_id, "invitation", payload.is_filtered, true)
|
|
975
971
|
}),
|
|
976
972
|
defineMilkyAction({
|
|
977
973
|
name: "reject_group_invitation",
|
|
978
974
|
schema: invitationSchema,
|
|
979
|
-
handle:
|
|
975
|
+
handle: (payload) => respondGroupNotify(api, payload.invitation_seq, payload.group_id, "invitation", payload.is_filtered, false)
|
|
980
976
|
})
|
|
981
977
|
];
|
|
982
978
|
}
|
|
983
|
-
/** accept_group_request
|
|
979
|
+
/** accept_group_request 入参。 */
|
|
984
980
|
const respondRequestSchema = z.object({
|
|
985
981
|
notification_seq: z.number().int().min(0),
|
|
986
982
|
notification_type: z.enum(["join_request", "invited_join_request"]),
|
|
987
983
|
...groupIdField,
|
|
988
984
|
is_filtered: optBool
|
|
989
985
|
});
|
|
990
|
-
/** reject_group_request
|
|
986
|
+
/** reject_group_request 入参。 */
|
|
991
987
|
const rejectRequestSchema = z.object({
|
|
992
988
|
notification_seq: z.number().int().min(0),
|
|
993
989
|
notification_type: z.enum(["join_request", "invited_join_request"]),
|
|
@@ -998,12 +994,18 @@ const rejectRequestSchema = z.object({
|
|
|
998
994
|
/** accept/reject_group_invitation 入参。 */
|
|
999
995
|
const invitationSchema = z.object({
|
|
1000
996
|
...groupIdField,
|
|
1001
|
-
invitation_seq: z.number().int().min(0)
|
|
997
|
+
invitation_seq: z.number().int().min(0),
|
|
998
|
+
is_filtered: optBool
|
|
1002
999
|
});
|
|
1003
1000
|
/** 应答公共路径:seq → 通知匹配 → handleGroupRequest。 */
|
|
1004
|
-
async function respondGroupNotify(api, seq, doubt, approve) {
|
|
1005
|
-
const notify = await
|
|
1006
|
-
|
|
1001
|
+
async function respondGroupNotify(api, seq, groupId, kind, doubt, approve, reason = "") {
|
|
1002
|
+
const { request, notify } = await findPendingGroupRequest(api.groupNotifyApi, {
|
|
1003
|
+
seq: String(seq),
|
|
1004
|
+
groupCode: String(groupId),
|
|
1005
|
+
kind,
|
|
1006
|
+
doubt: doubt ?? void 0
|
|
1007
|
+
}, 100);
|
|
1008
|
+
await api.groupNotifyApi.handleGroupRequest(request.doubt, notify, approve ? NTGroupRequestOperateTypes.KAGREE : NTGroupRequestOperateTypes.KREFUSE, reason || " ");
|
|
1007
1009
|
return {};
|
|
1008
1010
|
}
|
|
1009
1011
|
/** 通知 user1/user2 uid → uin 批量转换(失败退空 Map,实体 id 兜底 0)。 */
|
|
@@ -1958,7 +1960,7 @@ function createProfileActions(api) {
|
|
|
1958
1960
|
const uin = String(payload.user_id);
|
|
1959
1961
|
const friend = (await api.friendApi.getFriendList()).find((f) => f.uin === uin);
|
|
1960
1962
|
if (friend === void 0) throw kernelError(`好友 ${uin} 不存在`, "NOT_FOUND");
|
|
1961
|
-
return { friend: toFriendEntity(friend,
|
|
1963
|
+
return { friend: toFriendEntity(friend, uin, friend.nickname) };
|
|
1962
1964
|
}
|
|
1963
1965
|
}),
|
|
1964
1966
|
defineMilkyAction({
|
|
@@ -2012,7 +2014,7 @@ function createSocialActions(api) {
|
|
|
2012
2014
|
name: "get_friend_list",
|
|
2013
2015
|
schema: z.object({}).strict(),
|
|
2014
2016
|
handle: async () => {
|
|
2015
|
-
return { friends: (await api.friendApi.getFriendList()).
|
|
2017
|
+
return { friends: (await api.friendApi.getFriendList()).flatMap((f) => f.uin === null ? [] : [toFriendEntity(f, f.uin, f.nickname)]) };
|
|
2016
2018
|
}
|
|
2017
2019
|
}),
|
|
2018
2020
|
defineMilkyAction({
|
|
@@ -2157,7 +2159,7 @@ async function pinnedFriendEntities(api, uids) {
|
|
|
2157
2159
|
const byUid = new Map(all.map((f) => [f.uid, f]));
|
|
2158
2160
|
return uids.flatMap((uid) => {
|
|
2159
2161
|
const f = byUid.get(uid);
|
|
2160
|
-
return f
|
|
2162
|
+
return f?.uin != null ? [toFriendEntity(f, f.uin, f.nickname)] : [];
|
|
2161
2163
|
});
|
|
2162
2164
|
}
|
|
2163
2165
|
/** 置顶群实体(groupCode 匹配群列表,缓存优先;未命中跳过)。 */
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* OneBot 11 协议适配器(当前主战场)
|
|
3
3
|
* 公共面:类型 + 动作注册表 + 配置 schema + 翻译层(adapter.ts 于 打通 kernel 事件后接入)。
|
|
4
4
|
*/
|
|
5
|
-
import { $ as OB11MessageInfo, A as serializeCqParts, B as canonicalToCqMessage, C as ob11ConfigSchema, D as escapeCqParam, E as encodeCqCode, F as ob11ErrorCodeMap, G as CurrentTalkative, H as cqMessageToCanonical, I as OneBotApi, J as GroupInfo, K as FriendInfo, L as OneBotApiOptions, M as Ob11ActionDeps, N as createOb11ActionRegistry, O as escapeCqText, P as AtAllRemainInfo, Q as OB11Message, R as OneBotSystemOptions, S as OB11Config, T as CqCode, U as cqMessageToSegments, V as canonicalToSegments, W as segmentsToCanonical, X as HonorMember, Y as GroupMemberInfo, Z as LoginInfo, _ as OB11GroupMessageEvent, a as assembleOb11Transports, at as VersionInfo, b as OB11BaseEvent, c as OB11Event, d as OB11RequestEvent, et as OB11MessageSegment, f as OB11NoticeEvent, g as OB11Status, h as OB11MetaEvent, i as Ob11TransportSet, it as StrangerInfo, j as unescapeCqText, k as parseCqMessage, l as OB11FriendRequestEvent, m as OB11LifecycleMetaEvent, n as Ob11OutboundTransport, nt as Sender, o as NapukettoOneBot11Adapter, p as OB11HeartbeatMetaEvent, q as GroupHonorInfo, r as Ob11OutboundWsReconnect, rt as Sex, s as OneBot11AdapterOptions, t as AssembleOb11TransportsOptions, tt as OB11Return, u as OB11GroupRequestEvent, v as OB11MessageEvent, w as segmentsToCqMessage, x as OB11PostType, y as OB11PrivateMessageEvent, z as MessageUnique } from "../index-
|
|
5
|
+
import { $ as OB11MessageInfo, A as serializeCqParts, B as canonicalToCqMessage, C as ob11ConfigSchema, D as escapeCqParam, E as encodeCqCode, F as ob11ErrorCodeMap, G as CurrentTalkative, H as cqMessageToCanonical, I as OneBotApi, J as GroupInfo, K as FriendInfo, L as OneBotApiOptions, M as Ob11ActionDeps, N as createOb11ActionRegistry, O as escapeCqText, P as AtAllRemainInfo, Q as OB11Message, R as OneBotSystemOptions, S as OB11Config, T as CqCode, U as cqMessageToSegments, V as canonicalToSegments, W as segmentsToCanonical, X as HonorMember, Y as GroupMemberInfo, Z as LoginInfo, _ as OB11GroupMessageEvent, a as assembleOb11Transports, at as VersionInfo, b as OB11BaseEvent, c as OB11Event, d as OB11RequestEvent, et as OB11MessageSegment, f as OB11NoticeEvent, g as OB11Status, h as OB11MetaEvent, i as Ob11TransportSet, it as StrangerInfo, j as unescapeCqText, k as parseCqMessage, l as OB11FriendRequestEvent, m as OB11LifecycleMetaEvent, n as Ob11OutboundTransport, nt as Sender, o as NapukettoOneBot11Adapter, p as OB11HeartbeatMetaEvent, q as GroupHonorInfo, r as Ob11OutboundWsReconnect, rt as Sex, s as OneBot11AdapterOptions, t as AssembleOb11TransportsOptions, tt as OB11Return, u as OB11GroupRequestEvent, v as OB11MessageEvent, w as segmentsToCqMessage, x as OB11PostType, y as OB11PrivateMessageEvent, z as MessageUnique } from "../index-Beq1S5ad.mjs";
|
|
6
6
|
export { type AssembleOb11TransportsOptions, type AtAllRemainInfo, type CqCode, type CurrentTalkative, type FriendInfo, type GroupHonorInfo, type GroupInfo, type GroupMemberInfo, type HonorMember, type LoginInfo, MessageUnique, NapukettoOneBot11Adapter, type OB11BaseEvent, type OB11Config, type OB11Event, type OB11FriendRequestEvent, type OB11GroupMessageEvent, type OB11GroupRequestEvent, type OB11HeartbeatMetaEvent, type OB11LifecycleMetaEvent, type OB11Message, type OB11MessageEvent, type OB11MessageInfo, type OB11MessageSegment, type OB11MetaEvent, type OB11NoticeEvent, type OB11PostType, type OB11PrivateMessageEvent, type OB11RequestEvent, type OB11Return, type OB11Status, type Ob11ActionDeps, type Ob11OutboundTransport, type Ob11OutboundWsReconnect, type Ob11TransportSet, type OneBot11AdapterOptions, OneBotApi, type OneBotApiOptions, type OneBotSystemOptions, type Sender, type Sex, type StrangerInfo, type VersionInfo, assembleOb11Transports, canonicalToCqMessage, canonicalToSegments, cqMessageToCanonical, cqMessageToSegments, createOb11ActionRegistry, encodeCqCode, escapeCqParam, escapeCqText, ob11ConfigSchema, ob11ErrorCodeMap, parseCqMessage, segmentsToCanonical, segmentsToCqMessage, serializeCqParts, unescapeCqText };
|
package/dist/onebot11/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { y as MessageUnique, t as NapukettoOneBot11Adapter, r as OneBotApi, n as assembleOb11Transports, a as canonicalToCqMessage, o as canonicalToSegments, s as cqMessageToCanonical, c as cqMessageToSegments, i as createOb11ActionRegistry, f as encodeCqCode, p as escapeCqParam, m as escapeCqText, u as ob11ConfigSchema, v as ob11ErrorCodeMap, h as parseCqMessage, l as segmentsToCanonical, d as segmentsToCqMessage, g as serializeCqParts, _ as unescapeCqText } from "../onebot11-
|
|
1
|
+
export { y as MessageUnique, t as NapukettoOneBot11Adapter, r as OneBotApi, n as assembleOb11Transports, a as canonicalToCqMessage, o as canonicalToSegments, s as cqMessageToCanonical, c as cqMessageToSegments, i as createOb11ActionRegistry, f as encodeCqCode, p as escapeCqParam, m as escapeCqText, u as ob11ConfigSchema, v as ob11ErrorCodeMap, h as parseCqMessage, l as segmentsToCanonical, d as segmentsToCqMessage, g as serializeCqParts, _ as unescapeCqText } from "../onebot11-CaSEVtLy.mjs";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as validateServerTokens, c as BEARER_PREFIX, f as ActionRegistry, l as createTokenAuthorize, o as BaseProtocolAdapter, p as runAction, r as createServerSchema, s as resolveProtocolConfig } from "./framework-CA3087JP.mjs";
|
|
2
2
|
import { _ as cacheMediaFile, a as logEventFailure, c as protocolMediaSchema, d as mediaDownloader, f as prepareVideoElements, g as MediaCache, h as resolveLocalMedia, i as hasGrayTip, l as downloadProtocolMedia, m as exportQqMedia, o as sliceRaw, p as bindLocalMediaRoots, r as firstUntranslatedGrayTip, s as truncRaw, t as collectGrayTipUids, u as ensureSilk, y as withMediaScope } from "./gray-tip-D0SfHr7q.mjs";
|
|
3
|
-
import { a as firstNonEmptyString, c as MS_TO_SEC, d as numericUin, f as resolveUidToUinWithFallback, i as toUnixSeconds, l as NUMERIC_RE, m as toUin, n as senderNickname, o as stringOrUndefined, r as subscribeRawMessages, s as startupBaselineSec, u as collectGroupNotifyUids } from "./raw-message-
|
|
4
|
-
import { a as processSysMsgBlob, d as processInboundBuddyReqs, n as OBSERVED_UNNAMED_SYSMSG_KEYS, o as recognizeSysMsg, r as narrowSysMsgBlobs, t as extractEssenceSetSysMsg, u as BuddyReqDedup } from "./essence-
|
|
5
|
-
import { ChatType, EssenceListSync, GrayTipSubType, GroupApi,
|
|
3
|
+
import { a as firstNonEmptyString, c as MS_TO_SEC, d as numericUin, f as resolveUidToUinWithFallback, i as toUnixSeconds, l as NUMERIC_RE, m as toUin, n as senderNickname, o as stringOrUndefined, p as resolveUin, r as subscribeRawMessages, s as startupBaselineSec, u as collectGroupNotifyUids } from "./raw-message-B0kwCfKE.mjs";
|
|
4
|
+
import { a as processSysMsgBlob, d as processInboundBuddyReqs, n as OBSERVED_UNNAMED_SYSMSG_KEYS, o as recognizeSysMsg, r as narrowSysMsgBlobs, t as extractEssenceSetSysMsg, u as BuddyReqDedup } from "./essence-ChxJJipr.mjs";
|
|
5
|
+
import { ChatType, EssenceListSync, GrayTipSubType, GroupApi, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, WebHonorType, errorMessage, findPendingGroupRequest, hasStringProp, isRecord, kernelError, narrowEssenceGroupArg, toCanonicalElements, toPendingGroupRequest } from "@napuketto/kernel";
|
|
6
6
|
import { HttpClient, HttpServer, WsClient, WsServer } from "@napuketto/network";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { basename } from "node:path";
|
|
@@ -269,13 +269,14 @@ function createFriendQueryActions(api) {
|
|
|
269
269
|
/** 是否忽略缓存(go-cqhttp 扩展)。 */
|
|
270
270
|
no_cache: z.boolean().optional() }),
|
|
271
271
|
handle: async () => {
|
|
272
|
-
return (await api.friendApi.getFriendList()).
|
|
272
|
+
return (await api.friendApi.getFriendList()).flatMap((f) => {
|
|
273
|
+
if (f.uin === null || !Number.isSafeInteger(Number(f.uin))) return [];
|
|
273
274
|
const info = {
|
|
274
275
|
user_id: Number(f.uin),
|
|
275
276
|
nickname: f.nickname
|
|
276
277
|
};
|
|
277
278
|
if (f.remark !== "") info.remark = f.remark;
|
|
278
|
-
return info;
|
|
279
|
+
return [info];
|
|
279
280
|
});
|
|
280
281
|
}
|
|
281
282
|
}),
|
|
@@ -599,7 +600,7 @@ function createGroupManageActions(api) {
|
|
|
599
600
|
group_id: z.number(),
|
|
600
601
|
user_id: z.number(),
|
|
601
602
|
/** 禁言时长(秒),0 解除。 */
|
|
602
|
-
duration: z.
|
|
603
|
+
duration: z.int().nonnegative().default(DEFAULT_BAN_DURATION)
|
|
603
604
|
}),
|
|
604
605
|
handle: async (payload) => {
|
|
605
606
|
const uid = await memberUidOf(api, payload.user_id);
|
|
@@ -692,24 +693,27 @@ const getGroupAddRequestSchema = z.object({ count: z.number().optional() });
|
|
|
692
693
|
/** 默认获取数量。 */
|
|
693
694
|
const DEFAULT_COUNT$1 = 100;
|
|
694
695
|
/** GroupNotify → OB11 群请求项(纯函数)。 */
|
|
695
|
-
function toGroupAddRequestItem(notify) {
|
|
696
|
+
function toGroupAddRequestItem(notify, doubt, uinMap) {
|
|
696
697
|
const { seq, type, status, postscript, user1, group } = notify;
|
|
697
698
|
let groupCode = 0;
|
|
698
699
|
let groupName = "";
|
|
699
|
-
if (group
|
|
700
|
+
if (group != null) {
|
|
700
701
|
const { groupCode: code, groupName: name } = group;
|
|
701
702
|
groupCode = Number(code);
|
|
702
703
|
groupName = name;
|
|
703
704
|
}
|
|
704
705
|
let userId = 0;
|
|
705
706
|
let userNick = "";
|
|
706
|
-
if (user1
|
|
707
|
+
if (user1 != null) {
|
|
707
708
|
const { uid, nickName } = user1;
|
|
708
|
-
userId =
|
|
709
|
+
userId = resolveUin(uid, uinMap);
|
|
709
710
|
userNick = nickName;
|
|
710
711
|
}
|
|
712
|
+
const requestKind = toPendingGroupRequest(notify, doubt)?.request.kind;
|
|
711
713
|
return {
|
|
712
714
|
flag: seq,
|
|
715
|
+
doubt,
|
|
716
|
+
...requestKind !== void 0 ? { request_kind: requestKind } : {},
|
|
713
717
|
group_id: groupCode,
|
|
714
718
|
group_name: groupName,
|
|
715
719
|
user_id: userId,
|
|
@@ -719,45 +723,59 @@ function toGroupAddRequestItem(notify) {
|
|
|
719
723
|
postscript: postscript ?? ""
|
|
720
724
|
};
|
|
721
725
|
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
const
|
|
725
|
-
|
|
726
|
-
return
|
|
726
|
+
async function listRequests(api, doubt, count) {
|
|
727
|
+
const list = await api.groupNotifyApi.getSingleScreenNotifies(doubt, count);
|
|
728
|
+
const uids = collectGroupNotifyUids(list);
|
|
729
|
+
const uinMap = uids.length === 0 ? /* @__PURE__ */ new Map() : await api.uidToUin(uids);
|
|
730
|
+
return list.map((notify) => toGroupAddRequestItem(notify, doubt, uinMap));
|
|
727
731
|
}
|
|
728
732
|
/** 群通知域动作工厂(get_group_add_request / get_group_ignored_notifies /
|
|
729
733
|
* set_group_add_request / get_group_shut_list)。 */
|
|
730
734
|
function createGroupNotifyActions(api) {
|
|
735
|
+
const legacyKinds = {
|
|
736
|
+
add: ["join_request"],
|
|
737
|
+
invite: ["invitation", "invited_join_request"]
|
|
738
|
+
};
|
|
731
739
|
return [
|
|
732
740
|
defineOb11Action({
|
|
733
741
|
name: "get_group_add_request",
|
|
734
742
|
schema: getGroupAddRequestSchema,
|
|
735
|
-
handle:
|
|
736
|
-
return (await api.groupNotifyApi.getSingleScreenNotifies(false, payload.count ?? DEFAULT_COUNT$1)).map(toGroupAddRequestItem);
|
|
737
|
-
}
|
|
743
|
+
handle: (payload) => listRequests(api, false, payload.count ?? DEFAULT_COUNT$1)
|
|
738
744
|
}),
|
|
739
745
|
defineOb11Action({
|
|
740
746
|
name: "get_group_ignored_notifies",
|
|
741
747
|
schema: getGroupAddRequestSchema,
|
|
742
|
-
handle:
|
|
743
|
-
return (await api.groupNotifyApi.getSingleScreenNotifies(true, payload.count ?? DEFAULT_COUNT$1)).map(toGroupAddRequestItem);
|
|
744
|
-
}
|
|
748
|
+
handle: (payload) => listRequests(api, true, payload.count ?? DEFAULT_COUNT$1)
|
|
745
749
|
}),
|
|
746
750
|
defineOb11Action({
|
|
747
751
|
name: "set_group_add_request",
|
|
748
752
|
schema: z.object({
|
|
749
753
|
flag: z.string(),
|
|
754
|
+
doubt: z.boolean().optional(),
|
|
755
|
+
group_id: z.int().positive().optional(),
|
|
756
|
+
request_kind: z.enum([
|
|
757
|
+
"invitation",
|
|
758
|
+
"invited_join_request",
|
|
759
|
+
"join_request"
|
|
760
|
+
]).optional(),
|
|
761
|
+
sub_type: z.enum(["add", "invite"]).optional(),
|
|
750
762
|
approve: z.boolean().optional(),
|
|
751
763
|
reason: z.string().optional(),
|
|
752
764
|
count: z.number().optional()
|
|
753
765
|
}),
|
|
754
766
|
handle: async (payload) => {
|
|
755
767
|
const count = payload.count ?? DEFAULT_COUNT$1;
|
|
756
|
-
const
|
|
757
|
-
if (
|
|
768
|
+
const kindsFromSubtype = payload.sub_type === void 0 ? void 0 : legacyKinds[payload.sub_type];
|
|
769
|
+
if (payload.request_kind !== void 0 && kindsFromSubtype?.includes(payload.request_kind) === false) throw kernelError("群请求的 request_kind 与 sub_type 不一致", "INVALID_PARAM");
|
|
770
|
+
const { request, notify } = await findPendingGroupRequest(api.groupNotifyApi, {
|
|
771
|
+
seq: payload.flag,
|
|
772
|
+
doubt: payload.doubt,
|
|
773
|
+
kind: payload.request_kind ?? kindsFromSubtype,
|
|
774
|
+
...payload.group_id !== void 0 ? { groupCode: String(payload.group_id) } : {}
|
|
775
|
+
}, count);
|
|
758
776
|
let operateType = NTGroupRequestOperateTypes.KREFUSE;
|
|
759
777
|
if (payload.approve !== false) operateType = NTGroupRequestOperateTypes.KAGREE;
|
|
760
|
-
await api.groupNotifyApi.handleGroupRequest(
|
|
778
|
+
await api.groupNotifyApi.handleGroupRequest(request.doubt, notify, operateType, payload.reason ?? " ");
|
|
761
779
|
return null;
|
|
762
780
|
}
|
|
763
781
|
}),
|
|
@@ -931,61 +949,25 @@ const DEFAULT_COUNT = 50;
|
|
|
931
949
|
const INVITED_REQUEST_ALIAS = "InvitedRequest";
|
|
932
950
|
/** 收集全部涉及的 uid 批量转 uin(循环外一次请求)。 */
|
|
933
951
|
async function collectUinMap(api, notifies) {
|
|
934
|
-
const uids =
|
|
935
|
-
for (const notify of notifies) {
|
|
936
|
-
const { user1, user2 } = notify;
|
|
937
|
-
if (user1 !== void 0) {
|
|
938
|
-
const { uid } = user1;
|
|
939
|
-
if (uid !== "") uids.push(uid);
|
|
940
|
-
}
|
|
941
|
-
if (user2 !== void 0) {
|
|
942
|
-
const { uid } = user2;
|
|
943
|
-
if (uid !== "") uids.push(uid);
|
|
944
|
-
}
|
|
945
|
-
}
|
|
952
|
+
const uids = collectGroupNotifyUids(notifies);
|
|
946
953
|
if (uids.length === 0) return /* @__PURE__ */ new Map();
|
|
947
954
|
return await api.uidToUin(uids);
|
|
948
955
|
}
|
|
949
956
|
/** GroupNotify → OB11 群系统消息结构(纯函数,uin 已批量转换)。 */
|
|
950
957
|
function toMessageInfo(notify, uinMap) {
|
|
951
958
|
const { seq, status, postscript, user1, user2, group } = notify;
|
|
952
|
-
|
|
953
|
-
if (user1 !== void 0) {
|
|
954
|
-
const { uid } = user1;
|
|
955
|
-
user1Uid = uid;
|
|
956
|
-
}
|
|
957
|
-
let user2Uid = "";
|
|
958
|
-
if (user2 !== void 0) {
|
|
959
|
-
const { uid } = user2;
|
|
960
|
-
user2Uid = uid;
|
|
961
|
-
}
|
|
962
|
-
let groupCode = 0;
|
|
963
|
-
let groupName = "";
|
|
964
|
-
if (group !== void 0) {
|
|
965
|
-
const { groupCode: code, groupName: name } = group;
|
|
966
|
-
groupCode = Number(code);
|
|
967
|
-
groupName = name;
|
|
968
|
-
}
|
|
969
|
-
let invitorUin = Number(user1Uid);
|
|
970
|
-
const mapped1 = uinMap.get(user1Uid);
|
|
971
|
-
if (mapped1 !== void 0) invitorUin = Number(mapped1);
|
|
972
|
-
let actor = Number(user2Uid);
|
|
973
|
-
const mapped2 = uinMap.get(user2Uid);
|
|
974
|
-
if (mapped2 !== void 0) actor = Number(mapped2);
|
|
975
|
-
let invitorNick = "";
|
|
976
|
-
if (user1 !== void 0) {
|
|
977
|
-
const { nickName } = user1;
|
|
978
|
-
invitorNick = nickName;
|
|
979
|
-
}
|
|
959
|
+
const invitorNick = user1?.nickName ?? "";
|
|
980
960
|
return {
|
|
981
961
|
request_id: Number(seq),
|
|
982
|
-
|
|
962
|
+
flag: seq,
|
|
963
|
+
doubt: false,
|
|
964
|
+
invitor_uin: resolveUin(user1?.uid, uinMap),
|
|
983
965
|
invitor_nick: invitorNick,
|
|
984
|
-
group_id: groupCode,
|
|
966
|
+
group_id: Number(group?.groupCode ?? 0),
|
|
985
967
|
message: postscript ?? "",
|
|
986
|
-
group_name: groupName,
|
|
968
|
+
group_name: group?.groupName ?? "",
|
|
987
969
|
checked: status !== 1,
|
|
988
|
-
actor,
|
|
970
|
+
actor: resolveUin(user2?.uid, uinMap),
|
|
989
971
|
requester_nick: invitorNick
|
|
990
972
|
};
|
|
991
973
|
}
|
|
@@ -1002,7 +984,7 @@ function createGroupSystemMsgActions(api) {
|
|
|
1002
984
|
const joined = [];
|
|
1003
985
|
for (const notify of notifies) {
|
|
1004
986
|
const info = toMessageInfo(notify, uinMap);
|
|
1005
|
-
if (notify.type === GroupNotifyMsgType.INVITED_BY_MEMBER) invited.push(info);
|
|
987
|
+
if (notify.type === GroupNotifyMsgType.INVITED_BY_MEMBER || notify.type === GroupNotifyMsgType.INVITED_NEED_ADMINI_STRATOR_PASS) invited.push(info);
|
|
1006
988
|
else if (notify.type === GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS) joined.push(info);
|
|
1007
989
|
}
|
|
1008
990
|
return {
|
|
@@ -1592,7 +1574,10 @@ function toOb11MessageInfo(msg, unique, ctx = {}) {
|
|
|
1592
1574
|
const { sender } = info;
|
|
1593
1575
|
sender.role = ctx.senderRole ?? "member";
|
|
1594
1576
|
if (msg.sendMemberName != null) sender.card = msg.sendMemberName;
|
|
1595
|
-
} else
|
|
1577
|
+
} else {
|
|
1578
|
+
info.user_id = Number(msg.senderUin);
|
|
1579
|
+
if (msg.chatType === ChatType.C2C_TEMP) info.temp_source = 0;
|
|
1580
|
+
}
|
|
1596
1581
|
return info;
|
|
1597
1582
|
}
|
|
1598
1583
|
// src/onebot11/helper/notice.ts
|
|
@@ -1623,20 +1608,31 @@ function base(msg, ctx) {
|
|
|
1623
1608
|
function toRecall(msg, g, ctx) {
|
|
1624
1609
|
if (g?.revokeElement == null) return null;
|
|
1625
1610
|
const revoke = g.revokeElement;
|
|
1611
|
+
const peer = ctx.messageUnique?.getPeer(msg.msgId);
|
|
1612
|
+
const identity = {
|
|
1613
|
+
message_id: (peer?.chatType === msg.chatType && peer.peerUid === msg.peerUid ? ctx.messageUnique?.getMessageId(msg.msgId) : void 0) ?? 0,
|
|
1614
|
+
tip_message_id: msg.msgId,
|
|
1615
|
+
tip_message_seq: msg.msgSeq
|
|
1616
|
+
};
|
|
1626
1617
|
if (msg.chatType === ChatType.C2C) return {
|
|
1627
1618
|
time: toUnixSeconds(msg.msgTime),
|
|
1628
1619
|
self_id: Number(ctx.selfUin),
|
|
1629
1620
|
post_type: "notice",
|
|
1630
1621
|
notice_type: "friend_recall",
|
|
1631
|
-
user_id: toUin(
|
|
1632
|
-
|
|
1622
|
+
user_id: numericUin(msg.peerUin ?? null) ?? toUin(msg.peerUid, ctx),
|
|
1623
|
+
...identity
|
|
1633
1624
|
};
|
|
1625
|
+
if (msg.chatType !== ChatType.GROUP) return null;
|
|
1626
|
+
const sender = numericUin(msg.senderUin ?? null) ?? toUin(msg.senderUid, ctx);
|
|
1627
|
+
let operator = toUin(revoke.operatorUid, ctx);
|
|
1628
|
+
if (revoke.isSelfOperate === true) operator = Number(ctx.selfUin);
|
|
1629
|
+
else if (revoke.operatorUid && revoke.operatorUid === msg.senderUid) operator = sender;
|
|
1634
1630
|
return {
|
|
1635
1631
|
...base(msg, ctx),
|
|
1636
1632
|
notice_type: "group_recall",
|
|
1637
|
-
user_id:
|
|
1638
|
-
operator_id:
|
|
1639
|
-
|
|
1633
|
+
user_id: sender,
|
|
1634
|
+
operator_id: operator,
|
|
1635
|
+
...identity
|
|
1640
1636
|
};
|
|
1641
1637
|
}
|
|
1642
1638
|
/**
|
|
@@ -1651,6 +1647,7 @@ function toPoke(msg, g, ctx) {
|
|
|
1651
1647
|
const aioOp = g?.aioOpGrayTipElement;
|
|
1652
1648
|
ctx.logger?.warn({ raw: JSON.stringify(g)?.slice(0, 2e3) }, "ob11: poke grayTip raw(待真实事件校准)");
|
|
1653
1649
|
const isGroup = msg.chatType === ChatType.GROUP;
|
|
1650
|
+
const tempSource = msg.chatType === ChatType.C2C_TEMP ? numericUin(aioOp?.fromGrpCodeOfTmpChat ?? null) : null;
|
|
1654
1651
|
return {
|
|
1655
1652
|
time: toUnixSeconds(msg.msgTime),
|
|
1656
1653
|
self_id: Number(ctx.selfUin),
|
|
@@ -1659,7 +1656,8 @@ function toPoke(msg, g, ctx) {
|
|
|
1659
1656
|
sub_type: "poke",
|
|
1660
1657
|
group_id: isGroup ? Number(msg.peerUid) : 0,
|
|
1661
1658
|
user_id: toUin(msg.senderUid, ctx),
|
|
1662
|
-
target_id: toUin(aioOp?.peerUid ?? "", ctx)
|
|
1659
|
+
target_id: toUin(aioOp?.peerUid ?? "", ctx),
|
|
1660
|
+
...tempSource !== null && tempSource > 0 ? { temp_source: tempSource } : {}
|
|
1663
1661
|
};
|
|
1664
1662
|
}
|
|
1665
1663
|
/** 群成员变动映射器表(键 = TipGroupElementType;缺项 = 不可翻译返回 null)。 */
|
|
@@ -1728,7 +1726,8 @@ function toAdminChange(common, grp, ctx) {
|
|
|
1728
1726
|
/** 禁言(duration>0=ban / 否则 lift_ban)。 */
|
|
1729
1727
|
function toBan(common, grp, ctx) {
|
|
1730
1728
|
const shutUp = grp.shutUp;
|
|
1731
|
-
const duration =
|
|
1729
|
+
const duration = numericUin(shutUp?.duration ?? null);
|
|
1730
|
+
if (duration === null || !Number.isSafeInteger(duration)) return null;
|
|
1732
1731
|
return {
|
|
1733
1732
|
time: common.time,
|
|
1734
1733
|
self_id: common.selfId,
|
|
@@ -1830,29 +1829,22 @@ function toOb11NoticeEvent(msg, ctx) {
|
|
|
1830
1829
|
* 仅未处理状态(KUNHANDLE)推送——已处理通知重复推送不再发事件。
|
|
1831
1830
|
* 非请求类通知(踢人/转让等处理结果回执)返回 null。
|
|
1832
1831
|
*/
|
|
1833
|
-
function toOb11GroupRequestEvent(notify, ctx) {
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
case GroupNotifyMsgType.INVITED_BY_MEMBER:
|
|
1838
|
-
case GroupNotifyMsgType.INVITED_NEED_ADMINI_STRATOR_PASS:
|
|
1839
|
-
subType = "invite";
|
|
1840
|
-
break;
|
|
1841
|
-
case GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS:
|
|
1842
|
-
subType = "add";
|
|
1843
|
-
break;
|
|
1844
|
-
default: return null;
|
|
1845
|
-
}
|
|
1832
|
+
function toOb11GroupRequestEvent(notify, ctx, doubt = false) {
|
|
1833
|
+
const pending = toPendingGroupRequest(notify, doubt);
|
|
1834
|
+
if (pending === void 0) return null;
|
|
1835
|
+
const { request, initiatorUid, comment } = pending;
|
|
1846
1836
|
return {
|
|
1847
1837
|
time: Math.floor(Date.now() / MS_TO_SEC),
|
|
1848
1838
|
self_id: Number(ctx.selfUin),
|
|
1849
1839
|
post_type: "request",
|
|
1850
1840
|
request_type: "group",
|
|
1851
|
-
sub_type:
|
|
1852
|
-
group_id: Number(
|
|
1853
|
-
user_id: toUin(
|
|
1854
|
-
comment:
|
|
1855
|
-
flag:
|
|
1841
|
+
sub_type: request.kind === "join_request" ? "add" : "invite",
|
|
1842
|
+
group_id: Number(request.groupCode),
|
|
1843
|
+
user_id: toUin(initiatorUid, ctx),
|
|
1844
|
+
comment: comment ?? "",
|
|
1845
|
+
flag: request.seq,
|
|
1846
|
+
doubt,
|
|
1847
|
+
request_kind: request.kind
|
|
1856
1848
|
};
|
|
1857
1849
|
}
|
|
1858
1850
|
/**
|
|
@@ -3435,7 +3427,8 @@ function toOb11MessageEvent(msg, selfUin, unique, messageFormat = "array", ctx =
|
|
|
3435
3427
|
message_type: "private",
|
|
3436
3428
|
sub_type: subType,
|
|
3437
3429
|
user_id: userId,
|
|
3438
|
-
sender
|
|
3430
|
+
sender,
|
|
3431
|
+
...subType === "group" ? { temp_source: 0 } : {}
|
|
3439
3432
|
};
|
|
3440
3433
|
}
|
|
3441
3434
|
// src/onebot11/inbound/message.ts
|
|
@@ -3486,6 +3479,7 @@ var Ob11InboundMessage = class {
|
|
|
3486
3479
|
const notice = toOb11NoticeEvent(msg, {
|
|
3487
3480
|
selfUin: this.deps.selfUin,
|
|
3488
3481
|
uidToUin,
|
|
3482
|
+
messageUnique: this.deps.api.messageUnique,
|
|
3489
3483
|
...this.deps.logger !== void 0 ? { logger: this.deps.logger } : {}
|
|
3490
3484
|
});
|
|
3491
3485
|
if (notice !== null) this.deps.broadcast(notice);
|
|
@@ -3508,10 +3502,10 @@ var Ob11InboundRequest = class {
|
|
|
3508
3502
|
}
|
|
3509
3503
|
/** 群系统通知 → group request 事件(批量 uidToUin 后翻译,纯函数)。 */
|
|
3510
3504
|
async groupNotifies(doubt, notifies) {
|
|
3511
|
-
if (doubt || !Array.isArray(notifies)) return;
|
|
3505
|
+
if (typeof doubt !== "boolean" || !Array.isArray(notifies)) return;
|
|
3512
3506
|
const ctx = await this.requestCtx(collectGroupNotifyUids(notifies));
|
|
3513
3507
|
for (const notify of notifies) {
|
|
3514
|
-
const event = toOb11GroupRequestEvent(notify, ctx);
|
|
3508
|
+
const event = toOb11GroupRequestEvent(notify, ctx, doubt);
|
|
3515
3509
|
if (event !== null) this.deps.broadcast(event);
|
|
3516
3510
|
}
|
|
3517
3511
|
}
|
|
@@ -39,7 +39,7 @@ function numericUin(value) {
|
|
|
39
39
|
*/
|
|
40
40
|
function collectGroupNotifyUids(notifies) {
|
|
41
41
|
const uids = [];
|
|
42
|
-
for (const notify of notifies) for (const user of [notify.user1, notify.user2]) if (user
|
|
42
|
+
for (const notify of notifies) for (const user of [notify.user1, notify.user2]) if (typeof user?.uid === "string" && user.uid !== "") uids.push(user.uid);
|
|
43
43
|
return uids;
|
|
44
44
|
}
|
|
45
45
|
/**
|
package/dist/satori/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { f as HTTP_STATUS, t as NapukettoSatoriAdapter, c as SatoriActionError, i as SatoriApi, n as assembleSatoriTransports, d as canonicalToSatoriElements, a as createSatoriActionRegistry, o as parseContentToCanonical, l as parseElements, u as renderElements, m as satoriConfigSchema, p as satoriHttpStatusMap, s as satoriToCanonicalElements, r as toEventSignal } from "../satori-
|
|
1
|
+
export { f as HTTP_STATUS, t as NapukettoSatoriAdapter, c as SatoriActionError, i as SatoriApi, n as assembleSatoriTransports, d as canonicalToSatoriElements, a as createSatoriActionRegistry, o as parseContentToCanonical, l as parseElements, u as renderElements, m as satoriConfigSchema, p as satoriHttpStatusMap, s as satoriToCanonicalElements, r as toEventSignal } from "../satori-B-vWj1fa.mjs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as validateServerTokens, d as tokenEquals, f as ActionRegistry, l as createTokenAuthorize, o as BaseProtocolAdapter, p as runAction, r as createServerSchema, s as resolveProtocolConfig } from "./framework-CA3087JP.mjs";
|
|
2
2
|
import { _ as cacheMediaFile, a as logEventFailure, c as protocolMediaSchema, g as MediaCache, h as resolveLocalMedia, l as downloadProtocolMedia, m as exportQqMedia, p as bindLocalMediaRoots, t as collectGrayTipUids, u as ensureSilk, v as leaseInternalMedia, y as withMediaScope } from "./gray-tip-D0SfHr7q.mjs";
|
|
3
|
-
import { c as MS_TO_SEC, h as toUinString, i as toUnixSeconds, r as subscribeRawMessages } from "./raw-message-
|
|
4
|
-
import { ChatType, GrayTipSubType, NTGroupRequestOperateTypes, TipGroupElementType, errorMessage, isRecord, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
3
|
+
import { c as MS_TO_SEC, h as toUinString, i as toUnixSeconds, r as subscribeRawMessages } from "./raw-message-B0kwCfKE.mjs";
|
|
4
|
+
import { ChatType, GrayTipSubType, NTGroupRequestOperateTypes, TipGroupElementType, errorMessage, findPendingGroupRequest, isRecord, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
5
5
|
import { HttpServer, WsServer, isWsOpen, sendWsText } from "@napuketto/network";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { rm, rmdir } from "node:fs/promises";
|
|
@@ -574,6 +574,16 @@ async function renderMessageContent(raw, deps) {
|
|
|
574
574
|
}
|
|
575
575
|
return renderElements(elements);
|
|
576
576
|
}
|
|
577
|
+
function directMessageResources(raw, selfUin) {
|
|
578
|
+
const senderUin = raw.senderUin ?? "";
|
|
579
|
+
const peerUin = raw.peerUin ?? "";
|
|
580
|
+
const peerId = peerUin !== "" && peerUin !== selfUin ? peerUin : senderUin || peerUin;
|
|
581
|
+
const nickname = raw.sendNickName ?? "";
|
|
582
|
+
return {
|
|
583
|
+
channel: toDirectChannel(peerId, peerId === senderUin ? nickname : raw.peerName),
|
|
584
|
+
...senderUin === "" ? {} : { user: toUser(senderUin, nickname) }
|
|
585
|
+
};
|
|
586
|
+
}
|
|
577
587
|
/** RawMessage → Satori Message(资源提升:message 不嵌套 user/member/channel)。 */
|
|
578
588
|
async function toSatoriMessage(raw, deps) {
|
|
579
589
|
const content = await renderMessageContent(raw, deps);
|
|
@@ -590,11 +600,7 @@ async function toSatoriMessage(raw, deps) {
|
|
|
590
600
|
message.user = toUser(senderUin, nickname);
|
|
591
601
|
message.member = { user: message.user };
|
|
592
602
|
if (memberName !== "" && memberName !== nickname) message.member.nick = memberName;
|
|
593
|
-
} else
|
|
594
|
-
const peerId = senderUin !== "" ? senderUin : peerUin;
|
|
595
|
-
message.channel = toDirectChannel(peerId, nickname);
|
|
596
|
-
message.user = toUser(peerId, nickname);
|
|
597
|
-
}
|
|
603
|
+
} else Object.assign(message, directMessageResources(raw, deps.selfUin));
|
|
598
604
|
const created = toUnixSeconds(raw.msgTime) * MS_TO_SEC;
|
|
599
605
|
if (created > 0) message.created_at = created;
|
|
600
606
|
return message;
|
|
@@ -674,10 +680,11 @@ function createFriendActions(deps) {
|
|
|
674
680
|
name: "friend.list",
|
|
675
681
|
schema: z.object({ next: z.string().optional() }),
|
|
676
682
|
handle: async () => {
|
|
677
|
-
return { data: (await deps.friendApi.getFriendList()).
|
|
683
|
+
return { data: (await deps.friendApi.getFriendList()).flatMap((f) => {
|
|
684
|
+
if (f.uin === null) return [];
|
|
678
685
|
const out = { user: toUser(f.uin, f.nickname) };
|
|
679
686
|
if (f.remark !== "" && f.remark !== f.nickname) out.nick = f.remark;
|
|
680
|
-
return out;
|
|
687
|
+
return [out];
|
|
681
688
|
}) };
|
|
682
689
|
}
|
|
683
690
|
}),
|
|
@@ -715,13 +722,19 @@ async function findBuddyReq(deps, messageId) {
|
|
|
715
722
|
return found;
|
|
716
723
|
}
|
|
717
724
|
// src/satori/action/guild.ts
|
|
725
|
+
/**
|
|
726
|
+
* Satori 群组动作:guild.get / guild.list / guild.approve
|
|
727
|
+
* + guild.member.get / list / kick / mute / approve
|
|
728
|
+
* (role.set / role.unset / guild.role.*:501,见 registry)
|
|
729
|
+
*/
|
|
718
730
|
/** 成员列表默认条数。 */
|
|
719
731
|
const DEFAULT_MEMBER_LIMIT = 100;
|
|
720
732
|
/** guild.approve / guild.member.approve 共入参(处理群邀请与加群申请)。 */
|
|
721
733
|
const groupApproveSchema = z.object({
|
|
722
734
|
message_id: z.string(),
|
|
723
735
|
approve: z.boolean(),
|
|
724
|
-
comment: z.string().optional()
|
|
736
|
+
comment: z.string().optional(),
|
|
737
|
+
doubt: z.boolean().optional()
|
|
725
738
|
});
|
|
726
739
|
/** 群组动作工厂(guild.get / list / approve + member 五动作)。 */
|
|
727
740
|
function createGuildActions(deps) {
|
|
@@ -747,7 +760,7 @@ function createGuildActions(deps) {
|
|
|
747
760
|
schema: groupApproveSchema,
|
|
748
761
|
handle: async (payload) => {
|
|
749
762
|
const { message_id: messageId, approve, comment } = payload;
|
|
750
|
-
await respondGroupRequest(deps, messageId, approve, comment);
|
|
763
|
+
await respondGroupRequest(deps, messageId, approve, comment, payload.doubt, "invitation");
|
|
751
764
|
}
|
|
752
765
|
}),
|
|
753
766
|
defineSatoriAction({
|
|
@@ -806,7 +819,7 @@ function createGuildActions(deps) {
|
|
|
806
819
|
guild_id: z.string(),
|
|
807
820
|
user_id: z.string(),
|
|
808
821
|
/** 禁言时长(毫秒,Satori 规范);0 解除禁言。 */
|
|
809
|
-
duration: z.
|
|
822
|
+
duration: z.int().nonnegative()
|
|
810
823
|
}),
|
|
811
824
|
handle: async (payload) => {
|
|
812
825
|
const { guild_id: guildId, user_id: userId, duration } = payload;
|
|
@@ -822,26 +835,24 @@ function createGuildActions(deps) {
|
|
|
822
835
|
schema: groupApproveSchema,
|
|
823
836
|
handle: async (payload) => {
|
|
824
837
|
const { message_id: messageId, approve, comment } = payload;
|
|
825
|
-
await respondGroupRequest(deps, messageId, approve, comment);
|
|
838
|
+
await respondGroupRequest(deps, messageId, approve, comment, payload.doubt, ["join_request", "invited_join_request"]);
|
|
826
839
|
}
|
|
827
840
|
})
|
|
828
841
|
];
|
|
829
842
|
}
|
|
830
843
|
/** 处理群请求(guild.approve / guild.member.approve 共用实现)。 */
|
|
831
|
-
async function respondGroupRequest(deps, messageId, approve, comment) {
|
|
832
|
-
const notify = await
|
|
844
|
+
async function respondGroupRequest(deps, messageId, approve, comment, doubt, kind) {
|
|
845
|
+
const { request, notify } = await findPendingGroupRequest(deps.groupNotifyApi, {
|
|
846
|
+
seq: messageId,
|
|
847
|
+
doubt,
|
|
848
|
+
kind
|
|
849
|
+
}, 50);
|
|
833
850
|
const operateType = approve ? NTGroupRequestOperateTypes.KAGREE : NTGroupRequestOperateTypes.KREFUSE;
|
|
834
|
-
await deps.groupNotifyApi.handleGroupRequest(
|
|
851
|
+
await deps.groupNotifyApi.handleGroupRequest(request.doubt, notify, operateType, comment ?? "");
|
|
835
852
|
}
|
|
836
|
-
/** 毫秒 → 秒(QQ setMemberShutUp
|
|
853
|
+
/** 毫秒 → 秒(QQ setMemberShutUp 单位;正时长至少 1 秒,0 解除禁言)。 */
|
|
837
854
|
function msToSeconds(ms) {
|
|
838
|
-
return Math.max(
|
|
839
|
-
}
|
|
840
|
-
/** 按 message_id(通知 seq)查找群通知(单屏非可疑快照)。 */
|
|
841
|
-
async function findGroupNotify(deps, messageId) {
|
|
842
|
-
const found = (await deps.groupNotifyApi.getSingleScreenNotifies(false, 50)).find((item) => item.seq === messageId);
|
|
843
|
-
if (found === void 0) throw kernelError("群通知不存在", "NOT_FOUND");
|
|
844
|
-
return found;
|
|
855
|
+
return ms === 0 ? 0 : Math.max(1, Math.floor(ms / 1e3));
|
|
845
856
|
}
|
|
846
857
|
/** GroupMember → Satori GuildMember(user.id = uin;nick = 群名片优先)。 */
|
|
847
858
|
function toGuildMember(member, uin) {
|
|
@@ -1068,6 +1079,7 @@ async function parseContentToCanonical(content, deps) {
|
|
|
1068
1079
|
*/
|
|
1069
1080
|
/** 消息列表默认条数(规范推荐 50)。 */
|
|
1070
1081
|
const DEFAULT_LIST_LIMIT = 50;
|
|
1082
|
+
const MAX_LIST_LIMIT = 100;
|
|
1071
1083
|
/** message.create 参数。 */
|
|
1072
1084
|
const messageCreateSchema = z.object({
|
|
1073
1085
|
channel_id: z.string(),
|
|
@@ -1131,7 +1143,7 @@ function createMessageActions(deps) {
|
|
|
1131
1143
|
schema: z.object({
|
|
1132
1144
|
channel_id: z.string(),
|
|
1133
1145
|
/** 分页令牌(缺省从最新开始)。 */
|
|
1134
|
-
next: z.string().
|
|
1146
|
+
next: z.string().min(1).nullish(),
|
|
1135
1147
|
/** 查询方向(缺省 before)。 */
|
|
1136
1148
|
direction: z.enum([
|
|
1137
1149
|
"before",
|
|
@@ -1139,30 +1151,30 @@ function createMessageActions(deps) {
|
|
|
1139
1151
|
"around"
|
|
1140
1152
|
]).optional(),
|
|
1141
1153
|
/** 消息数量限制(缺省平台默认,推荐 50)。 */
|
|
1142
|
-
limit: z.
|
|
1154
|
+
limit: z.int().positive().optional(),
|
|
1143
1155
|
/** 排序(缺省 asc)。 */
|
|
1144
1156
|
order: z.enum(["asc", "desc"]).optional()
|
|
1145
1157
|
}),
|
|
1146
1158
|
handle: async (payload) => {
|
|
1147
1159
|
const { channel_id: channelId, next, direction, limit, order } = payload;
|
|
1148
|
-
if (direction
|
|
1160
|
+
if (direction !== void 0 && direction !== "before") throw kernelError(`暂不支持 ${direction} 方向`, "INVALID_PARAM");
|
|
1149
1161
|
const peer = await deps.resolvePeer(channelId);
|
|
1150
|
-
const count = limit ?? DEFAULT_LIST_LIMIT;
|
|
1151
|
-
const
|
|
1152
|
-
count,
|
|
1153
|
-
msgId: next ?? ""
|
|
1154
|
-
});
|
|
1162
|
+
const count = Math.min(limit ?? DEFAULT_LIST_LIMIT, MAX_LIST_LIMIT);
|
|
1163
|
+
const page = await fetchBefore(deps.msgApi, peer, next ?? "", count);
|
|
1155
1164
|
deps.setChannelType(channelId, peer.chatType === 2);
|
|
1156
|
-
const
|
|
1165
|
+
const delivered = page.slice(0, count);
|
|
1166
|
+
const cursor = page.length > count ? delivered.at(-1)?.msgId : void 0;
|
|
1167
|
+
const ordered = order === "desc" ? delivered : delivered.reverse();
|
|
1157
1168
|
const messages = [];
|
|
1158
1169
|
for (const msg of ordered) messages.push(await toSatoriMessage(msg, {
|
|
1159
1170
|
selfUin: deps.selfUin,
|
|
1160
1171
|
uidToUin: (uids) => deps.uidToUin(uids)
|
|
1161
1172
|
}));
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1173
|
+
return cursor === void 0 ? { data: messages } : {
|
|
1174
|
+
data: messages,
|
|
1175
|
+
prev: cursor,
|
|
1176
|
+
next: cursor
|
|
1177
|
+
};
|
|
1166
1178
|
}
|
|
1167
1179
|
}),
|
|
1168
1180
|
defineSatoriAction({
|
|
@@ -1179,6 +1191,30 @@ function createMessageActions(deps) {
|
|
|
1179
1191
|
})
|
|
1180
1192
|
];
|
|
1181
1193
|
}
|
|
1194
|
+
/** 原生历史按新到旧读取,允许原生把起始消息也放进响应。 */
|
|
1195
|
+
async function fetchBefore(api, peer, start, count) {
|
|
1196
|
+
const seen = /* @__PURE__ */ new Set(["", start]);
|
|
1197
|
+
const messages = [];
|
|
1198
|
+
let cursor = start;
|
|
1199
|
+
while (messages.length <= count) {
|
|
1200
|
+
const remaining = count + 1 - messages.length;
|
|
1201
|
+
const raw = await api.fetchMessages(peer, {
|
|
1202
|
+
count: remaining + (cursor === "" ? 0 : 1),
|
|
1203
|
+
msgId: cursor
|
|
1204
|
+
});
|
|
1205
|
+
const anchor = raw.findIndex(({ msgId }) => msgId === cursor);
|
|
1206
|
+
const older = raw.slice(anchor + 1).filter(({ msgId }) => {
|
|
1207
|
+
if (seen.has(msgId)) return false;
|
|
1208
|
+
seen.add(msgId);
|
|
1209
|
+
return true;
|
|
1210
|
+
});
|
|
1211
|
+
const oldest = older.at(-1);
|
|
1212
|
+
if (oldest === void 0) break;
|
|
1213
|
+
messages.push(...older);
|
|
1214
|
+
cursor = oldest.msgId;
|
|
1215
|
+
}
|
|
1216
|
+
return messages;
|
|
1217
|
+
}
|
|
1182
1218
|
// src/satori/action/reaction.ts
|
|
1183
1219
|
/**
|
|
1184
1220
|
* Satori 表态动作:reaction.create / reaction.delete
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@napuketto/adapter",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.22.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Protocol adapters (OneBot11 / Satori / KuroBot / Milky) for NapukettoQQ",
|
|
7
7
|
"keywords": [
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"dev": "tsdown --watch"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@napuketto/kernel": "^0.
|
|
86
|
+
"@napuketto/kernel": "^0.18.0",
|
|
87
87
|
"@napuketto/media": "^0.3.0",
|
|
88
88
|
"@napuketto/network": "^0.5.0",
|
|
89
89
|
"zod": "^4.6.7"
|