Merge pull request #406 from SnowLuma/dev
chore: promote dev → main (bc070eca)
This commit is contained in:
69 files changed
+1857
-262
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "snowluma-monorepo",
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.12",
|
||||
"description": "SnowLuma monorepo workspace (pnpm)",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/bridge",
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.12",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "SnowLuma bridge — QQ NT desktop client lifecycle: hook injection (via native addon), per-PID HookSession orchestration, pipe-watcher for process discovery, and the BridgeManagerSink interface that lets the hook layer call back into a UIN-keyed session router without depending on @snowluma/core. Consumed by the top-level app entry (which constructs the BridgeManager from @snowluma/core and injects it as the sink) and by the WebUI server (read-only HookProcessInfo views).",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/common",
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.12",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "SnowLuma shared infrastructure — leaf-package utilities with zero business dependencies. Logger / hex codec / log file transport / log line summariser / packet sender wire-protocol types / runtime config loader. Consumed by @snowluma/protocol, @snowluma/core, and @snowluma/onebot. Per-file subpath exports keep import sites unambiguous and let the bundler tree-shake aggressively (importing `@snowluma/common/hex` doesn't pull in `node:fs` from the logger transport).",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/core",
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.12",
|
||||
"description": "SnowLuma core - NTQQ packet sniffer with Node.js native addon",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
@@ -21,6 +21,7 @@ import { FetchUserProfile } from '@snowluma/protocol/oidb-services/contacts/fetc
|
||||
import { FetchUserProfileByUid } from '@snowluma/protocol/oidb-services/contacts/fetch-user-profile-by-uid';
|
||||
import { GetBuddyRecommendArk } from '@snowluma/protocol/oidb-services/contacts/get-buddy-recommend-ark';
|
||||
import { GetGroupRecommendArk } from '@snowluma/protocol/oidb-services/contacts/get-group-recommend-ark';
|
||||
import { SendTuwenArk, type SendTuwenArkParams } from '@snowluma/protocol/oidb-services/contacts/send-tuwen-ark';
|
||||
import { SetFriendCategory } from '@snowluma/protocol/oidb-services/contacts/set-friend-category';
|
||||
import { toHex } from '@snowluma/common/hex';
|
||||
import { createLogger } from '@snowluma/common/logger';
|
||||
@@ -137,6 +138,11 @@ export class ContactsApi {
|
||||
return GetGroupRecommendArk.invoke(this.ctx, { groupId });
|
||||
}
|
||||
|
||||
/** Send a custom 图文 ark card to a C2C peer or group (0xdc2_34). */
|
||||
sendTuwenArk(params: SendTuwenArkParams): Promise<void> {
|
||||
return SendTuwenArk.invoke(this.ctx, params);
|
||||
}
|
||||
|
||||
private async fetchFriendRoster(): Promise<FriendRoster> {
|
||||
const entries: FriendListPageEntry[] = [];
|
||||
const categories = new Map<number, FriendListPageCategory>();
|
||||
@@ -354,6 +360,18 @@ export class ContactsApi {
|
||||
const targetUin = raw.target?.uin ?? 0;
|
||||
const invitorUin = raw.invitor?.uin ?? 0;
|
||||
const operatorUin = raw.operatorUser?.uin ?? 0;
|
||||
const targetUid = raw.target?.uid
|
||||
|| this.ctx.identity.findUidByUin(targetUin, groupId)
|
||||
|| this.ctx.identity.findUidByUin(targetUin)
|
||||
|| '';
|
||||
const invitorUid = raw.invitor?.uid
|
||||
|| this.ctx.identity.findUidByUin(invitorUin, groupId)
|
||||
|| this.ctx.identity.findUidByUin(invitorUin)
|
||||
|| '';
|
||||
const operatorUid = raw.operatorUser?.uid
|
||||
|| this.ctx.identity.findUidByUin(operatorUin, groupId)
|
||||
|| this.ctx.identity.findUidByUin(operatorUin)
|
||||
|| '';
|
||||
const notifyType = raw.eventType ?? 0;
|
||||
const operationType = groupRequestOperationType(notifyType);
|
||||
const sequence = normalizeGroupRequestSequence(raw.sequence, groupId);
|
||||
@@ -368,20 +386,23 @@ export class ContactsApi {
|
||||
requests.push({
|
||||
groupId,
|
||||
groupName: raw.group?.groupName ?? '',
|
||||
targetUid: this.ctx.identity.findUidByUin(targetUin, groupId)
|
||||
?? this.ctx.identity.findUidByUin(targetUin)
|
||||
?? '',
|
||||
targetUin,
|
||||
targetUid,
|
||||
targetUin: targetUin
|
||||
|| this.ctx.identity.findUinByUid(targetUid, groupId)
|
||||
|| this.ctx.identity.findUinByUid(targetUid)
|
||||
|| 0,
|
||||
targetName: raw.target?.name ?? '',
|
||||
invitorUid: this.ctx.identity.findUidByUin(invitorUin, groupId)
|
||||
?? this.ctx.identity.findUidByUin(invitorUin)
|
||||
?? '',
|
||||
invitorUin,
|
||||
invitorUid,
|
||||
invitorUin: invitorUin
|
||||
|| this.ctx.identity.findUinByUid(invitorUid, groupId)
|
||||
|| this.ctx.identity.findUinByUid(invitorUid)
|
||||
|| 0,
|
||||
invitorName: raw.invitor?.name ?? '',
|
||||
operatorUid: this.ctx.identity.findUidByUin(operatorUin, groupId)
|
||||
?? this.ctx.identity.findUidByUin(operatorUin)
|
||||
?? '',
|
||||
operatorUin,
|
||||
operatorUid,
|
||||
operatorUin: operatorUin
|
||||
|| this.ctx.identity.findUinByUid(operatorUid, groupId)
|
||||
|| this.ctx.identity.findUinByUid(operatorUid)
|
||||
|| 0,
|
||||
operatorName: raw.operatorUser?.name ?? '',
|
||||
sequence,
|
||||
state: raw.state ?? 0,
|
||||
|
||||
@@ -48,8 +48,19 @@ export class FriendApi {
|
||||
}
|
||||
|
||||
/** List doubtful friend-add requests (可能认识的人). */
|
||||
getDoubtRequests(count: number): Promise<DoubtBuddyRequest[]> {
|
||||
return GetDoubtBuddyReq.invoke(this.ctx, { count });
|
||||
async getDoubtRequests(count: number): Promise<DoubtBuddyRequest[]> {
|
||||
const list = await GetDoubtBuddyReq.invoke(this.ctx, { count });
|
||||
return list.map((item) => {
|
||||
let uid = item.uid;
|
||||
let userId = item.user_id;
|
||||
if (userId <= 0 && uid) {
|
||||
userId = this.ctx.identity.findUinByUid(uid) ?? 0;
|
||||
}
|
||||
if (!uid && userId > 0) {
|
||||
uid = this.ctx.identity.findUidByUin(userId) ?? '';
|
||||
}
|
||||
return { ...item, uid, user_id: userId };
|
||||
});
|
||||
}
|
||||
|
||||
/** Approve a doubtful friend-add request by its uid (the list item's flag). */
|
||||
|
||||
@@ -76,14 +76,15 @@ export class ProfileApi {
|
||||
if (!resp) {
|
||||
throw new Error(result.errorMessage || 'set online status failed (network/timeout)');
|
||||
}
|
||||
if (resp.errCode !== undefined && resp.errCode !== 0) {
|
||||
throw new Error(resp.errMsg || `set online status failed with errCode: ${resp.errCode}`);
|
||||
const message = resp.errMsg ?? '';
|
||||
if (message !== '' && message !== 'set status success') {
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setProfile(nickname?: string, personalNote?: string): Promise<void> {
|
||||
return SetProfile.invoke(this.ctx, { nickname, personalNote });
|
||||
setProfile(nickname?: string, personalNote?: string, sex?: number): Promise<void> {
|
||||
return SetProfile.invoke(this.ctx, { nickname, personalNote, sex });
|
||||
}
|
||||
|
||||
setSelfLongNick(longNick: string): Promise<void> {
|
||||
|
||||
@@ -11,6 +11,7 @@ import type {
|
||||
Oidb0x89a_0HistoryVisibility,
|
||||
Oidb0x89a_0MemberPermission,
|
||||
Oidb0xf16Req,
|
||||
OidbGroupDetailRequest,
|
||||
OidbGroupRequestAction,
|
||||
OidbKickMember,
|
||||
OidbLeaveGroup,
|
||||
@@ -475,9 +476,11 @@ describe('apis/group-admin', () => {
|
||||
allowMemberUploadAlbum: true,
|
||||
});
|
||||
|
||||
expect(bridge.sendRawPacket.mock.calls[1]![0]).toBe('OidbSvcTrpcTcp.0x89a_0');
|
||||
const envelope = protobuf_decode<OidbBase<Oidb0x89a_0MemberPermission>>(
|
||||
bridge.sendRawPacket.mock.calls[1]![1],
|
||||
);
|
||||
expect(envelope.subCommand ?? 0).toBe(0);
|
||||
expect(envelope.body?.settings).toEqual({
|
||||
appPrivilegeFlag: 0,
|
||||
appPrivilegeMask: 1,
|
||||
@@ -568,6 +571,11 @@ describe('apis/group-admin', () => {
|
||||
'OidbSvcTrpcTcp.0x88d_0',
|
||||
'OidbSvcTrpcTcp.0xef0_1',
|
||||
]);
|
||||
const detailReq = protobuf_decode<OidbBase<OidbGroupDetailRequest>>(
|
||||
bridge.sendRawPacket.mock.calls.find((call) => call[0] === 'OidbSvcTrpcTcp.0x88d_0')![1],
|
||||
);
|
||||
expect(detailReq.body?.config?.flags?.question).toBe('');
|
||||
expect(detailReq.body?.config?.flags?.answer).toBe('');
|
||||
});
|
||||
|
||||
it('getAdminSettings treats omitted detail/ext zeros as the default values', async () => {
|
||||
|
||||
@@ -87,9 +87,30 @@ describe('apis/profile', () => {
|
||||
expect(decoded.batteryStatus ?? 0).toBe(0);
|
||||
});
|
||||
|
||||
it('setOnlineStatus accepts QQ\'s success reply even when the reply code is non-zero (#405)', async () => {
|
||||
const bridge = mockBridge();
|
||||
const respBuf = Buffer.from(protobuf_encode<SetStatusResp>({
|
||||
errCode: 1,
|
||||
errMsg: 'set status success',
|
||||
}));
|
||||
expect(respBuf.length).toBeGreaterThan(0);
|
||||
bridge.sendRawPacket.mockResolvedValueOnce({
|
||||
success: true, gotResponse: true, errorCode: 0, errorMessage: '', responseData: respBuf,
|
||||
} as any);
|
||||
await expect(new ProfileApi(bridge as any).setOnlineStatus(10, 0, 100)).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('setOnlineStatus accepts a success-only reply body (#405)', async () => {
|
||||
const bridge = mockBridge();
|
||||
const respBuf = Buffer.from(protobuf_encode<SetStatusResp>({ errMsg: 'set status success' }));
|
||||
bridge.sendRawPacket.mockResolvedValueOnce({
|
||||
success: true, gotResponse: true, errorCode: 0, errorMessage: '', responseData: respBuf,
|
||||
} as any);
|
||||
await expect(new ProfileApi(bridge as any).setOnlineStatus(10, 0)).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('setDiyOnlineStatus surfaces server errors via the same path as setOnlineStatus', async () => {
|
||||
const bridge = mockBridge();
|
||||
// Build a response that decodes to errCode != 0.
|
||||
const respBuf = Buffer.from(protobuf_encode<SetStatusResp>({ errCode: 1, errMsg: 'denied' }));
|
||||
bridge.sendRawPacket.mockResolvedValueOnce({
|
||||
success: true, gotResponse: true, errorCode: 0, errorMessage: '', responseData: respBuf,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/mcp",
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.12",
|
||||
"description": "MCP server exposing the SnowLuma OneBot action catalog (docs + JSON Schemas) and optional execution to LLM clients.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -3235,6 +3235,10 @@
|
||||
"type": "string",
|
||||
"description": "申请人 uid(回传作 set_doubt_friends_add_request 的 flag)"
|
||||
},
|
||||
"user_id": {
|
||||
"type": "integer",
|
||||
"description": "申请人 QQ 号"
|
||||
},
|
||||
"nick": {
|
||||
"type": "string",
|
||||
"description": "申请人昵称"
|
||||
@@ -3243,10 +3247,18 @@
|
||||
"type": "string",
|
||||
"description": "申请来源"
|
||||
},
|
||||
"reason": {
|
||||
"type": "string",
|
||||
"description": "附加说明"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string",
|
||||
"description": "验证留言"
|
||||
},
|
||||
"group_code": {
|
||||
"type": "string",
|
||||
"description": "来源群号,无则为空串"
|
||||
},
|
||||
"reqTime": {
|
||||
"type": "integer",
|
||||
"description": "申请时间戳"
|
||||
@@ -3254,9 +3266,12 @@
|
||||
},
|
||||
"required": [
|
||||
"uid",
|
||||
"user_id",
|
||||
"nick",
|
||||
"source",
|
||||
"reason",
|
||||
"msg",
|
||||
"group_code",
|
||||
"reqTime"
|
||||
]
|
||||
}
|
||||
@@ -5886,6 +5901,14 @@
|
||||
"type": "string",
|
||||
"description": "申请人昵称"
|
||||
},
|
||||
"invitor_uin": {
|
||||
"type": "integer",
|
||||
"description": "邀请人 QQ 号,无邀请时为 0"
|
||||
},
|
||||
"invitor_nick": {
|
||||
"type": "string",
|
||||
"description": "邀请人昵称"
|
||||
},
|
||||
"message": {
|
||||
"type": "string",
|
||||
"description": "验证留言"
|
||||
@@ -5905,6 +5928,8 @@
|
||||
"request_id",
|
||||
"requester_uin",
|
||||
"requester_nick",
|
||||
"invitor_uin",
|
||||
"invitor_nick",
|
||||
"message",
|
||||
"checked",
|
||||
"flag"
|
||||
@@ -6137,6 +6162,91 @@
|
||||
},
|
||||
"category": "消息"
|
||||
},
|
||||
{
|
||||
"name": "get_msg_emoji_likes",
|
||||
"aliases": [],
|
||||
"summary": "获取一条消息的全部表情回应",
|
||||
"returns": "该消息上每个表情回应的编号、数量与用户列表。",
|
||||
"returnsSchema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"emoji_id": {
|
||||
"type": "string",
|
||||
"description": "表情编号"
|
||||
},
|
||||
"emoji_type": {
|
||||
"type": "integer",
|
||||
"description": "表情类型"
|
||||
},
|
||||
"count": {
|
||||
"type": "integer",
|
||||
"description": "回应数量"
|
||||
},
|
||||
"last_reaction_time": {
|
||||
"type": "integer",
|
||||
"description": "最近一次回应时间"
|
||||
},
|
||||
"users": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"user_id": {
|
||||
"type": "integer",
|
||||
"description": "用户 QQ 号"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"user_id"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"emoji_id",
|
||||
"emoji_type",
|
||||
"count",
|
||||
"last_reaction_time",
|
||||
"users"
|
||||
]
|
||||
}
|
||||
},
|
||||
"readOnly": true,
|
||||
"params": [
|
||||
{
|
||||
"name": "message_id",
|
||||
"type": "messageId",
|
||||
"required": true,
|
||||
"role": "message_id",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"not": {
|
||||
"const": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message_id": {
|
||||
"type": "integer",
|
||||
"not": {
|
||||
"const": 0
|
||||
},
|
||||
"x-role": "message_id"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"message_id"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "扩展"
|
||||
},
|
||||
{
|
||||
"name": "get_online_clients",
|
||||
"aliases": [],
|
||||
@@ -7346,6 +7456,31 @@
|
||||
"level": {
|
||||
"type": "integer",
|
||||
"description": "QQ 等级,同 qq_level(仅查到资料时返回)"
|
||||
},
|
||||
"status": {
|
||||
"type": "integer",
|
||||
"description": "在线状态码"
|
||||
},
|
||||
"extStatus": {
|
||||
"type": "integer",
|
||||
"description": "扩展状态码"
|
||||
},
|
||||
"ext_status": {
|
||||
"type": "integer",
|
||||
"description": "扩展状态码(同 extStatus)"
|
||||
},
|
||||
"batteryStatus": {
|
||||
"type": "integer",
|
||||
"description": "电量状态"
|
||||
},
|
||||
"customStatus": {
|
||||
"type": "object",
|
||||
"description": "自定义状态",
|
||||
"nullable": true
|
||||
},
|
||||
"customStatusDescInfo": {
|
||||
"type": "string",
|
||||
"description": "自定义状态说明"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -9299,6 +9434,120 @@
|
||||
},
|
||||
"category": "空间"
|
||||
},
|
||||
{
|
||||
"name": "send_tuwen_ark",
|
||||
"aliases": [],
|
||||
"summary": "发送图文 Ark 卡片(私聊/群聊)",
|
||||
"returns": "null",
|
||||
"returnsSchema": {
|
||||
"type": "null"
|
||||
},
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "user_id",
|
||||
"type": "uint",
|
||||
"required": false,
|
||||
"role": "user_id",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "group_id",
|
||||
"type": "uint",
|
||||
"required": false,
|
||||
"role": "group_id",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "desc",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "summary",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": "[分享]"
|
||||
},
|
||||
{
|
||||
"name": "preview_url",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": "https://tangram-1251316161.file.myqcloud.com/files/20210721/e50a8e37e08f29bf1ffc7466e1950690.png"
|
||||
},
|
||||
{
|
||||
"name": "jump_url",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"user_id": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"x-role": "user_id"
|
||||
},
|
||||
"group_id": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"x-role": "group_id"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": {
|
||||
"type": "string"
|
||||
},
|
||||
"summary": {
|
||||
"type": "string",
|
||||
"default": "[分享]"
|
||||
},
|
||||
"preview_url": {
|
||||
"type": "string",
|
||||
"default": "https://tangram-1251316161.file.myqcloud.com/files/20210721/e50a8e37e08f29bf1ffc7466e1950690.png"
|
||||
},
|
||||
"jump_url": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"title",
|
||||
"desc",
|
||||
"jump_url"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "扩展"
|
||||
},
|
||||
{
|
||||
"name": "set_diy_online_status",
|
||||
"aliases": [],
|
||||
@@ -11209,6 +11458,17 @@
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "sex",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 2
|
||||
},
|
||||
"desc": "0 未知,1 男,2 女"
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
@@ -11220,6 +11480,12 @@
|
||||
},
|
||||
"personal_note": {
|
||||
"type": "string"
|
||||
},
|
||||
"sex": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 2,
|
||||
"description": "0 未知,1 男,2 女"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
@@ -12287,7 +12553,7 @@
|
||||
},
|
||||
{
|
||||
"category": "扩展",
|
||||
"count": 113
|
||||
"count": 114
|
||||
},
|
||||
{
|
||||
"category": "群相册",
|
||||
|
||||
@@ -3238,6 +3238,10 @@ export const ACTIONS: CatalogAction[] = [
|
||||
"type": "string",
|
||||
"description": "申请人 uid(回传作 set_doubt_friends_add_request 的 flag)"
|
||||
},
|
||||
"user_id": {
|
||||
"type": "integer",
|
||||
"description": "申请人 QQ 号"
|
||||
},
|
||||
"nick": {
|
||||
"type": "string",
|
||||
"description": "申请人昵称"
|
||||
@@ -3246,10 +3250,18 @@ export const ACTIONS: CatalogAction[] = [
|
||||
"type": "string",
|
||||
"description": "申请来源"
|
||||
},
|
||||
"reason": {
|
||||
"type": "string",
|
||||
"description": "附加说明"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string",
|
||||
"description": "验证留言"
|
||||
},
|
||||
"group_code": {
|
||||
"type": "string",
|
||||
"description": "来源群号,无则为空串"
|
||||
},
|
||||
"reqTime": {
|
||||
"type": "integer",
|
||||
"description": "申请时间戳"
|
||||
@@ -3257,9 +3269,12 @@ export const ACTIONS: CatalogAction[] = [
|
||||
},
|
||||
"required": [
|
||||
"uid",
|
||||
"user_id",
|
||||
"nick",
|
||||
"source",
|
||||
"reason",
|
||||
"msg",
|
||||
"group_code",
|
||||
"reqTime"
|
||||
]
|
||||
}
|
||||
@@ -5889,6 +5904,14 @@ export const ACTIONS: CatalogAction[] = [
|
||||
"type": "string",
|
||||
"description": "申请人昵称"
|
||||
},
|
||||
"invitor_uin": {
|
||||
"type": "integer",
|
||||
"description": "邀请人 QQ 号,无邀请时为 0"
|
||||
},
|
||||
"invitor_nick": {
|
||||
"type": "string",
|
||||
"description": "邀请人昵称"
|
||||
},
|
||||
"message": {
|
||||
"type": "string",
|
||||
"description": "验证留言"
|
||||
@@ -5908,6 +5931,8 @@ export const ACTIONS: CatalogAction[] = [
|
||||
"request_id",
|
||||
"requester_uin",
|
||||
"requester_nick",
|
||||
"invitor_uin",
|
||||
"invitor_nick",
|
||||
"message",
|
||||
"checked",
|
||||
"flag"
|
||||
@@ -6140,6 +6165,91 @@ export const ACTIONS: CatalogAction[] = [
|
||||
},
|
||||
"category": "消息"
|
||||
},
|
||||
{
|
||||
"name": "get_msg_emoji_likes",
|
||||
"aliases": [],
|
||||
"summary": "获取一条消息的全部表情回应",
|
||||
"returns": "该消息上每个表情回应的编号、数量与用户列表。",
|
||||
"returnsSchema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"emoji_id": {
|
||||
"type": "string",
|
||||
"description": "表情编号"
|
||||
},
|
||||
"emoji_type": {
|
||||
"type": "integer",
|
||||
"description": "表情类型"
|
||||
},
|
||||
"count": {
|
||||
"type": "integer",
|
||||
"description": "回应数量"
|
||||
},
|
||||
"last_reaction_time": {
|
||||
"type": "integer",
|
||||
"description": "最近一次回应时间"
|
||||
},
|
||||
"users": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"user_id": {
|
||||
"type": "integer",
|
||||
"description": "用户 QQ 号"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"user_id"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"emoji_id",
|
||||
"emoji_type",
|
||||
"count",
|
||||
"last_reaction_time",
|
||||
"users"
|
||||
]
|
||||
}
|
||||
},
|
||||
"readOnly": true,
|
||||
"params": [
|
||||
{
|
||||
"name": "message_id",
|
||||
"type": "messageId",
|
||||
"required": true,
|
||||
"role": "message_id",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"not": {
|
||||
"const": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message_id": {
|
||||
"type": "integer",
|
||||
"not": {
|
||||
"const": 0
|
||||
},
|
||||
"x-role": "message_id"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"message_id"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "扩展"
|
||||
},
|
||||
{
|
||||
"name": "get_online_clients",
|
||||
"aliases": [],
|
||||
@@ -7349,6 +7459,31 @@ export const ACTIONS: CatalogAction[] = [
|
||||
"level": {
|
||||
"type": "integer",
|
||||
"description": "QQ 等级,同 qq_level(仅查到资料时返回)"
|
||||
},
|
||||
"status": {
|
||||
"type": "integer",
|
||||
"description": "在线状态码"
|
||||
},
|
||||
"extStatus": {
|
||||
"type": "integer",
|
||||
"description": "扩展状态码"
|
||||
},
|
||||
"ext_status": {
|
||||
"type": "integer",
|
||||
"description": "扩展状态码(同 extStatus)"
|
||||
},
|
||||
"batteryStatus": {
|
||||
"type": "integer",
|
||||
"description": "电量状态"
|
||||
},
|
||||
"customStatus": {
|
||||
"type": "object",
|
||||
"description": "自定义状态",
|
||||
"nullable": true
|
||||
},
|
||||
"customStatusDescInfo": {
|
||||
"type": "string",
|
||||
"description": "自定义状态说明"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -9302,6 +9437,120 @@ export const ACTIONS: CatalogAction[] = [
|
||||
},
|
||||
"category": "空间"
|
||||
},
|
||||
{
|
||||
"name": "send_tuwen_ark",
|
||||
"aliases": [],
|
||||
"summary": "发送图文 Ark 卡片(私聊/群聊)",
|
||||
"returns": "null",
|
||||
"returnsSchema": {
|
||||
"type": "null"
|
||||
},
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "user_id",
|
||||
"type": "uint",
|
||||
"required": false,
|
||||
"role": "user_id",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "group_id",
|
||||
"type": "uint",
|
||||
"required": false,
|
||||
"role": "group_id",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "desc",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "summary",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": "[分享]"
|
||||
},
|
||||
{
|
||||
"name": "preview_url",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": "https://tangram-1251316161.file.myqcloud.com/files/20210721/e50a8e37e08f29bf1ffc7466e1950690.png"
|
||||
},
|
||||
{
|
||||
"name": "jump_url",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"user_id": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"x-role": "user_id"
|
||||
},
|
||||
"group_id": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"x-role": "group_id"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
"desc": {
|
||||
"type": "string"
|
||||
},
|
||||
"summary": {
|
||||
"type": "string",
|
||||
"default": "[分享]"
|
||||
},
|
||||
"preview_url": {
|
||||
"type": "string",
|
||||
"default": "https://tangram-1251316161.file.myqcloud.com/files/20210721/e50a8e37e08f29bf1ffc7466e1950690.png"
|
||||
},
|
||||
"jump_url": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"title",
|
||||
"desc",
|
||||
"jump_url"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "扩展"
|
||||
},
|
||||
{
|
||||
"name": "set_diy_online_status",
|
||||
"aliases": [],
|
||||
@@ -11212,6 +11461,17 @@ export const ACTIONS: CatalogAction[] = [
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "sex",
|
||||
"type": "int",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 2
|
||||
},
|
||||
"desc": "0 未知,1 男,2 女"
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
@@ -11223,6 +11483,12 @@ export const ACTIONS: CatalogAction[] = [
|
||||
},
|
||||
"personal_note": {
|
||||
"type": "string"
|
||||
},
|
||||
"sex": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 2,
|
||||
"description": "0 未知,1 男,2 女"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
@@ -12291,7 +12557,7 @@ export const CATEGORIES: CatalogCategory[] = [
|
||||
},
|
||||
{
|
||||
"category": "扩展",
|
||||
"count": 113
|
||||
"count": 114
|
||||
},
|
||||
{
|
||||
"category": "群相册",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/onebot",
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.12",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "SnowLuma OneBot v11 adapter — the protocol translation layer that maps the public OneBot vocabulary (HTTP / WebSocket actions, message segments, post events) onto @snowluma/core's typed Api hub (`bridge.apis.<area>.method()`). Owns network adapters (HTTP server / HTTP client / WS server / WS client), the registered action handlers, the receive-side event→OneBot converter, message-id hashing, message store (SQLite-backed event history), media store, and the OneBot instance + manager that ties one OneBotConfig to one Bridge. Per-file subpath exports mirror the legacy `core/src/onebot/*` layout 1:1 so the previous `import { … } from '../onebot/<x>'` collapses to `import { … } from '@snowluma/onebot/<x>'`.",
|
||||
|
||||
@@ -996,12 +996,10 @@ export const actions = [
|
||||
params: {
|
||||
nickname: f.string().optional(),
|
||||
personal_note: f.string().optional(),
|
||||
sex: f.int({ min: 0, max: 2 }).optional().describe('0 未知,1 男,2 女'),
|
||||
},
|
||||
run: async (p, ctx) => {
|
||||
const nickname = p.nickname;
|
||||
const personalNote = p.personal_note;
|
||||
|
||||
await ctx.bridge.apis.profile.setProfile(nickname, personalNote);
|
||||
await ctx.bridge.apis.profile.setProfile(p.nickname, p.personal_note, p.sex);
|
||||
return okResponse();
|
||||
},
|
||||
}),
|
||||
@@ -1400,6 +1398,41 @@ export const actions = [
|
||||
},
|
||||
}),
|
||||
|
||||
defineAction({
|
||||
name: 'get_msg_emoji_likes',
|
||||
summary: '获取一条消息的全部表情回应',
|
||||
readOnly: true,
|
||||
returns: '该消息上每个表情回应的编号、数量与用户列表。',
|
||||
returnsSchema: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
emoji_id: { type: 'string', description: '表情编号' },
|
||||
emoji_type: { type: 'integer', description: '表情类型' },
|
||||
count: { type: 'integer', description: '回应数量' },
|
||||
last_reaction_time: { type: 'integer', description: '最近一次回应时间' },
|
||||
users: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: { user_id: { type: 'integer', description: '用户 QQ 号' } },
|
||||
required: ['user_id'],
|
||||
},
|
||||
},
|
||||
},
|
||||
required: ['emoji_id', 'emoji_type', 'count', 'last_reaction_time', 'users'],
|
||||
},
|
||||
},
|
||||
params: { message_id: f.messageId() },
|
||||
run: async (p, ctx) => {
|
||||
if (!ctx.fetchEmojiLikeSummary) {
|
||||
return failedResponse(RETCODE.ACTION_FAILED, 'emoji reaction summary is unavailable');
|
||||
}
|
||||
return okResponse(await ctx.fetchEmojiLikeSummary(p.message_id));
|
||||
},
|
||||
}),
|
||||
|
||||
defineAction({
|
||||
name: 'get_friends_with_category',
|
||||
summary: '获取分组好友列表',
|
||||
@@ -1706,6 +1739,55 @@ export const actions = [
|
||||
},
|
||||
}),
|
||||
|
||||
// send_tuwen_ark — send a custom 图文 (URL-share) ark card to a C2C peer or group (0xdc2_34).
|
||||
// targetId at AppInfo[11] and Meta[2]; Meta.peerType: 0=C2C, 1=group.
|
||||
// 与 send_ark_share 的区别:send_ark_share 只获取推荐联系人 JSON 不发送;
|
||||
// 与 send_msg share/json 的区别:后者发送 structmsg 图文卡且有 message_id,
|
||||
// 本 action 发送固定图文 ark 模板,返回 null(无法用于撤回/设精华)。
|
||||
defineAction({
|
||||
name: 'send_tuwen_ark',
|
||||
summary: '发送图文 Ark 卡片(私聊/群聊)',
|
||||
readOnly: false,
|
||||
returns: 'null',
|
||||
returnsSchema: { type: 'null' },
|
||||
params: {
|
||||
user_id: f.userId().optional(),
|
||||
group_id: f.groupId().optional(),
|
||||
title: f.string(),
|
||||
desc: f.string(),
|
||||
summary: f.string().default('[分享]'),
|
||||
preview_url: f.string().default('https://tangram-1251316161.file.myqcloud.com/files/20210721/e50a8e37e08f29bf1ffc7466e1950690.png'),
|
||||
jump_url: f.string(),
|
||||
},
|
||||
run: async (p, ctx) => {
|
||||
if (p.group_id) {
|
||||
await ctx.bridge.apis.contacts.sendTuwenArk({
|
||||
targetId: p.group_id,
|
||||
peerType: 1,
|
||||
title: p.title,
|
||||
desc: p.desc,
|
||||
summary: p.summary,
|
||||
previewUrl: p.preview_url,
|
||||
jumpUrl: p.jump_url,
|
||||
});
|
||||
return okResponse(null);
|
||||
}
|
||||
if (p.user_id) {
|
||||
await ctx.bridge.apis.contacts.sendTuwenArk({
|
||||
targetId: p.user_id,
|
||||
peerType: 0,
|
||||
title: p.title,
|
||||
desc: p.desc,
|
||||
summary: p.summary,
|
||||
previewUrl: p.preview_url,
|
||||
jumpUrl: p.jump_url,
|
||||
});
|
||||
return okResponse(null);
|
||||
}
|
||||
return failedResponse(RETCODE.BAD_REQUEST, 'user_id or group_id is required');
|
||||
},
|
||||
}),
|
||||
|
||||
// share_group_ex / send_group_ark_share — group-only Ark share. NapCat uses
|
||||
// a distinct kernel API (getArkJsonGroupShare) we did NOT RE; we route to
|
||||
// the fully-RE'd group recommend-contact ark (0x8b7_5), the closest
|
||||
@@ -1746,12 +1828,15 @@ export const actions = [
|
||||
type: 'object',
|
||||
properties: {
|
||||
uid: { type: 'string', description: '申请人 uid(回传作 set_doubt_friends_add_request 的 flag)' },
|
||||
user_id: { type: 'integer', description: '申请人 QQ 号' },
|
||||
nick: { type: 'string', description: '申请人昵称' },
|
||||
source: { type: 'string', description: '申请来源' },
|
||||
reason: { type: 'string', description: '附加说明' },
|
||||
msg: { type: 'string', description: '验证留言' },
|
||||
group_code: { type: 'string', description: '来源群号,无则为空串' },
|
||||
reqTime: { type: 'integer', description: '申请时间戳' },
|
||||
},
|
||||
required: ['uid', 'nick', 'source', 'msg', 'reqTime'],
|
||||
required: ['uid', 'user_id', 'nick', 'source', 'reason', 'msg', 'group_code', 'reqTime'],
|
||||
},
|
||||
},
|
||||
params: { count: f.int({ min: 0 }).default(50) },
|
||||
|
||||
@@ -44,6 +44,12 @@ export const actions = [
|
||||
long_nick: { type: 'string', description: '个性签名' },
|
||||
qq_level: { type: 'integer', description: 'QQ 等级(仅查到资料时返回)' },
|
||||
level: { type: 'integer', description: 'QQ 等级,同 qq_level(仅查到资料时返回)' },
|
||||
status: { type: 'integer', description: '在线状态码' },
|
||||
extStatus: { type: 'integer', description: '扩展状态码' },
|
||||
ext_status: { type: 'integer', description: '扩展状态码(同 extStatus)' },
|
||||
batteryStatus: { type: 'integer', description: '电量状态' },
|
||||
customStatus: { type: 'object', description: '自定义状态', nullable: true },
|
||||
customStatusDescInfo: { type: 'string', description: '自定义状态说明' },
|
||||
},
|
||||
required: ['user_id', 'nickname', 'remark', 'sex', 'age', 'long_nick'],
|
||||
},
|
||||
|
||||
@@ -224,13 +224,16 @@ export const actions = [
|
||||
request_id: { type: 'integer', description: '请求序列号' },
|
||||
requester_uin: { type: 'integer', description: '申请人 QQ 号' },
|
||||
requester_nick: { type: 'string', description: '申请人昵称' },
|
||||
invitor_uin: { type: 'integer', description: '邀请人 QQ 号,无邀请时为 0' },
|
||||
invitor_nick: { type: 'string', description: '邀请人昵称' },
|
||||
message: { type: 'string', description: '验证留言' },
|
||||
checked: { type: 'boolean', description: '是否已处理' },
|
||||
flag: { type: 'string', description: '处理请求使用的规范 flag' },
|
||||
},
|
||||
required: [
|
||||
'group_id', 'group_name', 'request_id', 'requester_uin',
|
||||
'requester_nick', 'message', 'checked', 'flag',
|
||||
'requester_nick', 'invitor_uin', 'invitor_nick',
|
||||
'message', 'checked', 'flag',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
@@ -91,6 +91,13 @@ export interface ApiActionContext {
|
||||
serverCount: number;
|
||||
complete: boolean;
|
||||
}>;
|
||||
fetchEmojiLikeSummary: (messageId: number) => Promise<Array<{
|
||||
emoji_id: string;
|
||||
emoji_type: number;
|
||||
count: number;
|
||||
last_reaction_time: number;
|
||||
users: Array<{ user_id: number }>;
|
||||
}>>;
|
||||
getImageInfo: (file: string) => Promise<JsonObject | null>;
|
||||
getRecordInfo: (file: string) => Promise<JsonObject | null>;
|
||||
fetchPttText: (messageId: number) => Promise<{ text: string }>;
|
||||
|
||||
@@ -16,11 +16,13 @@ export function convertFriendRequest(ctx: ConverterContext, event: FriendRequest
|
||||
}
|
||||
|
||||
export function convertGroupInvite(ctx: ConverterContext, event: GroupInvite): JsonObject {
|
||||
const invitedId = event.invitedUin ?? 0;
|
||||
return request(ctx, event, {
|
||||
request_type: 'group',
|
||||
sub_type: event.subType || 'invite',
|
||||
group_id: event.groupId,
|
||||
user_id: event.fromUin,
|
||||
...(invitedId > 0 ? { invited_id: invitedId } : {}),
|
||||
comment: event.message,
|
||||
flag: event.flag,
|
||||
});
|
||||
|
||||
@@ -180,6 +180,10 @@ export class GroupRequestPoller {
|
||||
groupId: request.groupId,
|
||||
fromUin,
|
||||
fromUid,
|
||||
...(notifyType === 1 ? {
|
||||
invitedUin: request.targetUin,
|
||||
invitedUid: request.targetUid,
|
||||
} : {}),
|
||||
subType,
|
||||
message: request.comment,
|
||||
flag: formatGroupRequestFlag(inviteCardSequence === undefined ? request : {
|
||||
|
||||
@@ -129,6 +129,31 @@ export function buildApiContext(ref: OneBotInstanceContext): ApiActionContext {
|
||||
if (!hasAuthoritativeSequence(meta)) throw new Error('message has no authoritative QQ sequence');
|
||||
await bridge.apis.interaction.setReaction(meta.targetId, meta.sequence, emojiId, set);
|
||||
},
|
||||
fetchEmojiLikeSummary: async (messageId) => {
|
||||
const meta = messageStore.findMeta(messageId);
|
||||
if (!meta) throw new Error('message not found');
|
||||
if (!meta.isGroup) throw new Error('emoji reactions are not supported on private messages');
|
||||
if (!hasAuthoritativeSequence(meta)) throw new Error('message has no authoritative QQ sequence');
|
||||
let summary: Array<{ emojiId: string; emojiType: number; count: number; lastReactionTime: number }>;
|
||||
try {
|
||||
summary = await bridge.apis.interaction.fetchReactionSummary(meta.targetId, meta.sequence);
|
||||
} catch {
|
||||
summary = reactionStore.summarizeMessage(meta.targetId, meta.sequence).map((entry) => ({
|
||||
emojiId: entry.emojiId,
|
||||
emojiType: entry.emojiType,
|
||||
count: entry.count,
|
||||
lastReactionTime: entry.lastSetAt,
|
||||
}));
|
||||
}
|
||||
return summary.map((entry) => ({
|
||||
emoji_id: entry.emojiId,
|
||||
emoji_type: entry.emojiType,
|
||||
count: entry.count,
|
||||
last_reaction_time: entry.lastReactionTime,
|
||||
users: reactionStore.listUsers(meta.targetId, meta.sequence, entry.emojiId, 1000, 0)
|
||||
.map((user) => ({ user_id: user.operatorUin })),
|
||||
}));
|
||||
},
|
||||
fetchEmojiLikeUsers: async (messageId, emojiId, count, offset = 0) => {
|
||||
const meta = messageStore.findMeta(messageId);
|
||||
if (!meta) throw new Error('message not found');
|
||||
|
||||
@@ -280,35 +280,39 @@ export async function getGroupFiles(
|
||||
};
|
||||
}
|
||||
|
||||
function formatStrangerInfo(p: UserProfileInfo): JsonObject {
|
||||
return {
|
||||
user_id: p.uin,
|
||||
nickname: p.nickname,
|
||||
remark: p.remark,
|
||||
sex: p.sex,
|
||||
age: p.age,
|
||||
long_nick: p.sign,
|
||||
qq_level: p.level,
|
||||
level: p.level,
|
||||
status: p.status ?? 0,
|
||||
extStatus: p.extStatus ?? 0,
|
||||
ext_status: p.extStatus ?? 0,
|
||||
batteryStatus: p.batteryStatus ?? 0,
|
||||
customStatus: p.customStatus ?? null,
|
||||
customStatusDescInfo: p.customStatusDesc ?? '',
|
||||
};
|
||||
}
|
||||
|
||||
export async function getStrangerInfo(
|
||||
bridge: BridgeInterface,
|
||||
userId: number,
|
||||
): Promise<JsonObject | null> {
|
||||
try {
|
||||
const p = await bridge.apis.contacts.fetchUserProfile(userId);
|
||||
return {
|
||||
user_id: p.uin,
|
||||
nickname: p.nickname,
|
||||
remark: p.remark,
|
||||
sex: p.sex,
|
||||
age: p.age,
|
||||
long_nick: p.sign,
|
||||
qq_level: p.level,
|
||||
level: p.level,
|
||||
};
|
||||
return formatStrangerInfo(p);
|
||||
} catch {
|
||||
const p = bridge.identity.findUserProfile(userId);
|
||||
if (p) {
|
||||
return {
|
||||
user_id: p.uin,
|
||||
nickname: p.nickname,
|
||||
return formatStrangerInfo({
|
||||
...p,
|
||||
remark: p.remark || bridge.identity.findFriend(userId)?.remark || '',
|
||||
sex: p.sex,
|
||||
age: p.age,
|
||||
long_nick: p.sign,
|
||||
qq_level: p.level,
|
||||
level: p.level,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const friend = bridge.identity.findFriend(userId);
|
||||
@@ -327,24 +331,33 @@ export async function getStrangerInfo(
|
||||
async function resolveRequesterUins(
|
||||
bridge: BridgeInterface,
|
||||
requests: readonly GroupRequestInfo[],
|
||||
): Promise<Map<string, number>> {
|
||||
const resolved = new Map<string, number>();
|
||||
): Promise<Map<string, { uin: number; name: string }>> {
|
||||
const resolved = new Map<string, { uin: number; name: string }>();
|
||||
const unresolved = new Set<string>();
|
||||
const names = new Map<string, string>();
|
||||
const unresolvedUins = new Set<number>();
|
||||
|
||||
for (const request of requests) {
|
||||
const actor = groupRequestActor(request);
|
||||
const uid = actor.uid;
|
||||
if (!uid || resolved.has(uid)) continue;
|
||||
if (actor.uin > 0) {
|
||||
resolved.set(uid, actor.uin);
|
||||
if (actor.name) names.set(uid || `uin:${actor.uin}`, actor.name);
|
||||
if (uid && actor.uin > 0 && actor.name) {
|
||||
resolved.set(uid, { uin: actor.uin, name: actor.name });
|
||||
unresolved.delete(uid);
|
||||
continue;
|
||||
}
|
||||
if (unresolved.has(uid)) continue;
|
||||
const cached = bridge.identity.findUinByUid(uid, request.groupId)
|
||||
?? bridge.identity.findUinByUid(uid);
|
||||
if (cached && cached > 0) resolved.set(uid, cached);
|
||||
else unresolved.add(uid);
|
||||
if (uid) {
|
||||
if (resolved.has(uid) || unresolved.has(uid)) continue;
|
||||
const cached = bridge.identity.findUinByUid(uid, request.groupId)
|
||||
?? bridge.identity.findUinByUid(uid);
|
||||
if (cached && cached > 0 && actor.name) {
|
||||
resolved.set(uid, { uin: cached, name: actor.name });
|
||||
} else {
|
||||
unresolved.add(uid);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (actor.uin > 0 && !actor.name) unresolvedUins.add(actor.uin);
|
||||
}
|
||||
|
||||
const profiles = await mapWithConcurrency(
|
||||
@@ -361,13 +374,43 @@ async function resolveRequesterUins(
|
||||
if (!Number.isSafeInteger(profile.uin) || profile.uin <= 0) {
|
||||
throw new Error(`failed to resolve requester UIN for UID ${uid}`);
|
||||
}
|
||||
return [uid, profile.uin] as const;
|
||||
return [uid, profile] as const;
|
||||
},
|
||||
);
|
||||
for (const [uid, uin] of profiles) resolved.set(uid, uin);
|
||||
for (const [uid, profile] of profiles) {
|
||||
resolved.set(uid, {
|
||||
uin: profile.uin,
|
||||
name: names.get(uid) || profile.nickname || '',
|
||||
});
|
||||
}
|
||||
|
||||
const uinProfiles = await mapWithConcurrency(
|
||||
[...unresolvedUins],
|
||||
REQUESTER_PROFILE_CONCURRENCY,
|
||||
async (uin) => {
|
||||
try {
|
||||
return [uin, await bridge.apis.contacts.fetchUserProfile(uin)] as const;
|
||||
} catch {
|
||||
return [uin, undefined] as const;
|
||||
}
|
||||
},
|
||||
);
|
||||
for (const [uin, profile] of uinProfiles) {
|
||||
if (!profile) continue;
|
||||
resolved.set(`uin:${uin}`, { uin: profile.uin, name: profile.nickname || '' });
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
|
||||
/** Join request (7) or invite that still needs an admin (5 / mapped 22). */
|
||||
function isJoinOrInviteNotify(notifyType: number | undefined): boolean {
|
||||
return notifyType === undefined
|
||||
|| notifyType === 1
|
||||
|| notifyType === 5
|
||||
|| notifyType === 7
|
||||
|| notifyType === 22;
|
||||
}
|
||||
|
||||
function groupRequestActor(request: GroupRequestInfo): {
|
||||
uid: string;
|
||||
uin: number;
|
||||
@@ -401,9 +444,7 @@ export async function getGroupSystemMessages(
|
||||
]);
|
||||
const unique = new Map<string, GroupRequestInfo>();
|
||||
for (const request of [...main, ...filtered]) {
|
||||
if (request.notifyType !== undefined
|
||||
&& request.notifyType !== 1
|
||||
&& request.notifyType !== 7) continue;
|
||||
if (!isJoinOrInviteNotify(request.notifyType)) continue;
|
||||
if (request.eventType <= 0) continue;
|
||||
const flag = formatGroupRequestFlag(request);
|
||||
if (!unique.has(flag)) unique.set(flag, request);
|
||||
@@ -417,12 +458,16 @@ export async function getGroupSystemMessages(
|
||||
|
||||
return requests.map((request) => {
|
||||
const actor = groupRequestActor(request);
|
||||
const resolved = (actor.uid ? requesterUins.get(actor.uid) : undefined)
|
||||
?? (actor.uin > 0 ? requesterUins.get(`uin:${actor.uin}`) : undefined);
|
||||
return {
|
||||
group_id: request.groupId,
|
||||
group_name: request.groupName,
|
||||
request_id: request.sequence,
|
||||
requester_uin: requesterUins.get(actor.uid) ?? actor.uin,
|
||||
requester_nick: actor.name,
|
||||
requester_uin: resolved?.uin ?? actor.uin,
|
||||
requester_nick: resolved?.name || actor.name,
|
||||
invitor_uin: request.invitorUin,
|
||||
invitor_nick: request.invitorName,
|
||||
message: request.comment,
|
||||
checked: request.state !== 1,
|
||||
flag: formatGroupRequestFlag(request),
|
||||
|
||||
@@ -90,9 +90,11 @@ describe('compileActionRegistry namespace conflicts', () => {
|
||||
});
|
||||
|
||||
describe('compiled production Action registry', () => {
|
||||
it('preserves all 191 canonical Action docs', () => {
|
||||
expect(ACTION_REGISTRY.actions).toHaveLength(191);
|
||||
expect(collectActionDocs()).toHaveLength(191);
|
||||
it('publishes a doc for every compiled action', () => {
|
||||
const registryNames = ACTION_REGISTRY.actions.map((action) => action.doc.name).sort();
|
||||
const docNames = collectActionDocs().map((doc) => doc.name).sort();
|
||||
expect(docNames).toEqual(registryNames);
|
||||
expect(docNames.length).toBeGreaterThan(100);
|
||||
});
|
||||
|
||||
it('resolves every executable name to exactly one canonical doc', () => {
|
||||
|
||||
@@ -627,6 +627,30 @@ describe('onebot/contact-actions / getGroupSystemMessages', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('includes admin-approval invitations with the invited account and inviter', async () => {
|
||||
const bridge = fakeBridge({
|
||||
fetchGroupRequests: vi.fn(async (filtered: boolean) => filtered ? [] : [
|
||||
makeGroupRequest({
|
||||
notifyType: 5,
|
||||
eventType: 22,
|
||||
targetUin: 10_001,
|
||||
targetName: 'invitee',
|
||||
invitorUin: 45_678,
|
||||
invitorName: 'inviter',
|
||||
}),
|
||||
]),
|
||||
});
|
||||
|
||||
const result = await getGroupSystemMessages(bridge);
|
||||
|
||||
expect(result).toEqual([expect.objectContaining({
|
||||
requester_uin: 10_001,
|
||||
requester_nick: 'invitee',
|
||||
invitor_uin: 45_678,
|
||||
invitor_nick: 'inviter',
|
||||
})]);
|
||||
});
|
||||
|
||||
it('reports the inviter as requester for group invitations', async () => {
|
||||
const bridge = fakeBridge({
|
||||
fetchGroupRequests: vi.fn(async (filtered: boolean) => filtered ? [] : [
|
||||
@@ -646,6 +670,8 @@ describe('onebot/contact-actions / getGroupSystemMessages', () => {
|
||||
expect(result).toEqual([expect.objectContaining({
|
||||
requester_uin: 45_678,
|
||||
requester_nick: 'inviter',
|
||||
invitor_uin: 45_678,
|
||||
invitor_nick: 'inviter',
|
||||
})]);
|
||||
});
|
||||
|
||||
|
||||
@@ -363,6 +363,23 @@ describe('convertEvent — request kinds', () => {
|
||||
} as QQEventVariant);
|
||||
expect(withSubType!.sub_type).toBe('add');
|
||||
});
|
||||
|
||||
it('group_invite: reports the invitee without replacing user_id (#394)', async () => {
|
||||
const out = await convertEvent(bareCtx(), {
|
||||
kind: 'group_invite', time: 1, selfUin: SELF_ID, groupId: GROUP_ID,
|
||||
fromUin: PEER_UIN, invitedUin: 4242, message: '', flag: 'gflag', subType: 'invite',
|
||||
} as QQEventVariant);
|
||||
expect(out!.user_id).toBe(PEER_UIN);
|
||||
expect(out!.invited_id).toBe(4242);
|
||||
});
|
||||
|
||||
it('group_invite: omits invited_id when the invitee is unknown', async () => {
|
||||
const out = await convertEvent(bareCtx(), {
|
||||
kind: 'group_invite', time: 1, selfUin: SELF_ID, groupId: GROUP_ID,
|
||||
fromUin: PEER_UIN, message: '', flag: 'gflag', subType: 'invite',
|
||||
} as QQEventVariant);
|
||||
expect(out).not.toHaveProperty('invited_id');
|
||||
});
|
||||
});
|
||||
|
||||
describe('convertEvent — message elements', () => {
|
||||
|
||||
@@ -2027,7 +2027,10 @@ describe('extended-actions / TierB ③ share + doubt + robot-option', () => {
|
||||
});
|
||||
|
||||
it('get_doubt_friends_add_request returns the mapped list', async () => {
|
||||
const list = [{ uid: 'u1', nick: 'A', source: 's', msg: 'm', reqTime: 123 }];
|
||||
const list = [{
|
||||
uid: 'u1', user_id: 10001, nick: 'A', source: 's', reason: '',
|
||||
msg: 'm', group_code: '', reqTime: 123,
|
||||
}];
|
||||
const getDoubtRequests = vi.fn(async () => list);
|
||||
const bridge = fakeBridge({ apis: { friend: { getDoubtRequests } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('get_doubt_friends_add_request', { count: 5 });
|
||||
@@ -2062,6 +2065,84 @@ describe('extended-actions / TierB ③ share + doubt + robot-option', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// ─── TierB ③: send_ark (图文 Ark 卡片, OIDB 0xdc2_34) ───
|
||||
|
||||
describe('extended-actions / send_tuwen_ark', () => {
|
||||
const arkParams = {
|
||||
title: '标题',
|
||||
desc: '描述',
|
||||
jump_url: 'https://example.com',
|
||||
};
|
||||
|
||||
it('routes to group when group_id is given (peerType=1)', async () => {
|
||||
const sendTuwenArk = vi.fn(async () => {});
|
||||
const bridge = fakeBridge({ apis: { contacts: { sendTuwenArk } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('send_tuwen_ark', {
|
||||
group_id: 12345,
|
||||
...arkParams,
|
||||
});
|
||||
expect(res).toMatchObject({ status: 'ok', retcode: 0, data: null });
|
||||
expect(sendTuwenArk).toHaveBeenCalledWith({
|
||||
targetId: 12345,
|
||||
peerType: 1,
|
||||
title: '标题',
|
||||
desc: '描述',
|
||||
summary: '[分享]',
|
||||
previewUrl: 'https://tangram-1251316161.file.myqcloud.com/files/20210721/e50a8e37e08f29bf1ffc7466e1950690.png',
|
||||
jumpUrl: 'https://example.com',
|
||||
});
|
||||
});
|
||||
|
||||
it('routes to C2C when user_id is given (peerType=0)', async () => {
|
||||
const sendTuwenArk = vi.fn(async () => {});
|
||||
const bridge = fakeBridge({ apis: { contacts: { sendTuwenArk } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('send_tuwen_ark', {
|
||||
user_id: 10001,
|
||||
...arkParams,
|
||||
});
|
||||
expect(res).toMatchObject({ status: 'ok', retcode: 0, data: null });
|
||||
expect(sendTuwenArk).toHaveBeenCalledWith({
|
||||
targetId: 10001,
|
||||
peerType: 0,
|
||||
title: '标题',
|
||||
desc: '描述',
|
||||
summary: '[分享]',
|
||||
previewUrl: 'https://tangram-1251316161.file.myqcloud.com/files/20210721/e50a8e37e08f29bf1ffc7466e1950690.png',
|
||||
jumpUrl: 'https://example.com',
|
||||
});
|
||||
});
|
||||
|
||||
it('prefers group_id over user_id when both are supplied', async () => {
|
||||
const sendTuwenArk = vi.fn(async () => {});
|
||||
const bridge = fakeBridge({ apis: { contacts: { sendTuwenArk } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('send_tuwen_ark', {
|
||||
group_id: 12345,
|
||||
user_id: 10001,
|
||||
...arkParams,
|
||||
});
|
||||
expect(res).toMatchObject({ status: 'ok' });
|
||||
expect(sendTuwenArk).toHaveBeenCalledWith(expect.objectContaining({ peerType: 1, targetId: 12345 }));
|
||||
});
|
||||
|
||||
it('rejects when neither user_id nor group_id is given', async () => {
|
||||
const sendTuwenArk = vi.fn();
|
||||
const bridge = fakeBridge({ apis: { contacts: { sendTuwenArk } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('send_tuwen_ark', { ...arkParams });
|
||||
expect(res).toMatchObject({ status: 'failed', retcode: 1400 });
|
||||
expect(sendTuwenArk).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('surfaces bridge errors as action_failed', async () => {
|
||||
const sendTuwenArk = vi.fn(async () => { throw new Error('oidb 0xdc2 rejected'); });
|
||||
const bridge = fakeBridge({ apis: { contacts: { sendTuwenArk } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('send_tuwen_ark', {
|
||||
group_id: 12345,
|
||||
...arkParams,
|
||||
});
|
||||
expect(res).toMatchObject({ status: 'failed', retcode: 100, wording: 'oidb 0xdc2 rejected' });
|
||||
});
|
||||
});
|
||||
|
||||
// ─── napcat-parity: get_qun_album_list (QQ NT AlbumService) ───
|
||||
describe('extended-actions / get_group_album_list', () => {
|
||||
it('returns the cover and last-upload metadata from the core facade', async () => {
|
||||
|
||||
@@ -63,6 +63,8 @@ describe('GroupRequestPoller', () => {
|
||||
groupId: 999,
|
||||
fromUin: 456,
|
||||
fromUid: 'inviter_uid',
|
||||
invitedUin: 123,
|
||||
invitedUid: 'target_uid',
|
||||
subType: 'invite',
|
||||
message: 'please',
|
||||
flag: 'slreq:1:42:999:2:0',
|
||||
|
||||
@@ -411,6 +411,34 @@ describe('buildApiContext setMsgEmojiLike', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildApiContext fetchEmojiLikeSummary', () => {
|
||||
it('returns every emoji on the message with cached users', async () => {
|
||||
const listUsers = vi.fn(() => [
|
||||
{ operatorUin: 20002, operatorUid: 'u_20002', setAt: 1_700_000_001 },
|
||||
]);
|
||||
const fetchReactionSummary = vi.fn(async () => [
|
||||
{ emojiId: '76', emojiType: 1, count: 1, lastReactionTime: 1_700_000_001 },
|
||||
]);
|
||||
const { api, metas } = makeRef({
|
||||
reactionStore: { listUsers, summarizeMessage: vi.fn(() => []) },
|
||||
apis: { interaction: { setReaction: vi.fn(), fetchReactionSummary } },
|
||||
});
|
||||
metas.set(-20, groupMeta({ targetId: 710301, sequence: 55 }));
|
||||
|
||||
await expect(api.fetchEmojiLikeSummary(-20)).resolves.toEqual([
|
||||
{
|
||||
emoji_id: '76',
|
||||
emoji_type: 1,
|
||||
count: 1,
|
||||
last_reaction_time: 1_700_000_001,
|
||||
users: [{ user_id: 20002 }],
|
||||
},
|
||||
]);
|
||||
expect(fetchReactionSummary).toHaveBeenCalledWith(710301, 55);
|
||||
expect(listUsers).toHaveBeenCalledWith(710301, 55, '76', 1000, 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildApiContext fetchEmojiLikeUsers', () => {
|
||||
it('throws when the message is missing', async () => {
|
||||
const { api } = makeRef();
|
||||
@@ -770,6 +798,12 @@ describe('buildApiContext contact reads', () => {
|
||||
long_nick: 'hello sign',
|
||||
qq_level: 17,
|
||||
level: 17,
|
||||
status: 0,
|
||||
extStatus: 0,
|
||||
ext_status: 0,
|
||||
batteryStatus: 0,
|
||||
customStatus: null,
|
||||
customStatusDescInfo: '',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -879,6 +913,8 @@ describe('buildApiContext contact reads', () => {
|
||||
request_id: 888,
|
||||
requester_uin: 20002,
|
||||
requester_nick: 'applicant',
|
||||
invitor_uin: 30003,
|
||||
invitor_nick: 'inviter',
|
||||
message: 'please add',
|
||||
checked: false,
|
||||
flag: 'slreq:1:888:710010:22:0',
|
||||
|
||||
@@ -27,7 +27,7 @@ function createControlPort(): {
|
||||
messages: MessageStoreMigrationWorkerMessage[];
|
||||
send(message: unknown): void;
|
||||
listenerCount(): number;
|
||||
} {
|
||||
} {
|
||||
const messages: MessageStoreMigrationWorkerMessage[] = [];
|
||||
const events = new EventEmitter();
|
||||
return {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/proto-defs",
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.12",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "SnowLuma QQ/Lagrange wire-protobuf type definitions. Pure TypeScript interfaces with proton's `pb<N, T>` marker types — `@snowluma/proton`'s vite plugin compiles them into zero-runtime encoder/decoder functions at the call sites in `@snowluma/core` (and any downstream consumer). Exposed as per-file subpaths (`@snowluma/proto-defs/oidb`, `@snowluma/proto-defs/message`, …) so the import-site shape mirrors the legacy `bridge/proto/proton/*` layout and avoids name collisions across files (notably `highway.ts` and `oidb-actions/media.ts` share NTV2-prefixed names).",
|
||||
|
||||
@@ -88,6 +88,7 @@ export interface Oidb0x89a_0HistoryVisibility {
|
||||
}
|
||||
// 0x89A_0 — one masked group-member capability update. These are deny bits,
|
||||
// so callers clear the selected bit to allow a capability and set it to deny.
|
||||
// Same settings tags as invite policy.
|
||||
export interface Oidb0x89a_0MemberPermissionSettings {
|
||||
appPrivilegeFlag?: pb_optional<23, uint_32>;
|
||||
appPrivilegeMask?: pb_optional<24, uint_32>;
|
||||
@@ -265,6 +266,10 @@ export interface OidbUserInfoResponse {
|
||||
export interface AvatarInfo {
|
||||
url?: pb<5, string>;
|
||||
}
|
||||
export interface OidbCustomStatus {
|
||||
faceId?: pb<1, uint_32>;
|
||||
msg?: pb<2, string>;
|
||||
}
|
||||
export interface OidbFriendListNumber {
|
||||
numbers?: pb_repeated<1, uint_32>;
|
||||
}
|
||||
@@ -357,8 +362,11 @@ export interface OidbGroupDetailFlags {
|
||||
uin?: pb<21, bool>;
|
||||
lastSequence?: pb<22, bool>;
|
||||
lastMessageTime?: pb<23, bool>;
|
||||
question?: pb<24, bool>;
|
||||
answer?: pb<25, string>;
|
||||
// EncodeSingleGroupInfoParamByBaseFilter writes these as empty strings
|
||||
// (length-delimited). A bool true is a different wire type and the
|
||||
// server ignores it; a plain pb<> empty string is omitted.
|
||||
question?: pb_optional<24, string>;
|
||||
answer?: pb_optional<25, string>;
|
||||
maxAdminCount?: pb<29, string>;
|
||||
// Official request mask for group shutup expire (proto tag 45 → 60027).
|
||||
// Lagrange's tag 59 requests 60259, which is a different field.
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// reads {1:bussness_error_code, 5:ark_json}.
|
||||
// Both return a server-built ark JSON string (the share card payload).
|
||||
|
||||
import type { pb, uint_32 } from '@snowluma/proton';
|
||||
import type { pb, pb_optional, uint_32 } from '@snowluma/proton';
|
||||
|
||||
export interface OidbBuddyRecommendArkReq {
|
||||
uin?: pb<1, uint_32>;
|
||||
@@ -28,3 +28,43 @@ export interface OidbGroupRecommendArkResp {
|
||||
errCode?: pb<1, uint_32>;
|
||||
arkJson?: pb<5, string>;
|
||||
}
|
||||
|
||||
// 0xdc2_34 — send a custom 图文 (URL-share) ark card to a C2C peer or group.
|
||||
// Field layout RE'd from QQ Android 9.3.25 captures. Default SSO: OidbSvcTrpcTcp.0xdc2_34.
|
||||
// appId = 100446242 is fixed for this ark type.
|
||||
// targetId (UIN or group_id) appears at AppInfo[11] AND Meta[2].
|
||||
// Meta.peerType: 0 = C2C, 1 = group.
|
||||
// peerType, field3, and previewUrl are pb_optional — proton preserves 0/empty on wire.
|
||||
export interface Oidb0xdc2CardField5 {
|
||||
field1?: pb<1, uint_32>;
|
||||
}
|
||||
|
||||
export interface Oidb0xdc2CardContent {
|
||||
flag?: pb<1, uint_32>;
|
||||
title?: pb<10, string>;
|
||||
desc?: pb<11, string>;
|
||||
summary?: pb<12, string>;
|
||||
jumpUrl?: pb<13, string>;
|
||||
previewUrl?: pb_optional<14, string>;
|
||||
}
|
||||
|
||||
export interface Oidb0xdc2AppInfo {
|
||||
appId?: pb<1, uint_32>;
|
||||
field2?: pb<2, uint_32>;
|
||||
field3?: pb_optional<3, uint_32>;
|
||||
field5?: pb<5, Oidb0xdc2CardField5>;
|
||||
targetId?: pb<11, uint_32>;
|
||||
content?: pb<12, Oidb0xdc2CardContent>;
|
||||
}
|
||||
|
||||
export interface Oidb0xdc2Meta {
|
||||
peerType?: pb_optional<1, uint_32>;
|
||||
targetId?: pb<2, uint_32>;
|
||||
}
|
||||
|
||||
export interface Oidb0xdc2_34Req {
|
||||
appInfo?: pb<1, Oidb0xdc2AppInfo>;
|
||||
meta?: pb<2, Oidb0xdc2Meta>;
|
||||
}
|
||||
|
||||
export interface Oidb0xdc2_34Resp {}
|
||||
@@ -27,11 +27,17 @@ export interface OidbDoubtGetReq {
|
||||
}
|
||||
|
||||
export interface OidbDoubtItem {
|
||||
uid?: pb<1, string>; // HIGH (kStrTargetUid)
|
||||
nick?: pb<2, string>; // MEDIUM (generic Nick attr 20002)
|
||||
source?: pb<5, string>; // MEDIUM
|
||||
reqTime?: pb<9, uint_64>; // HIGH (attr 60001)
|
||||
msg?: pb<11, string>; // MEDIUM
|
||||
uid?: pb<1, string>;
|
||||
nick?: pb<2, string>;
|
||||
age?: pb<3, uint_32>;
|
||||
sex?: pb<4, uint_32>;
|
||||
msg?: pb<5, string>;
|
||||
source?: pb<6, string>;
|
||||
reason?: pb<7, string>;
|
||||
uin?: pb<8, uint_64>;
|
||||
reqTime?: pb<9, uint_64>;
|
||||
commFriendNum?: pb<10, uint_32>;
|
||||
groupCode?: pb<11, string>;
|
||||
}
|
||||
export interface OidbDoubtGetRespBody {
|
||||
list?: pb_repeated<1, OidbDoubtItem>;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/protocol",
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.12",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "SnowLuma protocol — the protocol-layer between QQ wire bytes and typed events. Owns: identity service (uid↔uin cache with SQLite persistence), event bus, packet pipeline (incoming SSO packet → QQEventVariant), msg-push decoders, element-builder (MessageElement → wire elems[]), highway upload protocol (file/image/video/ptt), OIDB envelope helper, and the event/notice/request type vocabulary. Consumers (@snowluma/core, @snowluma/onebot) talk to this package through `BridgeContext` for runtime calls and the standalone classes (IdentityService, BridgeEventBus, IncomingPacketPipeline) for composition. Per-file subpath exports mirror the legacy `core/src/bridge/*` layout 1:1 so the previous `import { …} from '../bridge/<x>'` collapses to `import { … } from '@snowluma/protocol/<x>'`.",
|
||||
|
||||
@@ -391,6 +391,11 @@ export interface GroupInviteEvent extends QQEvent {
|
||||
groupId: number;
|
||||
fromUin: number;
|
||||
fromUid?: string;
|
||||
/** Person being invited. Present on admin-side invitation notices
|
||||
* and on the pending-request list; for a self-invite this is the
|
||||
* logged-in account. */
|
||||
invitedUin?: number;
|
||||
invitedUid?: string;
|
||||
subType: string;
|
||||
message: string;
|
||||
flag: string;
|
||||
|
||||
@@ -283,8 +283,12 @@ export function formatEvent(identity: IdentityService, event: QQEventVariant): s
|
||||
return `群戳 ${formatGroup(identity, event.groupId)} | ${formatUser(identity, event.groupId, event.userUin)} -> ${formatUser(identity, event.groupId, event.targetUin)}`;
|
||||
case 'friend_request':
|
||||
return `好友请求 ${formatUser(identity, undefined, event.fromUin)}: ${event.message}`;
|
||||
case 'group_invite':
|
||||
return `群邀请 ${formatUser(identity, undefined, event.fromUin)} -> ${formatGroup(identity, event.groupId)}`;
|
||||
case 'group_invite': {
|
||||
const invitee = event.invitedUin && event.invitedUin > 0
|
||||
? ` 邀 ${formatUser(identity, event.groupId, event.invitedUin, event.invitedUid)}`
|
||||
: '';
|
||||
return `群邀请 ${formatUser(identity, undefined, event.fromUin)}${invitee} -> ${formatGroup(identity, event.groupId)}`;
|
||||
}
|
||||
case 'group_essence':
|
||||
return `精华 ${formatGroup(identity, event.groupId)} | ${event.set ? '+' : '-'}精华`;
|
||||
case 'group_msg_emoji_like':
|
||||
|
||||
@@ -36,6 +36,8 @@ export const decodeGroupInvitation: MsgPushDecoder = (ctx) => {
|
||||
groupId: inner.groupUin ?? 0,
|
||||
fromUin: resolveUidToUin(ctx.identity, inner.groupUin ?? 0, inner.invitorUid ?? ''),
|
||||
fromUid: inner.invitorUid ?? '',
|
||||
invitedUin: resolveUidToUin(ctx.identity, inner.groupUin ?? 0, inner.targetUid ?? ''),
|
||||
invitedUid: inner.targetUid ?? '',
|
||||
subType: 'invite',
|
||||
message: '',
|
||||
flag: 'invite:' + (inner.groupUin ?? 0) + ':' + (inner.invitorUid ?? ''),
|
||||
@@ -53,6 +55,7 @@ export const decodeGroupInvite: MsgPushDecoder = (ctx) => {
|
||||
groupId: invite.groupUin ?? 0,
|
||||
fromUin: resolveUidToUin(ctx.identity, invite.groupUin ?? 0, invite.invitorUid ?? ''),
|
||||
fromUid: invite.invitorUid ?? '',
|
||||
invitedUin: ctx.selfUin,
|
||||
subType: 'invite',
|
||||
message: '',
|
||||
flag: 'invite:' + (invite.groupUin ?? 0) + ':' + (invite.invitorUid ?? ''),
|
||||
|
||||
@@ -31,7 +31,7 @@ export namespace FetchGroupDetail {
|
||||
flags: {
|
||||
ownerUid: on, createTime: on, maxMemberCount: on, memberCount: on,
|
||||
level: on, name: '', noticePreview: '', uin: on, lastSequence: on,
|
||||
lastMessageTime: on, question: on, answer: '', maxAdminCount: '',
|
||||
lastMessageTime: on, question: '', answer: '', maxAdminCount: '',
|
||||
// Tag 45 (not Lagrange's 59): official request mask for 60027.
|
||||
shutUpAllTimestamp: on, addType: on, privilegeFlag: on, groupFlagExt4: on,
|
||||
noFingerOpen: on, noCodeFingerOpen: on,
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
// 0x10C0 — fetch pending group-add requests.
|
||||
// subCommand 1 = main inbox, 2 = filtered (low-priority) inbox
|
||||
//
|
||||
// Current QQ uses the UIN-form envelope for its native list path. The server
|
||||
// changes user field 1 from a UID string to a numeric UIN when that envelope
|
||||
// bit changes, so the two forms deliberately have separate decoders below.
|
||||
// The UID form remains necessary for correlating UID-only real-time pushes.
|
||||
// Current QQ uses the UIN-form envelope for the native list path, but the
|
||||
// per-user record still carries a string account on field 1. Decode both
|
||||
// shapes and merge so neither identifier is dropped. The UID-form request
|
||||
// remains necessary for correlating UID-only real-time pushes.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type {
|
||||
OidbBase,
|
||||
OidbSvcTrpcTcp0x10C0Response,
|
||||
OidbSvcTrpcTcp0x10C0ResponseByUin,
|
||||
OidbSvcTrpcTcp0x10C0ResponseRequest,
|
||||
OidbSvcTrpcTcp0x10C0ResponseRequestByUin,
|
||||
OidbSvcTrpcTcp0x10C0ResponseUser,
|
||||
OidbSvcTrpcTcp0x10C0ResponseUserByUin,
|
||||
} from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbGroupRequestList } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
@@ -24,9 +28,92 @@ const GROUP_REQUEST_OPERATION_TYPE = new Map<number, number>([
|
||||
[6, 35], [7, 1], [8, 3], [9, 6], [10, 7], [11, 13],
|
||||
[12, 15], [13, 16], [14, 17], [15, 19], [16, 8], [17, 100],
|
||||
]);
|
||||
const GROUP_REQUEST_OPERATION_OUTPUT = new Set(GROUP_REQUEST_OPERATION_TYPE.values());
|
||||
|
||||
export function groupRequestOperationType(notifyType: number): number | null {
|
||||
return GROUP_REQUEST_OPERATION_TYPE.get(notifyType) ?? null;
|
||||
const mapped = GROUP_REQUEST_OPERATION_TYPE.get(notifyType);
|
||||
if (mapped !== undefined) return mapped;
|
||||
// Some list replies already carry the mapped discriminator (e.g. 22).
|
||||
if (GROUP_REQUEST_OPERATION_OUTPUT.has(notifyType)) return notifyType;
|
||||
return null;
|
||||
}
|
||||
|
||||
export interface DecodedGroupRequestUser {
|
||||
uid: string;
|
||||
uin: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface DecodedGroupRequest {
|
||||
sequence?: bigint;
|
||||
eventType?: number;
|
||||
state?: number;
|
||||
group?: { groupUin?: number; groupName?: string };
|
||||
target?: DecodedGroupRequestUser;
|
||||
invitor?: DecodedGroupRequestUser;
|
||||
operatorUser?: DecodedGroupRequestUser;
|
||||
comment?: string;
|
||||
operateTransInfo?: Uint8Array;
|
||||
}
|
||||
|
||||
export interface DecodedGroupRequestList {
|
||||
requests?: DecodedGroupRequest[];
|
||||
field2?: bigint;
|
||||
newLatestSeq?: bigint;
|
||||
field4?: number;
|
||||
field5?: bigint;
|
||||
field6?: number;
|
||||
}
|
||||
|
||||
function mergeRequestUser(
|
||||
byUin?: OidbSvcTrpcTcp0x10C0ResponseUserByUin,
|
||||
byUid?: OidbSvcTrpcTcp0x10C0ResponseUser,
|
||||
): DecodedGroupRequestUser {
|
||||
return {
|
||||
uid: byUid?.uid ?? '',
|
||||
uin: byUin?.uin ?? 0,
|
||||
name: (byUin?.name || byUid?.name) ?? '',
|
||||
};
|
||||
}
|
||||
|
||||
function mergeRequestItem(
|
||||
byUin?: OidbSvcTrpcTcp0x10C0ResponseRequestByUin,
|
||||
byUid?: OidbSvcTrpcTcp0x10C0ResponseRequest,
|
||||
): DecodedGroupRequest {
|
||||
const src = byUin ?? byUid;
|
||||
return {
|
||||
sequence: src?.sequence,
|
||||
eventType: src?.eventType,
|
||||
state: src?.state,
|
||||
group: src?.group,
|
||||
target: mergeRequestUser(byUin?.target, byUid?.target),
|
||||
invitor: mergeRequestUser(byUin?.invitor, byUid?.invitor),
|
||||
operatorUser: mergeRequestUser(byUin?.operatorUser, byUid?.operatorUser),
|
||||
comment: src?.comment ?? '',
|
||||
operateTransInfo: src?.operateTransInfo,
|
||||
};
|
||||
}
|
||||
|
||||
function mergeRequestList(
|
||||
byUin?: OidbSvcTrpcTcp0x10C0ResponseByUin,
|
||||
byUid?: OidbSvcTrpcTcp0x10C0Response,
|
||||
): DecodedGroupRequestList {
|
||||
const src = byUin ?? byUid;
|
||||
const uinItems = byUin?.requests ?? [];
|
||||
const uidItems = byUid?.requests ?? [];
|
||||
const count = Math.max(uinItems.length, uidItems.length);
|
||||
const requests: DecodedGroupRequest[] = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
requests.push(mergeRequestItem(uinItems[i], uidItems[i]));
|
||||
}
|
||||
return {
|
||||
requests,
|
||||
field2: src?.field2,
|
||||
newLatestSeq: src?.newLatestSeq,
|
||||
field4: src?.field4,
|
||||
field5: src?.field5,
|
||||
field6: src?.field6,
|
||||
};
|
||||
}
|
||||
|
||||
export namespace FetchGroupRequests {
|
||||
@@ -51,15 +138,21 @@ export namespace FetchGroupRequests {
|
||||
field2: p.cursor ?? 0n,
|
||||
});
|
||||
|
||||
export const deserialize = (_ctx: Deps, body: OidbSvcTrpcTcp0x10C0ResponseByUin): OidbSvcTrpcTcp0x10C0ResponseByUin => body;
|
||||
export const deserialize = (_ctx: Deps, body: DecodedGroupRequestList): DecodedGroupRequestList => body;
|
||||
|
||||
export const encode = (env: OidbBase<OidbGroupRequestList>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbGroupRequestList>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbSvcTrpcTcp0x10C0ResponseByUin> =>
|
||||
protobuf_decode<OidbBase<OidbSvcTrpcTcp0x10C0ResponseByUin>>(bytes);
|
||||
export const decode = (bytes: Uint8Array): OidbBase<DecodedGroupRequestList> => {
|
||||
const byUin = protobuf_decode<OidbBase<OidbSvcTrpcTcp0x10C0ResponseByUin>>(bytes);
|
||||
const byUid = protobuf_decode<OidbBase<OidbSvcTrpcTcp0x10C0Response>>(bytes);
|
||||
return {
|
||||
...byUin,
|
||||
body: mergeRequestList(byUin.body, byUid.body),
|
||||
};
|
||||
};
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<OidbSvcTrpcTcp0x10C0ResponseByUin> =>
|
||||
export const invoke = (deps: Deps, params: Params): Promise<DecodedGroupRequestList> =>
|
||||
invokeOidb(deps, FetchGroupRequests, params);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import type {
|
||||
OidbUserInfoResponse,
|
||||
} from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import type { UserProfileInfo } from '../../qq-info';
|
||||
import { applyOnlineStatus } from './fetch-user-profile';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
const REQUESTED_KEYS = [
|
||||
@@ -83,6 +84,7 @@ export namespace FetchUserProfileByUid {
|
||||
info.sex = sexNum === 1 ? 'male' : sexNum === 2 ? 'female' : 'unknown';
|
||||
info.age = numMap.get(20037) ?? 0;
|
||||
info.level = numMap.get(105) ?? 0;
|
||||
applyOnlineStatus(info, bytesMap, numMap);
|
||||
}
|
||||
|
||||
return info;
|
||||
|
||||
@@ -21,12 +21,37 @@ import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type {
|
||||
AvatarInfo,
|
||||
OidbCustomStatus,
|
||||
OidbUserInfoRequest,
|
||||
OidbUserInfoResponse,
|
||||
} from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import type { UserProfileInfo } from '../../qq-info';
|
||||
import { unpackStatusWord } from '../extras/get-stranger-status';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
export function applyOnlineStatus(
|
||||
info: UserProfileInfo,
|
||||
bytesMap: Map<number, Uint8Array>,
|
||||
numMap: Map<number, number>,
|
||||
): void {
|
||||
const statusRaw = numMap.get(27372);
|
||||
if (statusRaw !== undefined) {
|
||||
const unpacked = unpackStatusWord(statusRaw);
|
||||
info.status = unpacked.status;
|
||||
info.extStatus = unpacked.ext_status;
|
||||
info.batteryStatus = 0;
|
||||
}
|
||||
const customBytes = bytesMap.get(27406);
|
||||
if (customBytes && customBytes.length > 0) {
|
||||
const custom = protobuf_decode<OidbCustomStatus>(customBytes);
|
||||
info.customStatus = {
|
||||
faceId: custom.faceId ?? 0,
|
||||
wording: custom.msg ?? '',
|
||||
};
|
||||
info.customStatusDesc = custom.msg ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
const REQUESTED_KEYS = [
|
||||
20002, 27394, 20009, 20031, 101, 103, 102, 20020, 20003, 20026,
|
||||
105, 27372, 27406, 20037,
|
||||
@@ -90,6 +115,7 @@ export namespace FetchUserProfile {
|
||||
info.sex = sexNum === 1 ? 'male' : sexNum === 2 ? 'female' : 'unknown';
|
||||
info.age = numMap.get(20037) ?? 0;
|
||||
info.level = numMap.get(105) ?? 0;
|
||||
applyOnlineStatus(info, bytesMap, numMap);
|
||||
}
|
||||
|
||||
return info;
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
// 0xdc2_34 — send a custom 图文 (URL-share) ark card to a C2C peer or group.
|
||||
// RE'd from QQ Android 9.3.25 captures. Default SSO: OidbSvcTrpcTcp.0xdc2_34.
|
||||
// Fixed fields: appId = 100446242, field2 = 1, field3 = 0, field5 = {1:1}
|
||||
// targetId appears at AppInfo[11] and Meta[2]; Meta.peerType: 0=C2C, 1=group.
|
||||
// peerType, field3, and previewUrl are pb_optional — proton preserves 0/empty on wire.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type {
|
||||
Oidb0xdc2_34Req,
|
||||
Oidb0xdc2_34Resp,
|
||||
} from '@snowluma/proto-defs/oidb-actions/contact-ark';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
const TUWEN_ARK_APPID = 100446242;
|
||||
|
||||
export type SendTuwenArkParams = {
|
||||
targetId: number;
|
||||
peerType: 0 | 1;
|
||||
title: string;
|
||||
desc: string;
|
||||
summary: string;
|
||||
jumpUrl: string;
|
||||
previewUrl: string;
|
||||
};
|
||||
|
||||
export namespace SendTuwenArk {
|
||||
export const command = 0xDC2;
|
||||
export const subCommand = 34;
|
||||
export const uinForm = false;
|
||||
|
||||
export type Params = SendTuwenArkParams;
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (_ctx: Deps, p: Params): Oidb0xdc2_34Req => ({
|
||||
appInfo: {
|
||||
appId: TUWEN_ARK_APPID,
|
||||
field2: 1,
|
||||
field3: 0,
|
||||
field5: { field1: 1 },
|
||||
targetId: p.targetId,
|
||||
content: {
|
||||
flag: 1,
|
||||
title: p.title,
|
||||
desc: p.desc,
|
||||
summary: p.summary,
|
||||
jumpUrl: p.jumpUrl,
|
||||
previewUrl: p.previewUrl,
|
||||
},
|
||||
},
|
||||
meta: {
|
||||
peerType: p.peerType,
|
||||
targetId: p.targetId,
|
||||
},
|
||||
});
|
||||
|
||||
export const deserialize = (_ctx: Deps, _body: Oidb0xdc2_34Resp): void => undefined;
|
||||
|
||||
export const encode = (env: OidbBase<Oidb0xdc2_34Req>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<Oidb0xdc2_34Req>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<Oidb0xdc2_34Resp> =>
|
||||
protobuf_decode<OidbBase<Oidb0xdc2_34Resp>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> =>
|
||||
invokeOidb(deps, SendTuwenArk, params);
|
||||
}
|
||||
@@ -16,6 +16,15 @@ export interface StrangerStatus {
|
||||
ext_status: number;
|
||||
}
|
||||
|
||||
export function unpackStatusWord(raw: bigint | number): { status: number; ext_status: number } {
|
||||
const extBig = typeof raw === 'bigint' ? raw : BigInt(raw);
|
||||
if (extBig <= 10n) {
|
||||
return { status: Number(extBig) * 10, ext_status: 0 };
|
||||
}
|
||||
const status = Number((extBig & 0xff00n) + ((extBig >> 16n) & 0xffn));
|
||||
return { status: 10, ext_status: status };
|
||||
}
|
||||
|
||||
const STATUS_PROPERTY_KEY = 27372;
|
||||
|
||||
export namespace GetStrangerStatus {
|
||||
@@ -39,12 +48,7 @@ export namespace GetStrangerStatus {
|
||||
?.find((entry) => entry.key === STATUS_PROPERTY_KEY)
|
||||
?.value;
|
||||
if (raw === undefined || raw === null) return null;
|
||||
const extBig = typeof raw === 'bigint' ? raw : BigInt(raw);
|
||||
if (extBig <= 10n) {
|
||||
return { status: Number(extBig) * 10, ext_status: 0 };
|
||||
}
|
||||
const status = Number((extBig & 0xff00n) + ((extBig >> 16n) & 0xffn));
|
||||
return { status: 10, ext_status: status };
|
||||
return unpackStatusWord(raw);
|
||||
};
|
||||
|
||||
export const encode = (env: OidbBase<OidbStrangerStatusReq>): Uint8Array =>
|
||||
|
||||
@@ -7,19 +7,31 @@
|
||||
// uid (tag1) and reqTime (tag9) are HIGH confidence.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { pb, pb_repeated, uint_32, uint_64 } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type {
|
||||
OidbDoubtGetReq, OidbDoubtGetResp,
|
||||
} from '@snowluma/proto-defs/oidb-actions/doubt-buddy';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
interface OidbDoubtItemAccountOnTag1 {
|
||||
uin?: pb<1, uint_64>;
|
||||
}
|
||||
interface OidbDoubtGetRespAccountOnTag1 {
|
||||
status?: pb<1, uint_32>;
|
||||
body?: pb<2, { list?: pb_repeated<1, OidbDoubtItemAccountOnTag1> }>;
|
||||
}
|
||||
|
||||
export interface DoubtBuddyRequest {
|
||||
[key: string]: import('@snowluma/common/json').JsonValue;
|
||||
/** Opaque uid — pass back as `flag` to set_doubt_friends_add_request. */
|
||||
uid: string;
|
||||
user_id: number;
|
||||
nick: string;
|
||||
source: string;
|
||||
reason: string;
|
||||
msg: string;
|
||||
group_code: string;
|
||||
reqTime: number;
|
||||
}
|
||||
|
||||
@@ -39,17 +51,32 @@ export namespace GetDoubtBuddyReq {
|
||||
export const deserialize = (_ctx: Deps, body: OidbDoubtGetResp): DoubtBuddyRequest[] =>
|
||||
(body.body?.list ?? []).map((it) => ({
|
||||
uid: it.uid ?? '',
|
||||
user_id: Number(it.uin ?? 0),
|
||||
nick: it.nick ?? '',
|
||||
source: it.source ?? '',
|
||||
reason: it.reason ?? '',
|
||||
msg: it.msg ?? '',
|
||||
group_code: it.groupCode ?? '',
|
||||
reqTime: Number(it.reqTime ?? 0),
|
||||
}));
|
||||
|
||||
export const encode = (env: OidbBase<OidbDoubtGetReq>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbDoubtGetReq>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbDoubtGetResp> =>
|
||||
protobuf_decode<OidbBase<OidbDoubtGetResp>>(bytes);
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbDoubtGetResp> => {
|
||||
const decoded = protobuf_decode<OidbBase<OidbDoubtGetResp>>(bytes);
|
||||
const numeric = protobuf_decode<OidbBase<OidbDoubtGetRespAccountOnTag1>>(bytes);
|
||||
const items = decoded.body?.body?.list ?? [];
|
||||
const numericItems = numeric.body?.body?.list ?? [];
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
if (!item) continue;
|
||||
if ((item.uin ?? 0n) === 0n && numericItems[i]?.uin) {
|
||||
item.uin = numericItems[i]!.uin;
|
||||
}
|
||||
}
|
||||
return decoded;
|
||||
};
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<DoubtBuddyRequest[]> =>
|
||||
invokeOidb(deps, GetDoubtBuddyReq, params);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// 0x89A_0 — update one member capability through the appPrivilegeFlag deny
|
||||
// bits. Current QQ applies one selected mask per operation; callers that change
|
||||
// multiple capabilities must invoke this namespace sequentially.
|
||||
// bits. Invite policy shares the same settings tags; album / temporary-session
|
||||
// / create-group writes use the same command with a narrower mask. Current QQ
|
||||
// applies one selected mask per operation; callers that change multiple
|
||||
// capabilities must invoke this namespace sequentially.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
|
||||
@@ -19,6 +19,7 @@ export namespace SetProfile {
|
||||
export interface Params {
|
||||
nickname?: string;
|
||||
personalNote?: string;
|
||||
sex?: number;
|
||||
}
|
||||
|
||||
/** Needs identity to read `uin` for the request body. */
|
||||
@@ -26,9 +27,15 @@ export namespace SetProfile {
|
||||
|
||||
export const serialize = (ctx: Deps, p: Params): OidbSetProfile => {
|
||||
const stringProfiles: { fieldId: number; value: string }[] = [];
|
||||
const intProfiles: { fieldId: number; value: bigint }[] = [];
|
||||
if (p.nickname !== undefined) stringProfiles.push({ fieldId: 20002, value: p.nickname });
|
||||
if (p.personalNote !== undefined) stringProfiles.push({ fieldId: 102, value: p.personalNote });
|
||||
return { uin: BigInt(ctx.identity.uin), stringProfiles };
|
||||
if (p.sex !== undefined) intProfiles.push({ fieldId: 20009, value: BigInt(p.sex) });
|
||||
return {
|
||||
uin: BigInt(ctx.identity.uin),
|
||||
...(stringProfiles.length > 0 ? { stringProfiles } : {}),
|
||||
...(intProfiles.length > 0 ? { intProfiles } : {}),
|
||||
};
|
||||
};
|
||||
|
||||
export const deserialize = (_ctx: Deps, _: Oidb0x112aResp): void => {};
|
||||
@@ -42,7 +49,11 @@ export namespace SetProfile {
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> => {
|
||||
// No-op when there's nothing to write — preserves the facade's
|
||||
// historic short-circuit (avoid a wasted SSO round-trip).
|
||||
if (params.nickname === undefined && params.personalNote === undefined) {
|
||||
if (
|
||||
params.nickname === undefined
|
||||
&& params.personalNote === undefined
|
||||
&& params.sex === undefined
|
||||
) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return invokeOidb(deps, SetProfile, params);
|
||||
|
||||
@@ -496,6 +496,12 @@ export class IncomingPacketPipeline {
|
||||
event.message = requestR.value.comment;
|
||||
|
||||
const request = requestR.value;
|
||||
if (subType === 'invite' && request.targetUid) {
|
||||
if (!event.invitedUid) event.invitedUid = request.targetUid;
|
||||
if ((event.invitedUin ?? 0) <= 0 && request.targetUin > 0) {
|
||||
event.invitedUin = request.targetUin;
|
||||
}
|
||||
}
|
||||
const hasApprovalTuple = Number.isSafeInteger(request.sequence) && request.sequence > 0
|
||||
&& Number.isSafeInteger(request.groupId) && request.groupId > 0
|
||||
&& Number.isSafeInteger(request.eventType) && request.eventType > 0;
|
||||
@@ -534,6 +540,17 @@ export class IncomingPacketPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
if ((event.invitedUin ?? 0) <= 0 && event.invitedUid) {
|
||||
try {
|
||||
const invited = await this.deps.identity.resolveUin(event.invitedUid, event.groupId);
|
||||
if (invited !== null && invited > 0) event.invitedUin = invited;
|
||||
} catch (error) {
|
||||
this.log.warn('failed to resolve invited account: groupId=%d uid=%s err=%s',
|
||||
event.groupId, event.invitedUid,
|
||||
error instanceof Error ? error.message : String(error));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return this.dispatchEvent(pkt, event, 'enriched');
|
||||
} catch (error) {
|
||||
@@ -724,6 +741,16 @@ export class IncomingPacketPipeline {
|
||||
uin: uinForCache,
|
||||
source: 'group_request',
|
||||
});
|
||||
if (event.invitedUid) {
|
||||
const invitedUin = event.invitedUin && event.invitedUin !== event.groupId
|
||||
? event.invitedUin : 0;
|
||||
this.deps.identity.rememberRequestIdentity({
|
||||
groupId: event.groupId,
|
||||
uid: event.invitedUid,
|
||||
uin: invitedUin,
|
||||
source: 'group_request',
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -12,6 +12,11 @@ export interface UserProfileInfo {
|
||||
* Already requested in `fetchUserProfile` keys[]; LagrangeV2
|
||||
* `FetchStrangerService.cs` confirms `// Level`. */
|
||||
level: number;
|
||||
status?: number;
|
||||
extStatus?: number;
|
||||
batteryStatus?: number;
|
||||
customStatus?: { faceId: number; wording: string } | null;
|
||||
customStatusDesc?: string;
|
||||
}
|
||||
|
||||
export interface FriendInfo {
|
||||
|
||||
@@ -613,6 +613,13 @@ describe('formatEvent', () => {
|
||||
fromUin: 30001,
|
||||
groupId: 778899,
|
||||
} as QQEventVariant)).toBe('群邀请 [惊蛰(30001)] -> [雪夜茶话(778899)]');
|
||||
|
||||
expect(formatEvent(identity, {
|
||||
kind: 'group_invite',
|
||||
fromUin: 30001,
|
||||
invitedUin: 30002,
|
||||
groupId: 778899,
|
||||
} as QQEventVariant)).toBe('群邀请 [惊蛰(30001)] 邀 [白露(30002)] -> [雪夜茶话(778899)]');
|
||||
});
|
||||
|
||||
it('renders group_essence set and unset', () => {
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import type { GroupInvitation, GroupInvite } from '@snowluma/proto-defs/notify';
|
||||
import { protobuf_encode } from '@snowluma/proton';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { IdentityService } from '../../src/identity-service';
|
||||
import type { MsgPushContext } from '../../src/msg-push/context';
|
||||
import {
|
||||
decodeGroupInvitation,
|
||||
decodeGroupInvite,
|
||||
} from '../../src/msg-push/decoders/group-join-request';
|
||||
|
||||
const SELF_UIN = 10001;
|
||||
const GROUP_ID = 12345;
|
||||
|
||||
function ctx(content: Uint8Array, identity = IdentityService.memory(String(SELF_UIN))): MsgPushContext {
|
||||
return {
|
||||
head: {
|
||||
msgType: 33, subType: 0, c2cCmd: 0, sequence: 1, ntMsgSeq: 0,
|
||||
timestamp: 1_710_000_000, msgId: 1,
|
||||
},
|
||||
fromUin: GROUP_ID,
|
||||
fromUid: '',
|
||||
selfUin: SELF_UIN,
|
||||
content,
|
||||
body: undefined,
|
||||
responseHead: undefined,
|
||||
identity,
|
||||
isHistorical: false,
|
||||
};
|
||||
}
|
||||
|
||||
describe('group invitation push carries the invitee (#394)', () => {
|
||||
it('keeps the inviter as from* and the invitee as invited*', () => {
|
||||
const identity = IdentityService.memory(String(SELF_UIN));
|
||||
identity.rememberRequestIdentity({ uid: 'u_inviter', uin: 456, source: 'group_request' });
|
||||
identity.rememberRequestIdentity({ uid: 'u_invitee', uin: 789, source: 'group_request' });
|
||||
const content = protobuf_encode<GroupInvitation>({
|
||||
cmd: 87,
|
||||
info: {
|
||||
inner: {
|
||||
groupUin: GROUP_ID,
|
||||
targetUid: 'u_invitee',
|
||||
invitorUid: 'u_inviter',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const [event] = decodeGroupInvitation(ctx(content, identity));
|
||||
expect(event).toMatchObject({
|
||||
kind: 'group_invite',
|
||||
groupId: GROUP_ID,
|
||||
fromUin: 456,
|
||||
fromUid: 'u_inviter',
|
||||
invitedUin: 789,
|
||||
invitedUid: 'u_invitee',
|
||||
subType: 'invite',
|
||||
});
|
||||
});
|
||||
|
||||
it('treats a self-invite as inviting the logged-in account', () => {
|
||||
const content = protobuf_encode<GroupInvite>({
|
||||
groupUin: GROUP_ID,
|
||||
invitorUid: 'u_inviter',
|
||||
});
|
||||
|
||||
const [event] = decodeGroupInvite(ctx(content));
|
||||
expect(event).toMatchObject({
|
||||
kind: 'group_invite',
|
||||
fromUid: 'u_inviter',
|
||||
invitedUin: SELF_UIN,
|
||||
subType: 'invite',
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -923,153 +923,153 @@ describe('decodeRichBody / unknown wire element observability', () => {
|
||||
}));
|
||||
});
|
||||
|
||||
function ntImageElem(fileName: string): Elem {
|
||||
const msgInfo: MsgInfo = {
|
||||
msgInfoBody: [{
|
||||
index: {
|
||||
info: {
|
||||
fileSize: 10711,
|
||||
fileHash: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
||||
fileSha1: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
|
||||
fileName,
|
||||
width: 1080,
|
||||
height: 1080,
|
||||
type: { picFormat: 1001 },
|
||||
function ntImageElem(fileName: string): Elem {
|
||||
const msgInfo: MsgInfo = {
|
||||
msgInfoBody: [{
|
||||
index: {
|
||||
info: {
|
||||
fileSize: 10711,
|
||||
fileHash: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
||||
fileSha1: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
|
||||
fileName,
|
||||
width: 1080,
|
||||
height: 1080,
|
||||
type: { picFormat: 1001 },
|
||||
},
|
||||
},
|
||||
picture: {
|
||||
urlPath: '/download?appid=1407&fileid=EhRgood',
|
||||
domain: 'multimedia.nt.qq.com.cn',
|
||||
ext: { originalParameter: '&rkey=good' },
|
||||
},
|
||||
}],
|
||||
extBizInfo: { pic: { bizType: 0, textSummary: '[图片]' } },
|
||||
};
|
||||
return {
|
||||
commonElem: {
|
||||
serviceType: 48,
|
||||
businessType: 20,
|
||||
pbElem: protobuf_encode<MsgInfo>(msgInfo),
|
||||
},
|
||||
picture: {
|
||||
urlPath: '/download?appid=1407&fileid=EhRgood',
|
||||
domain: 'multimedia.nt.qq.com.cn',
|
||||
ext: { originalParameter: '&rkey=good' },
|
||||
};
|
||||
}
|
||||
|
||||
function customFaceElem(filePath: string, origUrl: string, md5: Uint8Array): Elem {
|
||||
return {
|
||||
customFace: {
|
||||
filePath,
|
||||
origUrl,
|
||||
md5,
|
||||
size: 10711,
|
||||
width: 1080,
|
||||
height: 1080,
|
||||
},
|
||||
}],
|
||||
extBizInfo: { pic: { bizType: 0, textSummary: '[图片]' } },
|
||||
};
|
||||
return {
|
||||
commonElem: {
|
||||
serviceType: 48,
|
||||
businessType: 20,
|
||||
pbElem: protobuf_encode<MsgInfo>(msgInfo),
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function customFaceElem(filePath: string, origUrl: string, md5: Uint8Array): Elem {
|
||||
return {
|
||||
customFace: {
|
||||
filePath,
|
||||
origUrl,
|
||||
md5,
|
||||
size: 10711,
|
||||
width: 1080,
|
||||
height: 1080,
|
||||
},
|
||||
};
|
||||
}
|
||||
describe('decodeRichBody / NT image compatibility siblings (#389)', () => {
|
||||
const fileName = 'bcc7bbcc76a1a9d940c57346a5d223e8.png';
|
||||
const otherMd5 = Uint8Array.from({ length: 16 }, (_, i) => i + 1);
|
||||
|
||||
describe('decodeRichBody / NT image compatibility siblings (#389)', () => {
|
||||
const fileName = 'bcc7bbcc76a1a9d940c57346a5d223e8.png';
|
||||
const otherMd5 = Uint8Array.from({ length: 16 }, (_, i) => i + 1);
|
||||
it('keeps the NT image and drops the query-only customFace sibling', () => {
|
||||
const out = decodeRichBody({
|
||||
richText: {
|
||||
elems: [
|
||||
ntImageElem(fileName),
|
||||
customFaceElem(fileName, '&rkey=xxx&spec=0', otherMd5),
|
||||
],
|
||||
},
|
||||
}, true);
|
||||
|
||||
it('keeps the NT image and drops the query-only customFace sibling', () => {
|
||||
const out = decodeRichBody({
|
||||
richText: {
|
||||
elems: [
|
||||
ntImageElem(fileName),
|
||||
customFaceElem(fileName, '&rkey=xxx&spec=0', otherMd5),
|
||||
],
|
||||
},
|
||||
}, true);
|
||||
expect(out).toHaveLength(1);
|
||||
expect(out[0]).toMatchObject({
|
||||
type: 'image',
|
||||
fileId: fileName,
|
||||
imageUrl: 'https://multimedia.nt.qq.com.cn/download?appid=1407&fileid=EhRgood&rkey=good',
|
||||
picFormat: 1001,
|
||||
});
|
||||
});
|
||||
|
||||
expect(out).toHaveLength(1);
|
||||
expect(out[0]).toMatchObject({
|
||||
type: 'image',
|
||||
fileId: fileName,
|
||||
imageUrl: 'https://multimedia.nt.qq.com.cn/download?appid=1407&fileid=EhRgood&rkey=good',
|
||||
picFormat: 1001,
|
||||
it('drops a same-file customFace even when its legacy URL is well-formed', () => {
|
||||
const out = decodeRichBody({
|
||||
richText: {
|
||||
elems: [
|
||||
ntImageElem(fileName),
|
||||
customFaceElem(fileName, '/gchatpic_new/0/0-0-AABB/0', otherMd5),
|
||||
],
|
||||
},
|
||||
}, true);
|
||||
|
||||
expect(out).toEqual([
|
||||
expect.objectContaining({ type: 'image', fileId: fileName, picFormat: 1001 }),
|
||||
]);
|
||||
});
|
||||
|
||||
it('keeps a standalone customFace with a usable download path', () => {
|
||||
const out = decodeRichBody({
|
||||
richText: {
|
||||
elems: [customFaceElem(fileName, '/gchatpic_new/0/0-0-AABB/0', otherMd5)],
|
||||
},
|
||||
}, true);
|
||||
|
||||
expect(out).toEqual([{
|
||||
type: 'image',
|
||||
imageUrl: 'http://gchat.qpic.cn/gchatpic_new/0/0-0-AABB/0',
|
||||
fileId: fileName,
|
||||
fileSize: 10711,
|
||||
width: 1080,
|
||||
height: 1080,
|
||||
subType: 0,
|
||||
summary: '[图片]',
|
||||
md5Hex: '0102030405060708090A0B0C0D0E0F10',
|
||||
}]);
|
||||
});
|
||||
|
||||
it('drops a standalone customFace whose URL cannot be fetched', () => {
|
||||
const out = decodeRichBody({
|
||||
richText: {
|
||||
elems: [customFaceElem(fileName, '&rkey=xxx&spec=0', otherMd5)],
|
||||
},
|
||||
}, true);
|
||||
|
||||
expect(out).toEqual([]);
|
||||
});
|
||||
|
||||
it('keeps two distinct pictures', () => {
|
||||
const second = 'other.png';
|
||||
const out = decodeRichBody({
|
||||
richText: {
|
||||
elems: [
|
||||
ntImageElem(fileName),
|
||||
customFaceElem(second, '/gchatpic_new/0/0-0-CCDD/0', otherMd5),
|
||||
],
|
||||
},
|
||||
}, true);
|
||||
|
||||
expect(out.map((el) => el.type === 'image' ? el.fileId : el.type)).toEqual([
|
||||
fileName,
|
||||
second,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
it('drops a same-file customFace even when its legacy URL is well-formed', () => {
|
||||
const out = decodeRichBody({
|
||||
richText: {
|
||||
elems: [
|
||||
ntImageElem(fileName),
|
||||
customFaceElem(fileName, '/gchatpic_new/0/0-0-AABB/0', otherMd5),
|
||||
],
|
||||
},
|
||||
}, true);
|
||||
describe('makeImageUrl', () => {
|
||||
it('prefixes NT paths that already include a download path', () => {
|
||||
expect(makeImageUrl('/download?appid=1407&fileid=abc&rkey=x'))
|
||||
.toBe('https://multimedia.nt.qq.com.cn/download?appid=1407&fileid=abc&rkey=x');
|
||||
});
|
||||
|
||||
expect(out).toEqual([
|
||||
expect.objectContaining({ type: 'image', fileId: fileName, picFormat: 1001 }),
|
||||
]);
|
||||
it('does not glue the NT host onto a query fragment (#389)', () => {
|
||||
expect(makeImageUrl('&rkey=xxx&spec=0')).toBe('');
|
||||
expect(makeImageUrl('rkey=xxx&spec=0')).toBe('');
|
||||
});
|
||||
|
||||
it('prefixes legacy gchat paths', () => {
|
||||
expect(makeImageUrl('/gchatpic_new/0/0-0-AABB/0'))
|
||||
.toBe('http://gchat.qpic.cn/gchatpic_new/0/0-0-AABB/0');
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps a standalone customFace with a usable download path', () => {
|
||||
const out = decodeRichBody({
|
||||
richText: {
|
||||
elems: [customFaceElem(fileName, '/gchatpic_new/0/0-0-AABB/0', otherMd5)],
|
||||
},
|
||||
}, true);
|
||||
|
||||
expect(out).toEqual([{
|
||||
type: 'image',
|
||||
imageUrl: 'http://gchat.qpic.cn/gchatpic_new/0/0-0-AABB/0',
|
||||
fileId: fileName,
|
||||
fileSize: 10711,
|
||||
width: 1080,
|
||||
height: 1080,
|
||||
subType: 0,
|
||||
summary: '[图片]',
|
||||
md5Hex: '0102030405060708090A0B0C0D0E0F10',
|
||||
}]);
|
||||
});
|
||||
|
||||
it('drops a standalone customFace whose URL cannot be fetched', () => {
|
||||
const out = decodeRichBody({
|
||||
richText: {
|
||||
elems: [customFaceElem(fileName, '&rkey=xxx&spec=0', otherMd5)],
|
||||
},
|
||||
}, true);
|
||||
|
||||
expect(out).toEqual([]);
|
||||
});
|
||||
|
||||
it('keeps two distinct pictures', () => {
|
||||
const second = 'other.png';
|
||||
const out = decodeRichBody({
|
||||
richText: {
|
||||
elems: [
|
||||
ntImageElem(fileName),
|
||||
customFaceElem(second, '/gchatpic_new/0/0-0-CCDD/0', otherMd5),
|
||||
],
|
||||
},
|
||||
}, true);
|
||||
|
||||
expect(out.map((el) => el.type === 'image' ? el.fileId : el.type)).toEqual([
|
||||
fileName,
|
||||
second,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('makeImageUrl', () => {
|
||||
it('prefixes NT paths that already include a download path', () => {
|
||||
expect(makeImageUrl('/download?appid=1407&fileid=abc&rkey=x'))
|
||||
.toBe('https://multimedia.nt.qq.com.cn/download?appid=1407&fileid=abc&rkey=x');
|
||||
});
|
||||
|
||||
it('does not glue the NT host onto a query fragment (#389)', () => {
|
||||
expect(makeImageUrl('&rkey=xxx&spec=0')).toBe('');
|
||||
expect(makeImageUrl('rkey=xxx&spec=0')).toBe('');
|
||||
});
|
||||
|
||||
it('prefixes legacy gchat paths', () => {
|
||||
expect(makeImageUrl('/gchatpic_new/0/0-0-AABB/0'))
|
||||
.toBe('http://gchat.qpic.cn/gchatpic_new/0/0-0-AABB/0');
|
||||
});
|
||||
});
|
||||
|
||||
it('bounds retained card output across the entire message', () => {
|
||||
const previousLevel = getLogLevel();
|
||||
const captured: Array<{ scope: string; message: string }> = [];
|
||||
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
protobuf_encode,
|
||||
type pb,
|
||||
type pb_repeated,
|
||||
type string,
|
||||
type uint_32,
|
||||
} from '@snowluma/proton';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
@@ -63,6 +63,8 @@ describe('FetchGroupDetail namespace', () => {
|
||||
expect(out.config?.flags?.addType).toBe(true);
|
||||
expect(out.config?.flags?.noFingerOpen).toBe(true);
|
||||
expect(out.config?.flags?.noCodeFingerOpen).toBe(true);
|
||||
expect(out.config?.flags?.question).toBe('');
|
||||
expect(out.config?.flags?.answer).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -85,6 +87,19 @@ describe('FetchGroupDetail namespace', () => {
|
||||
expect(env.subCommand ?? 0).toBe(0); // proto3 omits the 0 default on the wire
|
||||
expect(env.reserved ?? 0).toBe(0); // NOT uin-form
|
||||
expect(env.body?.config?.uin).toBe(BigInt(601692726));
|
||||
expect(env.body?.config?.flags?.question).toBe('');
|
||||
expect(env.body?.config?.flags?.answer).toBe('');
|
||||
});
|
||||
|
||||
it('keeps empty question/answer masks on the wire (#393)', async () => {
|
||||
const sender = makeSender({ groupInfo: { uin: 1n, results: { name: 'g' } } });
|
||||
await FetchGroupDetail.invoke(sender, { groupUin: 1 });
|
||||
|
||||
const bytes = sender.sendRawPacket.mock.calls[0]![1] as Uint8Array;
|
||||
// length-delimited empty string: field 24/25, wire type 2, length 0.
|
||||
const hex = Buffer.from(bytes).toString('hex');
|
||||
expect(hex).toContain('c20100');
|
||||
expect(hex).toContain('ca0100');
|
||||
});
|
||||
|
||||
it('returns the decoded group detail (name + counts)', async () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { pb, pb_repeated, uint_32, uint_64 } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbBase, OidbSvcTrpcTcp0x10C0Response } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbGroupRequestList } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import type { SendPacketResult } from '@snowluma/common/packet-sender';
|
||||
|
||||
@@ -47,6 +47,8 @@ describe('FetchGroupRequests namespace', () => {
|
||||
expect(groupRequestOperationType(1)).toBe(2);
|
||||
expect(groupRequestOperationType(7)).toBe(1);
|
||||
expect(groupRequestOperationType(17)).toBe(100);
|
||||
expect(groupRequestOperationType(5)).toBe(22);
|
||||
expect(groupRequestOperationType(22)).toBe(22);
|
||||
expect(groupRequestOperationType(99)).toBeNull();
|
||||
});
|
||||
|
||||
@@ -135,13 +137,43 @@ describe('FetchGroupRequests namespace', () => {
|
||||
const response = await FetchGroupRequests.invoke(sender, { filtered: false });
|
||||
|
||||
expect(response.requests?.[0]).toMatchObject({
|
||||
target: { uin: 1_234_567_890, name: 'requester' },
|
||||
invitor: { uin: 2_345_678_901, name: 'inviter' },
|
||||
operatorUser: { uin: 3_456_789_012, name: 'operator' },
|
||||
target: { uin: 1_234_567_890, uid: '', name: 'requester' },
|
||||
invitor: { uin: 2_345_678_901, uid: '', name: 'inviter' },
|
||||
operatorUser: { uin: 3_456_789_012, uid: '', name: 'operator' },
|
||||
});
|
||||
expect(response.field2).toBe(1_785_406_628_779_279n);
|
||||
});
|
||||
|
||||
it('keeps string account identifiers from the native reply', async () => {
|
||||
const responseData = Buffer.from(protobuf_encode<OidbBase<OidbSvcTrpcTcp0x10C0Response>>({
|
||||
body: {
|
||||
requests: [{
|
||||
sequence: 99n,
|
||||
eventType: 5,
|
||||
state: 1,
|
||||
group: { groupUin: 1001, groupName: 'group' },
|
||||
target: { uid: 'u_target', name: 'invitee' },
|
||||
invitor: { uid: 'u_inviter', name: 'inviter' },
|
||||
comment: 'join us',
|
||||
}],
|
||||
},
|
||||
}));
|
||||
const sender = {
|
||||
sendRawPacket: vi.fn(async () => ({
|
||||
success: true, gotResponse: true, errorCode: 0, errorMessage: '', responseData,
|
||||
})),
|
||||
};
|
||||
|
||||
const response = await FetchGroupRequests.invoke(sender, { filtered: false });
|
||||
|
||||
expect(response.requests?.[0]).toMatchObject({
|
||||
eventType: 5,
|
||||
target: { uid: 'u_target', uin: 0, name: 'invitee' },
|
||||
invitor: { uid: 'u_inviter', uin: 0, name: 'inviter' },
|
||||
comment: 'join us',
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps the UID response path on the non-native envelope', async () => {
|
||||
const sender = makeSender();
|
||||
await FetchGroupRequestsByUid.invoke(sender, { filtered: false });
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type { Oidb0xdc2_34Resp } from '@snowluma/proto-defs/oidb-actions/contact-ark';
|
||||
import type { SendPacketResult } from '@snowluma/common/packet-sender';
|
||||
import { SendTuwenArk } from '../../../src/oidb-services/contacts/send-tuwen-ark';
|
||||
import { env, v, s, m } from '../_pb-oracle';
|
||||
|
||||
function makeSender() {
|
||||
const respEnv: OidbBase<Oidb0xdc2_34Resp> = { command: 0xDC2, subCommand: 34, body: {} };
|
||||
const r: SendPacketResult = {
|
||||
success: true, gotResponse: true, errorCode: 0, errorMessage: '',
|
||||
responseData: Buffer.from(protobuf_encode<OidbBase<Oidb0xdc2_34Resp>>(respEnv)),
|
||||
};
|
||||
return { sendRawPacket: vi.fn(async () => r) };
|
||||
}
|
||||
|
||||
describe('SendTuwenArk namespace', () => {
|
||||
it('declares command 0xdc2 sub 34, SSO: OidbSvcTrpcTcp.0xdc2_34', () => {
|
||||
expect(SendTuwenArk.command).toBe(0xDC2);
|
||||
expect(SendTuwenArk.subCommand).toBe(34);
|
||||
expect(SendTuwenArk.uinForm).toBe(false);
|
||||
});
|
||||
|
||||
it('serializes fixed appId=100446242, field2=1, field3=0, field5={1:1}', () => {
|
||||
const out = SendTuwenArk.serialize({} as any, {
|
||||
targetId: 12345,
|
||||
peerType: 1,
|
||||
title: 'T',
|
||||
desc: 'D',
|
||||
summary: 'S',
|
||||
jumpUrl: 'https://example.com',
|
||||
previewUrl: '',
|
||||
});
|
||||
expect(out.appInfo).toMatchObject({
|
||||
appId: 100446242,
|
||||
field2: 1,
|
||||
field3: 0,
|
||||
field5: { field1: 1 },
|
||||
targetId: 12345,
|
||||
});
|
||||
});
|
||||
|
||||
it('byte-oracle: C2C (peerType=0) — peerType omitted on wire, field3=0 present, previewUrl present', async () => {
|
||||
const sender = makeSender();
|
||||
await SendTuwenArk.invoke(sender, {
|
||||
targetId: 2863253201,
|
||||
peerType: 0,
|
||||
title: 'QQ开放平台',
|
||||
desc: 'QQ小程序是连接广轻用户的新方式,覆盖8亿新生代活跃网民。轻便快捷的开发模式,将能在QQ内被轻松获取和传播',
|
||||
summary: '[分享] QQ开放平台',
|
||||
jumpUrl: 'https://q.qq.com/r',
|
||||
previewUrl: 'https://tangram-1251316161.file.myqcloud.com/files/20210721/e50a8e37e08f29bf1ffc7466e1950690.png',
|
||||
});
|
||||
|
||||
const [cmd, bytes] = sender.sendRawPacket.mock.calls[0]!;
|
||||
expect(cmd).toBe('OidbSvcTrpcTcp.0xdc2_34');
|
||||
|
||||
// AppInfo embedding: field5={1:1}, content={1:1, 10:title, 11:desc, 12:summary, 13:jumpUrl, 14:previewUrl}, then appId/field2/field3/targetId
|
||||
const field5 = m(5, [...v(1, 1)]);
|
||||
const content = m(12, [
|
||||
...v(1, 1),
|
||||
...s(10, 'QQ开放平台'),
|
||||
...s(11, 'QQ小程序是连接广轻用户的新方式,覆盖8亿新生代活跃网民。轻便快捷的开发模式,将能在QQ内被轻松获取和传播'),
|
||||
...s(12, '[分享] QQ开放平台'),
|
||||
...s(13, 'https://q.qq.com/r'),
|
||||
...s(14, 'https://tangram-1251316161.file.myqcloud.com/files/20210721/e50a8e37e08f29bf1ffc7466e1950690.png'),
|
||||
]);
|
||||
const appInfo = m(1, [
|
||||
...v(1, 100446242),
|
||||
...v(2, 1),
|
||||
...v(3, 0), // field3=0 is present in wire (pb_optional preserves zero as expected)
|
||||
...field5,
|
||||
...v(11, 2863253201),
|
||||
...content,
|
||||
]);
|
||||
// Meta: peerType=0 is present in wire (pb_optional preserves zero as expected)
|
||||
const meta = m(2, [
|
||||
...v(1, 0),
|
||||
...v(2, 2863253201),
|
||||
]);
|
||||
const body = [...appInfo, ...meta];
|
||||
expect(Buffer.from(bytes).toString('hex')).toBe(env(0xDC2, 34, body, false));
|
||||
});
|
||||
|
||||
it('byte-oracle: group (peerType=1) — peerType present, field3=0 present, empty previewUrl present', async () => {
|
||||
const sender = makeSender();
|
||||
await SendTuwenArk.invoke(sender, {
|
||||
targetId: 123456789,
|
||||
peerType: 1,
|
||||
title: '测试标题',
|
||||
desc: '测试描述',
|
||||
summary: '测试摘要',
|
||||
jumpUrl: 'https://example.com/jump',
|
||||
previewUrl: '',
|
||||
});
|
||||
|
||||
const [cmd, bytes] = sender.sendRawPacket.mock.calls[0]!;
|
||||
expect(cmd).toBe('OidbSvcTrpcTcp.0xdc2_34');
|
||||
|
||||
const field5 = m(5, [...v(1, 1)]);
|
||||
const content = m(12, [
|
||||
...v(1, 1),
|
||||
...s(10, '测试标题'),
|
||||
...s(11, '测试描述'),
|
||||
...s(12, '测试摘要'),
|
||||
...s(13, 'https://example.com/jump'),
|
||||
...s(14, ''), // previewUrl='' is present in wire (pb_optional preserves empty string as expected)
|
||||
]);
|
||||
const appInfo = m(1, [
|
||||
...v(1, 100446242),
|
||||
...v(2, 1),
|
||||
...v(3, 0), // field3=0 is present
|
||||
...field5,
|
||||
...v(11, 123456789),
|
||||
...content,
|
||||
]);
|
||||
// Meta: peerType=1 present
|
||||
const meta = m(2, [
|
||||
...v(1, 1),
|
||||
...v(2, 123456789),
|
||||
]);
|
||||
const body = [...appInfo, ...meta];
|
||||
expect(Buffer.from(bytes).toString('hex')).toBe(env(0xDC2, 34, body, false));
|
||||
});
|
||||
|
||||
it('deserialize returns undefined (void response)', () => {
|
||||
expect(SendTuwenArk.deserialize({} as any, {})).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -10,7 +10,10 @@ function makeSender(): { sendRawPacket: ReturnType<typeof vi.fn> } {
|
||||
const respEnv: OidbBase<OidbDoubtGetResp> = {
|
||||
command: 0xD69, subCommand: 0,
|
||||
body: { status: 1, body: { list: [
|
||||
{ uid: 'u_alice', nick: 'Alice', source: '可能认识', msg: 'hi', reqTime: 1700000000n },
|
||||
{
|
||||
uid: 'u_alice', nick: 'Alice', source: '可能认识', reason: '',
|
||||
msg: 'hi', uin: 12345n, groupCode: '', reqTime: 1700000000n,
|
||||
},
|
||||
], reason: '' } },
|
||||
};
|
||||
const r: SendPacketResult = {
|
||||
@@ -46,7 +49,10 @@ describe('GetDoubtBuddyReq namespace', () => {
|
||||
it('deserializes the item list to the OneBot shape (uid + reqTime high-confidence)', async () => {
|
||||
const list = await GetDoubtBuddyReq.invoke(makeSender(), { count: 10 });
|
||||
expect(list).toEqual([
|
||||
{ uid: 'u_alice', nick: 'Alice', source: '可能认识', msg: 'hi', reqTime: 1700000000 },
|
||||
{
|
||||
uid: 'u_alice', user_id: 12345, nick: 'Alice', source: '可能认识',
|
||||
reason: '', msg: 'hi', group_code: '', reqTime: 1700000000,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -24,6 +24,11 @@ function makeSender() {
|
||||
}
|
||||
|
||||
describe('SetMemberPermission namespace', () => {
|
||||
it('declares 0x89A_0', () => {
|
||||
expect(SetMemberPermission.command).toBe(0x89A);
|
||||
expect(SetMemberPermission.subCommand).toBe(0);
|
||||
});
|
||||
|
||||
it.each<[GroupMemberPermission, number]>([
|
||||
['upload_album', 0x1],
|
||||
['temporary_session', 0x10000],
|
||||
@@ -41,6 +46,8 @@ describe('SetMemberPermission namespace', () => {
|
||||
const [command, bytes] = sender.sendRawPacket.mock.calls[0]!;
|
||||
expect(command).toBe('OidbSvcTrpcTcp.0x89a_0');
|
||||
const envelope = protobuf_decode<OidbBase<Oidb0x89a_0MemberPermission>>(bytes);
|
||||
expect(envelope.command).toBe(0x89A);
|
||||
expect(envelope.subCommand ?? 0).toBe(0);
|
||||
expect(envelope.body).toMatchObject({
|
||||
groupUin: 12345n,
|
||||
settings: {
|
||||
|
||||
@@ -21,6 +21,14 @@ describe('SetProfile namespace', () => {
|
||||
});
|
||||
|
||||
describe('invoke', () => {
|
||||
it('packages sex into integer field 20009', async () => {
|
||||
const deps = makeDeps();
|
||||
await SetProfile.invoke(deps, { sex: 1 });
|
||||
const [, bytes] = deps.sendRawPacket.mock.calls[0]!;
|
||||
const env = protobuf_decode<OidbBase<OidbSetProfile>>(bytes);
|
||||
expect(env.body?.intProfiles).toEqual([{ fieldId: 20009, value: 1n }]);
|
||||
});
|
||||
|
||||
it('is a no-op when both nickname and personalNote are undefined', async () => {
|
||||
const deps = makeDeps();
|
||||
await SetProfile.invoke(deps, {});
|
||||
|
||||
@@ -259,7 +259,38 @@ describe('IncomingPacketPipeline / stranger resolve on group_invite', () => {
|
||||
await new Promise(r => setTimeout(r, 10));
|
||||
|
||||
expect(resolveGroupInviteCardSequence).toHaveBeenCalledWith(999);
|
||||
expect(captured[0]).toMatchObject({ flag: 'slreq:1:778899:999:2:0' });
|
||||
expect(captured[0]).toMatchObject({
|
||||
flag: 'slreq:1:778899:999:2:0',
|
||||
invitedUin: 10001,
|
||||
invitedUid: 'self',
|
||||
});
|
||||
});
|
||||
|
||||
it('fills the invitee from the pending-request row (#394)', async () => {
|
||||
const resolveGroupJoinRequest = vi.fn(async () => ({
|
||||
groupId: 1, groupName: 'group',
|
||||
targetUid: 'u_invitee', targetUin: 789, targetName: 'invitee',
|
||||
invitorUid: 'u_inviter', invitorUin: 456, invitorName: 'inviter',
|
||||
operatorUid: '', operatorUin: 0, operatorName: '',
|
||||
sequence: 42, state: 1, eventType: 2,
|
||||
comment: '', filtered: false,
|
||||
}));
|
||||
const { pipeline, captured } = makePipeline({ resolveGroupJoinRequest });
|
||||
|
||||
pipeline.registerCmd('test.cmd', () => [{
|
||||
kind: 'group_invite', time: 1, selfUin: 10001,
|
||||
groupId: 1, fromUin: 456, fromUid: 'u_inviter',
|
||||
subType: 'invite', message: '', flag: 'invite:1:u_inviter',
|
||||
} as QQEventVariant]);
|
||||
|
||||
pipeline.process({ serviceCmd: 'test.cmd' } as PacketInfo);
|
||||
await new Promise(r => setTimeout(r, 10));
|
||||
|
||||
expect(captured[0]).toMatchObject({
|
||||
fromUin: 456,
|
||||
invitedUin: 789,
|
||||
invitedUid: 'u_invitee',
|
||||
});
|
||||
});
|
||||
|
||||
it('runs the profile + request lookups in parallel (independent failures)', async () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/proton",
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.12",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "Compile-time protobuf encoder/decoder generator for SnowLuma. TypeScript interfaces → fully-inlined, zero-runtime protobuf codec functions. Vendored from SnowLuma/protobuf-dsl (reference copy under dev/protobuf-dsl/) with edge-case fixes applied.",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/runtime",
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.12",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "index.mjs",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"name": "MotricSeven",
|
||||
"email": "motricseven@gmail.com"
|
||||
},
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.12",
|
||||
"description": "TypeScript SDK for SnowLuma OneBot HTTP and WebSocket transports",
|
||||
"keywords": [
|
||||
"snowluma",
|
||||
|
||||
@@ -455,10 +455,11 @@ export abstract class SnowLumaApiClient {
|
||||
return this.call('download_file', params, options);
|
||||
}
|
||||
|
||||
setQqProfile(params: { nickname?: string; personalNote?: string }, options?: RequestOptions) {
|
||||
setQqProfile(params: { nickname?: string; personalNote?: string; sex?: number }, options?: RequestOptions) {
|
||||
return this.call('set_qq_profile', {
|
||||
nickname: params.nickname,
|
||||
personal_note: params.personalNote,
|
||||
...(params.sex !== undefined ? { sex: params.sex } : {}),
|
||||
}, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ export interface OneBotRequestEvent extends OneBotBaseEvent {
|
||||
sub_type?: string;
|
||||
group_id?: number;
|
||||
user_id?: number;
|
||||
/** Invitee QQ number on `request.group` / `invite`. */
|
||||
invited_id?: number;
|
||||
comment?: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -350,6 +350,7 @@ export interface DownloadFileParams extends JsonObject {
|
||||
export interface SetQqProfileParams extends JsonObject {
|
||||
nickname?: string;
|
||||
personal_note?: string;
|
||||
sex?: number;
|
||||
}
|
||||
|
||||
export interface SetOnlineStatusParams extends JsonObject {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"name": "MotricSeven",
|
||||
"email": "motricseven@gmail.com"
|
||||
},
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.12",
|
||||
"description": "Shared SnowLuma UI primitives — Tailwind 4 theme tokens + shadcn-style atomic components",
|
||||
"keywords": [
|
||||
"snowluma",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "@snowluma/websocket",
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.12",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"name": "webui",
|
||||
"private": true,
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.12",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -200,7 +200,7 @@ export function ActionTester({ accounts, docs, presetAction }: { accounts: QQInf
|
||||
{/* tester */}
|
||||
<motion.section
|
||||
initial={{ opacity: 0, y: 10 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.35 }}
|
||||
className={cn(cardCls, 'flex flex-col gap-5 p-6 xl:col-span-7')}
|
||||
className={cn(cardCls, 'relative z-20 flex flex-col gap-5 p-6 xl:col-span-7')}
|
||||
>
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-2.5">
|
||||
|
||||
@@ -59,6 +59,7 @@ export function Picker({
|
||||
const listRef = useRef<HTMLDivElement>(null);
|
||||
const searchRef = useRef<HTMLInputElement>(null);
|
||||
const suppressTriggerClick = useRef(false);
|
||||
const dragRef = useRef<{ id: number; y: number; dragged: boolean } | null>(null);
|
||||
const waitingForOptions = Boolean(loading && options.length === 0);
|
||||
|
||||
const selected = options.find((o) => o.value === value);
|
||||
@@ -184,7 +185,7 @@ export function Picker({
|
||||
}}
|
||||
transition={reduced ? NONE : { ...OPEN, opacity: { duration: 0.12, ease: EASE } }}
|
||||
style={{ transformOrigin: 'top left' }}
|
||||
className="absolute z-50 mt-1.5 w-full overflow-hidden rounded-[11px] border border-border bg-popover shadow-[0_1px_2px_rgb(0_0_0/0.06),0_16px_36px_-18px_rgb(0_0_0/0.5)]"
|
||||
className="absolute z-[200] mt-1.5 w-full overflow-hidden rounded-[11px] border border-border bg-popover shadow-[0_1px_2px_rgb(0_0_0/0.06),0_16px_36px_-18px_rgb(0_0_0/0.5)]"
|
||||
>
|
||||
<div className="flex items-center gap-2 border-b border-border/60 px-2.5 py-2">
|
||||
<Search className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
|
||||
@@ -229,8 +230,8 @@ export function Picker({
|
||||
ref={listRef}
|
||||
role="listbox"
|
||||
onScroll={(e) => setScrollTop((e.target as HTMLDivElement).scrollTop)}
|
||||
className="overflow-auto"
|
||||
style={{ height: viewH }}
|
||||
className="overflow-auto overscroll-contain"
|
||||
style={{ height: viewH, touchAction: 'pan-y' }}
|
||||
>
|
||||
<div style={{ height: totalRows * ROW_H, position: 'relative' }}>
|
||||
<motion.span
|
||||
@@ -251,10 +252,26 @@ export function Picker({
|
||||
aria-selected={idx === active}
|
||||
onMouseEnter={() => setActive(idx)}
|
||||
onPointerDown={(e) => {
|
||||
e.preventDefault();
|
||||
if (e.pointerType === 'mouse') {
|
||||
suppressTriggerClick.current = true;
|
||||
choose(idx);
|
||||
return;
|
||||
}
|
||||
dragRef.current = { id: e.pointerId, y: e.clientY, dragged: false };
|
||||
}}
|
||||
onPointerMove={(e) => {
|
||||
const drag = dragRef.current;
|
||||
if (!drag || drag.id !== e.pointerId) return;
|
||||
if (Math.abs(e.clientY - drag.y) > 8) drag.dragged = true;
|
||||
}}
|
||||
onPointerUp={(e) => {
|
||||
const drag = dragRef.current;
|
||||
dragRef.current = null;
|
||||
if (!drag || drag.id !== e.pointerId || drag.dragged) return;
|
||||
suppressTriggerClick.current = true;
|
||||
choose(idx);
|
||||
}}
|
||||
onPointerCancel={() => { dragRef.current = null; }}
|
||||
className={cn(
|
||||
'absolute left-0 right-0 z-[1] flex cursor-pointer items-center gap-2.5 px-3',
|
||||
idx === active ? 'text-accent-foreground' : 'hover:bg-accent/50',
|
||||
|
||||
Reference in new issue
Block a user