Fix merge conflict and remove one group avatar implement
This commit is contained in:
commit
16bdf1be1e
111 files changed
+6830
-2916
No files matched your search
@@ -0,0 +1,155 @@
|
||||
// Tier-2 napcat-parity actions ported as pure oidb calls. Each function
|
||||
// here corresponds to one napcat PacketApi.pkt.operation.* entry; the
|
||||
// schemas live in proto/oidb-action.ts. Nothing in this file touches
|
||||
// the NTQQ NodeIKernel — every wire trip is one runOidb round-trip.
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import {
|
||||
OidbGroupTodoSchema,
|
||||
OidbStrangerStatusReqSchema,
|
||||
OidbStrangerStatusRespSchema,
|
||||
OidbAiVoiceListReqSchema,
|
||||
OidbAiVoiceListRespSchema,
|
||||
OidbAiVoiceReqSchema,
|
||||
OidbAiVoiceRespSchema,
|
||||
} from '../proto/oidb-action';
|
||||
import type { MediaIndexNode } from './shared';
|
||||
|
||||
// ─────────────── Group todo (0xF90) ───────────────
|
||||
|
||||
export async function setGroupTodo(bridge: Bridge, groupId: number, msgSeq: bigint): Promise<void> {
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xf90_1',
|
||||
oidbCmd: 0xF90, subCmd: 1,
|
||||
request: { schema: OidbGroupTodoSchema, value: { groupUin: groupId, msgSeq } },
|
||||
});
|
||||
}
|
||||
|
||||
export async function completeGroupTodo(bridge: Bridge, groupId: number, msgSeq: bigint): Promise<void> {
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xf90_2',
|
||||
oidbCmd: 0xF90, subCmd: 2,
|
||||
request: { schema: OidbGroupTodoSchema, value: { groupUin: groupId, msgSeq } },
|
||||
});
|
||||
}
|
||||
|
||||
export async function cancelGroupTodo(bridge: Bridge, groupId: number, msgSeq: bigint): Promise<void> {
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xf90_3',
|
||||
oidbCmd: 0xF90, subCmd: 3,
|
||||
request: { schema: OidbGroupTodoSchema, value: { groupUin: groupId, msgSeq } },
|
||||
});
|
||||
}
|
||||
|
||||
// ─────────────── Stranger online/ext status (0xFE1_2) ───────────────
|
||||
|
||||
export interface StrangerStatus {
|
||||
status: number;
|
||||
ext_status: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirror napcat's GetStrangerStatus: decode the extBigInt status word.
|
||||
* Values ≤10 fold into a 10×status; everything else is split into the
|
||||
* high-byte / low-byte ext_status the OneBot dialect uses.
|
||||
*
|
||||
* Returns null on transport / decode failure rather than throwing, so
|
||||
* the OneBot action can produce a clean retcode without try/catch
|
||||
* gymnastics.
|
||||
*/
|
||||
export async function getStrangerStatus(bridge: Bridge, uin: number): Promise<StrangerStatus | null> {
|
||||
try {
|
||||
const resp = await runOidb<{ data?: { status?: { value?: bigint | number } } }>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xfe1_2',
|
||||
oidbCmd: 0xFE1, subCmd: 2,
|
||||
request: {
|
||||
schema: OidbStrangerStatusReqSchema,
|
||||
value: { uin, key: [{ key: 27372 }] },
|
||||
},
|
||||
response: { schema: OidbStrangerStatusRespSchema },
|
||||
});
|
||||
const raw = resp?.data?.status?.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 };
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────── AI voice (0x929D / 0x929B) ───────────────
|
||||
|
||||
export const AiVoiceChatType = {
|
||||
Unknown: 0,
|
||||
Sound: 1,
|
||||
Sing: 2,
|
||||
} as const;
|
||||
export type AiVoiceChatType = typeof AiVoiceChatType[keyof typeof AiVoiceChatType];
|
||||
|
||||
export interface AiVoiceItem {
|
||||
voiceId: string;
|
||||
voiceDisplayName: string;
|
||||
voiceExampleUrl: string;
|
||||
}
|
||||
|
||||
export interface AiVoiceCategory {
|
||||
category: string;
|
||||
voices: AiVoiceItem[];
|
||||
}
|
||||
|
||||
export async function fetchAiVoiceList(
|
||||
bridge: Bridge,
|
||||
groupId: number,
|
||||
chatType: AiVoiceChatType,
|
||||
): Promise<AiVoiceCategory[]> {
|
||||
const resp = await runOidb<{ content?: AiVoiceCategory[] }>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x929d_0',
|
||||
oidbCmd: 0x929D, subCmd: 0,
|
||||
request: { schema: OidbAiVoiceListReqSchema, value: { groupUin: groupId, chatType } },
|
||||
response: { schema: OidbAiVoiceListRespSchema },
|
||||
});
|
||||
return resp?.content ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger AI voice synthesis. Server may return an empty msgInfo while
|
||||
* the render is in-flight; we retry until a node materialises or the
|
||||
* cap is hit. napcat uses the same 30-retry budget.
|
||||
*
|
||||
* The returned MediaIndexNode plugs directly into
|
||||
* `bridge.fetchGroupPttUrlByNode`, which already handles every other
|
||||
* download-URL fetch in SnowLuma.
|
||||
*/
|
||||
export async function fetchAiVoice(
|
||||
bridge: Bridge,
|
||||
groupId: number,
|
||||
voiceId: string,
|
||||
text: string,
|
||||
chatType: AiVoiceChatType,
|
||||
maxRetries = 30,
|
||||
): Promise<MediaIndexNode> {
|
||||
// Random 32-bit session id — server uses this to deduplicate polls.
|
||||
const sessionId = Math.floor(Math.random() * 0xFFFFFFFF) >>> 0;
|
||||
for (let i = 0; i < maxRetries; i++) {
|
||||
const resp = await runOidb<{
|
||||
statusCode?: number;
|
||||
msgInfo?: { msgInfoBody?: Array<{ index?: MediaIndexNode }> };
|
||||
}>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x929b_0',
|
||||
oidbCmd: 0x929B, subCmd: 0,
|
||||
request: {
|
||||
schema: OidbAiVoiceReqSchema,
|
||||
value: { groupUin: groupId, voiceId, text, chatType, session: { sessionId } },
|
||||
},
|
||||
response: { schema: OidbAiVoiceRespSchema },
|
||||
});
|
||||
const node = resp?.msgInfo?.msgInfoBody?.[0]?.index;
|
||||
if (node) return node;
|
||||
}
|
||||
throw new Error(`AI voice synthesis did not complete after ${maxRetries} polls`);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import type { Bridge } from '../bridge';
|
||||
import { gunzipSync, gzipSync } from 'zlib';
|
||||
import { protoDecode, protoEncode } from '../../protobuf/decode';
|
||||
import { buildSendElems } from '../element-builder';
|
||||
import { parseMsgPush } from '../msg-push-handler';
|
||||
import { parseMsgPush } from '../msg-push';
|
||||
import type { ForwardNodePayload } from '../events';
|
||||
import type { PacketInfo } from '../../protocol/types';
|
||||
import {
|
||||
@@ -29,7 +29,7 @@ async function buildForwardPushBody(
|
||||
bridge: Bridge,
|
||||
node: ForwardNodePayload,
|
||||
): Promise<Record<string, unknown>> {
|
||||
const fromUin = node.userUin > 0 ? node.userUin : toInt(bridge.qqInfo.uin);
|
||||
const fromUin = node.userUin > 0 ? node.userUin : toInt(bridge.identity.uin);
|
||||
if (fromUin <= 0) throw new Error('forward node user uin is invalid');
|
||||
|
||||
const nickname = node.nickname.trim() || String(fromUin);
|
||||
@@ -41,7 +41,7 @@ async function buildForwardPushBody(
|
||||
return {
|
||||
responseHead: {
|
||||
fromUin,
|
||||
toUid: bridge.qqInfo.selfUid ?? '',
|
||||
toUid: bridge.identity.selfUid ?? '',
|
||||
forward: {
|
||||
friendName: nickname,
|
||||
},
|
||||
@@ -173,14 +173,14 @@ export async function fetchForwardNodes(bridge: Bridge, resId: string): Promise<
|
||||
const wrapped = protoEncode({ message: msgBody }, PushMsgSchema);
|
||||
const pkt: PacketInfo = {
|
||||
pid: 0,
|
||||
uin: bridge.qqInfo.uin,
|
||||
uin: bridge.identity.uin,
|
||||
serviceCmd: 'trpc.msg.olpush.OlPushService.MsgPush',
|
||||
seqId: 0,
|
||||
retCode: 0,
|
||||
fromClient: false,
|
||||
body: wrapped,
|
||||
};
|
||||
const events = parseMsgPush(pkt, bridge.qqInfo);
|
||||
const events = parseMsgPush(pkt, bridge.identity);
|
||||
const event = events.find(e =>
|
||||
e.kind === 'friend_message' || e.kind === 'group_message' || e.kind === 'temp_message');
|
||||
if (!event) continue;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// protocol uses opaque UIDs rather than QQ uin numbers.
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { sendOidbAndCheck, resolveUserUid } from '../bridge-oidb';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import {
|
||||
OidbDeleteFriendSchema,
|
||||
OidbFriendRequestActionSchema,
|
||||
@@ -13,32 +13,40 @@ import {
|
||||
export async function setFriendAddRequest(bridge: Bridge, uidOrFlag: string, approve: boolean): Promise<void> {
|
||||
let targetUid = uidOrFlag;
|
||||
if (/^\d+$/.test(uidOrFlag)) {
|
||||
targetUid = await resolveUserUid(bridge, parseInt(uidOrFlag, 10));
|
||||
targetUid = await bridge.resolveUserUid(parseInt(uidOrFlag, 10));
|
||||
}
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0xb5d_44', 0xB5D, 44,
|
||||
{ accept: approve ? 3 : 5, targetUid }, OidbFriendRequestActionSchema);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xb5d_44',
|
||||
oidbCmd: 0xB5D, subCmd: 44,
|
||||
request: { schema: OidbFriendRequestActionSchema, value: { accept: approve ? 3 : 5, targetUid } },
|
||||
});
|
||||
}
|
||||
|
||||
export async function deleteFriend(bridge: Bridge, userId: number, block = false): Promise<void> {
|
||||
const targetUid = await resolveUserUid(bridge, userId);
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x126b_0', 0x126B, 0,
|
||||
{
|
||||
field1: {
|
||||
targetUid,
|
||||
field2: {
|
||||
field1: 130,
|
||||
field2: 109,
|
||||
field3: {
|
||||
field1: 8,
|
||||
field2: 8,
|
||||
field3: 50,
|
||||
const targetUid = await bridge.resolveUserUid(userId);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x126b_0',
|
||||
oidbCmd: 0x126B, subCmd: 0,
|
||||
request: {
|
||||
schema: OidbDeleteFriendSchema,
|
||||
value: {
|
||||
field1: {
|
||||
targetUid,
|
||||
field2: {
|
||||
field1: 130,
|
||||
field2: 109,
|
||||
field3: {
|
||||
field1: 8,
|
||||
field2: 8,
|
||||
field3: 50,
|
||||
},
|
||||
},
|
||||
block,
|
||||
field4: false,
|
||||
},
|
||||
block,
|
||||
field4: false,
|
||||
},
|
||||
},
|
||||
OidbDeleteFriendSchema);
|
||||
});
|
||||
|
||||
// Refresh friend cache after deletion so subsequent reads don't
|
||||
// surface a ghost entry. Best-effort: a transient OIDB hiccup here
|
||||
@@ -47,7 +55,10 @@ export async function deleteFriend(bridge: Bridge, userId: number, block = false
|
||||
}
|
||||
|
||||
export async function setFriendRemark(bridge: Bridge, userId: number, remark: string): Promise<void> {
|
||||
const uid = await resolveUserUid(bridge, userId);
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0xb6e_2', 0xB6E, 2,
|
||||
{ targetUid: uid, remark }, OidbSetFriendRemarkSchema);
|
||||
const uid = await bridge.resolveUserUid(userId);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xb6e_2',
|
||||
oidbCmd: 0xB6E, subCmd: 2,
|
||||
request: { schema: OidbSetFriendRemarkSchema, value: { targetUid: uid, remark } },
|
||||
});
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
// so callers can grep across the two layers.
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { sendOidbAndCheck, sendOidbAndDecode, resolveUserUid } from '../bridge-oidb';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import {
|
||||
Oidb0x89a_0AddOptionSchema,
|
||||
Oidb0x89a_0SearchSchema,
|
||||
@@ -26,26 +26,50 @@ import {
|
||||
// ─────────────── mute / un-mute ───────────────
|
||||
|
||||
export async function muteGroupMember(bridge: Bridge, groupId: number, userId: number, duration: number): Promise<void> {
|
||||
const uid = await resolveUserUid(bridge, userId, groupId);
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x1253_1', 0x1253, 1,
|
||||
{ groupUin: groupId, type: 1, body: { targetUid: uid, duration } }, OidbMuteMemberSchema);
|
||||
const uid = await bridge.resolveUserUid(userId, groupId);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x1253_1',
|
||||
oidbCmd: 0x1253, subCmd: 1,
|
||||
request: {
|
||||
schema: OidbMuteMemberSchema,
|
||||
value: { groupUin: groupId, type: 1, body: { targetUid: uid, duration } },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function muteGroupAll(bridge: Bridge, groupId: number, enable: boolean): Promise<void> {
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x89a_0', 0x89A, 0,
|
||||
{ groupUin: groupId, muteState: { state: enable ? 0xFFFFFFFF : 0 } }, OidbMuteAllSchema);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x89a_0',
|
||||
oidbCmd: 0x89A, subCmd: 0,
|
||||
request: {
|
||||
schema: OidbMuteAllSchema,
|
||||
value: { groupUin: groupId, muteState: { state: enable ? 0xFFFFFFFF : 0 } },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// ─────────────── join-policy ───────────────
|
||||
|
||||
export async function setGroupAddOption(bridge: Bridge, groupId: number, addType: number): Promise<void> {
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x89a_0', 0x89A, 0,
|
||||
{ groupUin: BigInt(groupId), settings: { addType }, field12: 0 }, Oidb0x89a_0AddOptionSchema);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x89a_0',
|
||||
oidbCmd: 0x89A, subCmd: 0,
|
||||
request: {
|
||||
schema: Oidb0x89a_0AddOptionSchema,
|
||||
value: { groupUin: BigInt(groupId), settings: { addType }, field12: 0 },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function setGroupSearch(bridge: Bridge, groupId: number): Promise<void> {
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x89a_0', 0x89A, 0,
|
||||
{ groupUin: BigInt(groupId), settings: new Uint8Array(0), field12: 0 }, Oidb0x89a_0SearchSchema);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x89a_0',
|
||||
oidbCmd: 0x89A, subCmd: 0,
|
||||
request: {
|
||||
schema: Oidb0x89a_0SearchSchema,
|
||||
value: { groupUin: BigInt(groupId), settings: new Uint8Array(0), field12: 0 },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function setGroupAddRequest(
|
||||
@@ -54,53 +78,92 @@ export async function setGroupAddRequest(
|
||||
): Promise<void> {
|
||||
const subCmd = filtered ? 2 : 1;
|
||||
const cmd = filtered ? 'OidbSvcTrpcTcp.0x10c8_2' : 'OidbSvcTrpcTcp.0x10c8_1';
|
||||
await sendOidbAndCheck(bridge, cmd, 0x10C8, subCmd,
|
||||
{ accept: approve ? 1 : 2, body: { sequence: BigInt(sequence), eventType, groupUin: groupId, message: reason } },
|
||||
OidbGroupRequestActionSchema, true);
|
||||
await runOidb(bridge, {
|
||||
cmd,
|
||||
oidbCmd: 0x10C8, subCmd,
|
||||
request: {
|
||||
schema: OidbGroupRequestActionSchema,
|
||||
value: { accept: approve ? 1 : 2, body: { sequence: BigInt(sequence), eventType, groupUin: groupId, message: reason } },
|
||||
isUid: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// ─────────────── kick / leave ───────────────
|
||||
|
||||
export async function kickGroupMember(bridge: Bridge, groupId: number, userId: number, reject: boolean, reason = ''): Promise<void> {
|
||||
const uid = await resolveUserUid(bridge, userId, groupId);
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x8a0_1', 0x8A0, 1,
|
||||
{ groupUin: groupId, targetUid: uid, rejectAddRequest: reject, reason }, OidbKickMemberSchema);
|
||||
const uid = await bridge.resolveUserUid(userId, groupId);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x8a0_1',
|
||||
oidbCmd: 0x8A0, subCmd: 1,
|
||||
request: {
|
||||
schema: OidbKickMemberSchema,
|
||||
value: { groupUin: groupId, targetUid: uid, rejectAddRequest: reject, reason },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function kickGroupMembers(bridge: Bridge, groupId: number, userIds: number[], reject: boolean): Promise<void> {
|
||||
const targetUids = await Promise.all(userIds.map(userId => resolveUserUid(bridge, userId, groupId)));
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x8a0_1', 0x8A0, 1,
|
||||
{ groupId: BigInt(groupId), targetUids, rejectAddRequest: reject ? 1 : 0, kickReason: new Uint8Array(0), field12: 0 }, Oidb0x8a0ReqSchema);
|
||||
const targetUids = await Promise.all(userIds.map(userId => bridge.resolveUserUid(userId, groupId)));
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x8a0_1',
|
||||
oidbCmd: 0x8A0, subCmd: 1,
|
||||
request: {
|
||||
schema: Oidb0x8a0ReqSchema,
|
||||
value: { groupId: BigInt(groupId), targetUids, rejectAddRequest: reject ? 1 : 0, kickReason: new Uint8Array(0), field12: 0 },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function leaveGroup(bridge: Bridge, groupId: number): Promise<void> {
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x1097_1', 0x1097, 1,
|
||||
{ groupUin: groupId }, OidbLeaveGroupSchema);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x1097_1',
|
||||
oidbCmd: 0x1097, subCmd: 1,
|
||||
request: { schema: OidbLeaveGroupSchema, value: { groupUin: groupId } },
|
||||
});
|
||||
}
|
||||
|
||||
// ─────────────── role / display name ───────────────
|
||||
|
||||
export async function setGroupAdmin(bridge: Bridge, groupId: number, userId: number, enable: boolean): Promise<void> {
|
||||
const uid = await resolveUserUid(bridge, userId, groupId);
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x1096_1', 0x1096, 1,
|
||||
{ groupUin: groupId, uid, isAdmin: enable }, OidbSetAdminSchema);
|
||||
const uid = await bridge.resolveUserUid(userId, groupId);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x1096_1',
|
||||
oidbCmd: 0x1096, subCmd: 1,
|
||||
request: { schema: OidbSetAdminSchema, value: { groupUin: groupId, uid, isAdmin: enable } },
|
||||
});
|
||||
}
|
||||
|
||||
export async function setGroupCard(bridge: Bridge, groupId: number, userId: number, card: string): Promise<void> {
|
||||
const uid = await resolveUserUid(bridge, userId, groupId);
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x8fc_3', 0x8FC, 3,
|
||||
{ groupUin: groupId, body: { targetUid: uid, targetName: card } }, OidbRenameMemberSchema);
|
||||
const uid = await bridge.resolveUserUid(userId, groupId);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x8fc_3',
|
||||
oidbCmd: 0x8FC, subCmd: 3,
|
||||
request: {
|
||||
schema: OidbRenameMemberSchema,
|
||||
value: { groupUin: groupId, body: { targetUid: uid, targetName: card } },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function setGroupName(bridge: Bridge, groupId: number, name: string): Promise<void> {
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x89a_15', 0x89A, 15,
|
||||
{ groupUin: groupId, body: { targetName: name } }, OidbRenameGroupSchema);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x89a_15',
|
||||
oidbCmd: 0x89A, subCmd: 15,
|
||||
request: { schema: OidbRenameGroupSchema, value: { groupUin: groupId, body: { targetName: name } } },
|
||||
});
|
||||
}
|
||||
|
||||
export async function setGroupSpecialTitle(bridge: Bridge, groupId: number, userId: number, title: string): Promise<void> {
|
||||
const uid = await resolveUserUid(bridge, userId, groupId);
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x8fc_2', 0x8FC, 2,
|
||||
{ groupUin: groupId, body: { targetUid: uid, specialTitle: title, expireTime: -1 } }, OidbSpecialTitleSchema);
|
||||
const uid = await bridge.resolveUserUid(userId, groupId);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x8fc_2',
|
||||
oidbCmd: 0x8FC, subCmd: 2,
|
||||
request: {
|
||||
schema: OidbSpecialTitleSchema,
|
||||
value: { groupUin: groupId, body: { targetUid: uid, specialTitle: title, expireTime: -1 } },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// ─────────────── personal-side metadata ───────────────
|
||||
@@ -109,8 +172,11 @@ export async function setGroupSpecialTitle(bridge: Bridge, groupId: number, user
|
||||
// here rather than in friend.ts because the semantic is "operate on a
|
||||
// group" rather than "operate on a contact list".
|
||||
export async function setGroupRemark(bridge: Bridge, groupId: number, remark: string): Promise<void> {
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0xf16_1', 0xF16, 1,
|
||||
{ inner: { groupId: BigInt(groupId), remark }, field12: 0 }, Oidb0xf16ReqSchema);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xf16_1',
|
||||
oidbCmd: 0xF16, subCmd: 1,
|
||||
request: { schema: Oidb0xf16ReqSchema, value: { inner: { groupId: BigInt(groupId), remark }, field12: 0 } },
|
||||
});
|
||||
}
|
||||
|
||||
// ─────────────── group-level quota query ───────────────
|
||||
@@ -123,20 +189,17 @@ export async function getGroupAtAllRemain(
|
||||
basic1: 1,
|
||||
basic2: 2,
|
||||
basic3: 1,
|
||||
uin: BigInt(bridge.qqInfo.uin),
|
||||
uin: BigInt(bridge.identity.uin),
|
||||
groupId: BigInt(groupId),
|
||||
type: 0,
|
||||
};
|
||||
|
||||
const result = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0x8a7_0',
|
||||
0x8A7,
|
||||
0,
|
||||
req,
|
||||
Oidb0x8a7ReqSchema,
|
||||
Oidb0x8a7RespSchema,
|
||||
);
|
||||
const result = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x8a7_0',
|
||||
oidbCmd: 0x8A7, subCmd: 0,
|
||||
request: { schema: Oidb0x8a7ReqSchema, value: req },
|
||||
response: { schema: Oidb0x8a7RespSchema },
|
||||
});
|
||||
|
||||
if (!result) {
|
||||
throw new Error('get group at all remain result empty');
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { protoEncode } from '../../protobuf/decode';
|
||||
import { sendOidbAndDecode, resolveUserUid } from '../bridge-oidb';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import { fetchHighwaySession, uploadHighwayHttp } from '../highway/highway-client';
|
||||
import { computeHashes, computeMd5, loadBinarySource } from '../highway/utils';
|
||||
import {
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
NTV2RichMediaRespSchema,
|
||||
} from '../proto/oidb-action';
|
||||
import { FileUploadExtSchema } from '../proto/highway';
|
||||
import { toHexUpper } from '../../utils/hex';
|
||||
import { ensureRetCodeZero, resolveSelfUid, toInt, type MediaIndexNode } from './shared';
|
||||
|
||||
// ─────────────── public result types ───────────────
|
||||
@@ -76,7 +77,7 @@ function normalizeDirectory(dir?: string): string {
|
||||
|
||||
function bytesToHexUpper(data: unknown): string {
|
||||
if (!(data instanceof Uint8Array) || data.length === 0) return '';
|
||||
return Buffer.from(data).toString('hex').toUpperCase();
|
||||
return toHexUpper(data);
|
||||
}
|
||||
|
||||
function normalizeUploadFileName(name: string, fallback: string): string {
|
||||
@@ -241,16 +242,12 @@ async function fetchNtv2DownloadUrl(
|
||||
oidbCmd: number,
|
||||
payload: Record<string, unknown>,
|
||||
): Promise<string> {
|
||||
const resp = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
serviceCmd,
|
||||
oidbCmd,
|
||||
200,
|
||||
payload,
|
||||
NTV2RichMediaReqSchema,
|
||||
NTV2RichMediaRespSchema,
|
||||
true,
|
||||
);
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: serviceCmd,
|
||||
oidbCmd, subCmd: 200,
|
||||
request: { schema: NTV2RichMediaReqSchema, value: payload, isUid: true },
|
||||
response: { schema: NTV2RichMediaRespSchema },
|
||||
});
|
||||
|
||||
ensureRetCodeZero('ntv2 download', resp?.respHead?.retCode, resp?.respHead?.message, undefined);
|
||||
const domain = typeof resp?.download?.info?.domain === 'string' ? resp.download.info.domain : '';
|
||||
@@ -266,11 +263,15 @@ async function fetchNtv2DownloadUrl(
|
||||
// ─────────────── file count ───────────────
|
||||
|
||||
export async function fetchGroupFileCount(bridge: Bridge, groupId: number): Promise<{ fileCount: number; maxCount: number }> {
|
||||
const resp = await sendOidbAndDecode<any>(bridge,
|
||||
'OidbSvcTrpcTcp.0x6d8_3', 0x6D8, 3,
|
||||
{ count: { groupUin: groupId, appId: 7, busId: 0 } },
|
||||
OidbGroupFileCountViewReqSchema,
|
||||
OidbGroupFileCountViewRespSchema);
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d8_3',
|
||||
oidbCmd: 0x6D8, subCmd: 3,
|
||||
request: {
|
||||
schema: OidbGroupFileCountViewReqSchema,
|
||||
value: { count: { groupUin: groupId, appId: 7, busId: 0 } },
|
||||
},
|
||||
response: { schema: OidbGroupFileCountViewRespSchema },
|
||||
});
|
||||
return {
|
||||
fileCount: toInt(resp?.count?.fileCount ?? 0),
|
||||
maxCount: toInt(resp?.count?.maxCount ?? 10000),
|
||||
@@ -293,31 +294,31 @@ export async function uploadGroupFile(
|
||||
const fileName = normalizeUploadFileName(name, loaded.fileName);
|
||||
const hashes = computeHashes(loaded.bytes);
|
||||
|
||||
const resp = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0x6d6_0',
|
||||
0x6D6,
|
||||
0,
|
||||
{
|
||||
file: {
|
||||
groupUin: groupId,
|
||||
appId: 4,
|
||||
busId: 102,
|
||||
entrance: 6,
|
||||
targetDirectory: normalizeDirectory(folderId),
|
||||
fileName,
|
||||
localDirectory: `/${fileName}`,
|
||||
fileSize: BigInt(loaded.bytes.length),
|
||||
fileSha1: hashes.sha1,
|
||||
fileSha3: new Uint8Array(0),
|
||||
fileMd5: hashes.md5,
|
||||
field15: true,
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d6_0',
|
||||
oidbCmd: 0x6D6, subCmd: 0,
|
||||
request: {
|
||||
schema: OidbGroupFileReqSchema,
|
||||
value: {
|
||||
file: {
|
||||
groupUin: groupId,
|
||||
appId: 4,
|
||||
busId: 102,
|
||||
entrance: 6,
|
||||
targetDirectory: normalizeDirectory(folderId),
|
||||
fileName,
|
||||
localDirectory: `/${fileName}`,
|
||||
fileSize: BigInt(loaded.bytes.length),
|
||||
fileSha1: hashes.sha1,
|
||||
fileSha3: new Uint8Array(0),
|
||||
fileMd5: hashes.md5,
|
||||
field15: true,
|
||||
},
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
OidbGroupFileReqSchema,
|
||||
OidbGroupFileRespSchema,
|
||||
true,
|
||||
);
|
||||
response: { schema: OidbGroupFileRespSchema },
|
||||
});
|
||||
|
||||
const upload = resp?.upload;
|
||||
if (!upload) throw new Error('group file upload response missing');
|
||||
@@ -327,7 +328,7 @@ export async function uploadGroupFile(
|
||||
if (!fileId) throw new Error('group file upload response missing file_id');
|
||||
|
||||
if (!upload.boolFileExist && uploadFile) {
|
||||
const senderUin = toInt(bridge.qqInfo.uin);
|
||||
const senderUin = toInt(bridge.identity.uin);
|
||||
if (senderUin <= 0) throw new Error('invalid self uin for group file upload');
|
||||
|
||||
const uploadHost = (typeof upload.uploadIp === 'string' && upload.uploadIp)
|
||||
@@ -368,48 +369,48 @@ export async function uploadPrivateFile(
|
||||
const loaded = await loadBinarySource(source, 'file');
|
||||
if (!loaded.bytes.length) throw new Error('private file is empty');
|
||||
|
||||
const targetUid = await resolveUserUid(bridge, userId);
|
||||
let selfUid = bridge.qqInfo.selfUid;
|
||||
const targetUid = await bridge.resolveUserUid(userId);
|
||||
let selfUid = bridge.identity.selfUid;
|
||||
if (!selfUid) {
|
||||
const selfUin = toInt(bridge.qqInfo.uin);
|
||||
const selfUin = toInt(bridge.identity.uin);
|
||||
if (selfUin > 0) {
|
||||
selfUid = await resolveUserUid(bridge, selfUin);
|
||||
selfUid = await bridge.resolveUserUid(selfUin);
|
||||
}
|
||||
}
|
||||
if (!selfUid) throw new Error('self uid is unavailable');
|
||||
|
||||
const senderUin = toInt(bridge.qqInfo.uin);
|
||||
const senderUin = toInt(bridge.identity.uin);
|
||||
if (senderUin <= 0) throw new Error('invalid self uin for private file upload');
|
||||
|
||||
const fileName = normalizeUploadFileName(name, loaded.fileName);
|
||||
const hashes = computeHashes(loaded.bytes);
|
||||
|
||||
const resp = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0xe37_1700',
|
||||
0xE37,
|
||||
1700,
|
||||
{
|
||||
command: 1700,
|
||||
seq: 0,
|
||||
upload: {
|
||||
senderUid: selfUid,
|
||||
receiverUid: targetUid,
|
||||
fileSize: loaded.bytes.length,
|
||||
fileName,
|
||||
md510MCheckSum: md5First10MB(loaded.bytes),
|
||||
sha1CheckSum: hashes.sha1,
|
||||
localPath: '/',
|
||||
md5CheckSum: hashes.md5,
|
||||
sha3CheckSum: new Uint8Array(0),
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xe37_1700',
|
||||
oidbCmd: 0xE37, subCmd: 1700,
|
||||
request: {
|
||||
schema: OidbPrivateFileUploadReqSchema,
|
||||
value: {
|
||||
command: 1700,
|
||||
seq: 0,
|
||||
upload: {
|
||||
senderUid: selfUid,
|
||||
receiverUid: targetUid,
|
||||
fileSize: loaded.bytes.length,
|
||||
fileName,
|
||||
md510MCheckSum: md5First10MB(loaded.bytes),
|
||||
sha1CheckSum: hashes.sha1,
|
||||
localPath: '/',
|
||||
md5CheckSum: hashes.md5,
|
||||
sha3CheckSum: new Uint8Array(0),
|
||||
},
|
||||
businessId: 3,
|
||||
clientType: 1,
|
||||
flagSupportMediaPlatform: 1,
|
||||
},
|
||||
businessId: 3,
|
||||
clientType: 1,
|
||||
flagSupportMediaPlatform: 1,
|
||||
},
|
||||
OidbPrivateFileUploadReqSchema,
|
||||
OidbPrivateFileUploadRespSchema,
|
||||
);
|
||||
response: { schema: OidbPrivateFileUploadRespSchema },
|
||||
});
|
||||
|
||||
const upload = resp?.upload;
|
||||
if (!upload) throw new Error('private file upload response missing');
|
||||
@@ -458,27 +459,27 @@ export async function fetchGroupFiles(bridge: Bridge, groupId: number, folderId
|
||||
const pageSize = 20;
|
||||
let startIndex = 0;
|
||||
for (let page = 0; page < 200; page++) {
|
||||
const resp = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0x6d8_1',
|
||||
0x6D8,
|
||||
1,
|
||||
{
|
||||
list: {
|
||||
groupUin: groupId,
|
||||
appId: 7,
|
||||
targetDirectory,
|
||||
fileCount: pageSize,
|
||||
sortBy: 1,
|
||||
startIndex,
|
||||
field17: 2,
|
||||
field18: 0,
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d8_1',
|
||||
oidbCmd: 0x6D8, subCmd: 1,
|
||||
request: {
|
||||
schema: OidbGroupFileViewReqSchema,
|
||||
value: {
|
||||
list: {
|
||||
groupUin: groupId,
|
||||
appId: 7,
|
||||
targetDirectory,
|
||||
fileCount: pageSize,
|
||||
sortBy: 1,
|
||||
startIndex,
|
||||
field17: 2,
|
||||
field18: 0,
|
||||
},
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
OidbGroupFileViewReqSchema,
|
||||
OidbGroupFileViewRespSchema,
|
||||
true,
|
||||
);
|
||||
response: { schema: OidbGroupFileViewRespSchema },
|
||||
});
|
||||
|
||||
const list = resp?.list;
|
||||
if (!list) break;
|
||||
@@ -489,7 +490,7 @@ export async function fetchGroupFiles(bridge: Bridge, groupId: number, folderId
|
||||
if (type === 1 && item?.fileInfo) {
|
||||
const file = item.fileInfo;
|
||||
const uploader = toInt(file.uploaderUin);
|
||||
const cached = bridge.qqInfo.findGroupMember(groupId, uploader);
|
||||
const cached = bridge.identity.findGroupMember(groupId, uploader);
|
||||
files.push({
|
||||
fileId: typeof file.fileId === 'string' ? file.fileId : '',
|
||||
fileName: typeof file.fileName === 'string' ? file.fileName : '',
|
||||
@@ -508,7 +509,7 @@ export async function fetchGroupFiles(bridge: Bridge, groupId: number, folderId
|
||||
} else if (type === 2 && item?.folderInfo) {
|
||||
const folder = item.folderInfo;
|
||||
const creator = toInt(folder.creatorUin);
|
||||
const cached = bridge.qqInfo.findGroupMember(groupId, creator);
|
||||
const cached = bridge.identity.findGroupMember(groupId, creator);
|
||||
folders.push({
|
||||
folderId: typeof folder.folderId === 'string' ? folder.folderId : '',
|
||||
folderName: typeof folder.folderName === 'string' ? folder.folderName : '',
|
||||
@@ -533,23 +534,23 @@ export async function fetchGroupFiles(bridge: Bridge, groupId: number, folderId
|
||||
// ─────────────── url fetch (group / private files) ───────────────
|
||||
|
||||
export async function fetchGroupFileUrl(bridge: Bridge, groupId: number, fileId: string, busId = 102): Promise<string> {
|
||||
const resp = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0x6d6_2',
|
||||
0x6D6,
|
||||
2,
|
||||
{
|
||||
download: {
|
||||
groupUin: groupId,
|
||||
appId: 7,
|
||||
busId,
|
||||
fileId,
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d6_2',
|
||||
oidbCmd: 0x6D6, subCmd: 2,
|
||||
request: {
|
||||
schema: OidbGroupFileReqSchema,
|
||||
value: {
|
||||
download: {
|
||||
groupUin: groupId,
|
||||
appId: 7,
|
||||
busId,
|
||||
fileId,
|
||||
},
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
OidbGroupFileReqSchema,
|
||||
OidbGroupFileRespSchema,
|
||||
true,
|
||||
);
|
||||
response: { schema: OidbGroupFileRespSchema },
|
||||
});
|
||||
|
||||
const download = resp?.download;
|
||||
if (!download) throw new Error('group file url response missing');
|
||||
@@ -568,30 +569,30 @@ export async function fetchGroupFileUrl(bridge: Bridge, groupId: number, fileId:
|
||||
}
|
||||
|
||||
export async function fetchPrivateFileUrl(bridge: Bridge, userId: number, fileId: string, fileHash: string): Promise<string> {
|
||||
const uid = await resolveUserUid(bridge, userId);
|
||||
const resp = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0xe37_1200',
|
||||
0xE37,
|
||||
1200,
|
||||
{
|
||||
subCommand: 1200,
|
||||
field2: 1,
|
||||
body: {
|
||||
receiverUid: uid,
|
||||
fileUuid: fileId,
|
||||
type: 2,
|
||||
fileHash,
|
||||
t2: 0,
|
||||
const uid = await bridge.resolveUserUid(userId);
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xe37_1200',
|
||||
oidbCmd: 0xE37, subCmd: 1200,
|
||||
request: {
|
||||
schema: OidbPrivateFileDownloadReqSchema,
|
||||
value: {
|
||||
subCommand: 1200,
|
||||
field2: 1,
|
||||
body: {
|
||||
receiverUid: uid,
|
||||
fileUuid: fileId,
|
||||
type: 2,
|
||||
fileHash,
|
||||
t2: 0,
|
||||
},
|
||||
field101: 3,
|
||||
field102: 103,
|
||||
field200: 1,
|
||||
field99999: new Uint8Array([0xC0, 0x85, 0x2C, 0x01]),
|
||||
},
|
||||
field101: 3,
|
||||
field102: 103,
|
||||
field200: 1,
|
||||
field99999: new Uint8Array([0xC0, 0x85, 0x2C, 0x01]),
|
||||
},
|
||||
OidbPrivateFileDownloadReqSchema,
|
||||
OidbPrivateFileDownloadRespSchema,
|
||||
);
|
||||
response: { schema: OidbPrivateFileDownloadRespSchema },
|
||||
});
|
||||
|
||||
const result = resp?.body?.result;
|
||||
const server = typeof result?.server === 'string' ? result.server : '';
|
||||
@@ -606,22 +607,22 @@ export async function fetchPrivateFileUrl(bridge: Bridge, userId: number, fileId
|
||||
// ─────────────── delete / move ───────────────
|
||||
|
||||
export async function deleteGroupFile(bridge: Bridge, groupId: number, fileId: string): Promise<void> {
|
||||
const resp = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0x6d6_3',
|
||||
0x6D6,
|
||||
3,
|
||||
{
|
||||
delete: {
|
||||
groupUin: groupId,
|
||||
busId: 102,
|
||||
fileId,
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d6_3',
|
||||
oidbCmd: 0x6D6, subCmd: 3,
|
||||
request: {
|
||||
schema: OidbGroupFileReqSchema,
|
||||
value: {
|
||||
delete: {
|
||||
groupUin: groupId,
|
||||
busId: 102,
|
||||
fileId,
|
||||
},
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
OidbGroupFileReqSchema,
|
||||
OidbGroupFileRespSchema,
|
||||
true,
|
||||
);
|
||||
response: { schema: OidbGroupFileRespSchema },
|
||||
});
|
||||
|
||||
const result = resp?.delete;
|
||||
if (!result) throw new Error('group file delete response missing');
|
||||
@@ -635,25 +636,25 @@ export async function moveGroupFile(
|
||||
parentDirectory: string,
|
||||
targetDirectory: string,
|
||||
): Promise<void> {
|
||||
const resp = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0x6d6_5',
|
||||
0x6D6,
|
||||
5,
|
||||
{
|
||||
move: {
|
||||
groupUin: groupId,
|
||||
appId: 7,
|
||||
busId: 102,
|
||||
fileId,
|
||||
parentDirectory,
|
||||
targetDirectory,
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d6_5',
|
||||
oidbCmd: 0x6D6, subCmd: 5,
|
||||
request: {
|
||||
schema: OidbGroupFileReqSchema,
|
||||
value: {
|
||||
move: {
|
||||
groupUin: groupId,
|
||||
appId: 7,
|
||||
busId: 102,
|
||||
fileId,
|
||||
parentDirectory,
|
||||
targetDirectory,
|
||||
},
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
OidbGroupFileReqSchema,
|
||||
OidbGroupFileRespSchema,
|
||||
true,
|
||||
);
|
||||
response: { schema: OidbGroupFileRespSchema },
|
||||
});
|
||||
|
||||
const result = resp?.move;
|
||||
if (!result) throw new Error('group file move response missing');
|
||||
@@ -663,22 +664,22 @@ export async function moveGroupFile(
|
||||
// ─────────────── folders ───────────────
|
||||
|
||||
export async function createGroupFileFolder(bridge: Bridge, groupId: number, name: string, parentId = '/'): Promise<void> {
|
||||
const resp = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0x6d7_0',
|
||||
0x6D7,
|
||||
0,
|
||||
{
|
||||
create: {
|
||||
groupUin: groupId,
|
||||
rootDirectory: normalizeDirectory(parentId),
|
||||
folderName: name,
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d7_0',
|
||||
oidbCmd: 0x6D7, subCmd: 0,
|
||||
request: {
|
||||
schema: OidbGroupFileFolderReqSchema,
|
||||
value: {
|
||||
create: {
|
||||
groupUin: groupId,
|
||||
rootDirectory: normalizeDirectory(parentId),
|
||||
folderName: name,
|
||||
},
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
OidbGroupFileFolderReqSchema,
|
||||
OidbGroupFileFolderRespSchema,
|
||||
true,
|
||||
);
|
||||
response: { schema: OidbGroupFileFolderRespSchema },
|
||||
});
|
||||
|
||||
const result = resp?.create;
|
||||
if (!result) throw new Error('group folder create response missing');
|
||||
@@ -686,21 +687,21 @@ export async function createGroupFileFolder(bridge: Bridge, groupId: number, nam
|
||||
}
|
||||
|
||||
export async function deleteGroupFileFolder(bridge: Bridge, groupId: number, folderId: string): Promise<void> {
|
||||
const resp = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0x6d7_1',
|
||||
0x6D7,
|
||||
1,
|
||||
{
|
||||
delete: {
|
||||
groupUin: groupId,
|
||||
folderId,
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d7_1',
|
||||
oidbCmd: 0x6D7, subCmd: 1,
|
||||
request: {
|
||||
schema: OidbGroupFileFolderReqSchema,
|
||||
value: {
|
||||
delete: {
|
||||
groupUin: groupId,
|
||||
folderId,
|
||||
},
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
OidbGroupFileFolderReqSchema,
|
||||
OidbGroupFileFolderRespSchema,
|
||||
true,
|
||||
);
|
||||
response: { schema: OidbGroupFileFolderRespSchema },
|
||||
});
|
||||
|
||||
const result = resp?.delete;
|
||||
if (!result) throw new Error('group folder delete response missing');
|
||||
@@ -708,22 +709,22 @@ export async function deleteGroupFileFolder(bridge: Bridge, groupId: number, fol
|
||||
}
|
||||
|
||||
export async function renameGroupFileFolder(bridge: Bridge, groupId: number, folderId: string, newFolderName: string): Promise<void> {
|
||||
const resp = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0x6d7_2',
|
||||
0x6D7,
|
||||
2,
|
||||
{
|
||||
rename: {
|
||||
groupUin: groupId,
|
||||
folderId,
|
||||
newFolderName,
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d7_2',
|
||||
oidbCmd: 0x6D7, subCmd: 2,
|
||||
request: {
|
||||
schema: OidbGroupFileFolderReqSchema,
|
||||
value: {
|
||||
rename: {
|
||||
groupUin: groupId,
|
||||
folderId,
|
||||
newFolderName,
|
||||
},
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
OidbGroupFileFolderReqSchema,
|
||||
OidbGroupFileFolderRespSchema,
|
||||
true,
|
||||
);
|
||||
response: { schema: OidbGroupFileFolderRespSchema },
|
||||
});
|
||||
|
||||
const result = resp?.rename;
|
||||
if (!result) throw new Error('group folder rename response missing');
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { protoEncode } from '../../protobuf/decode';
|
||||
import { sendOidbAndCheck, resolveUserUid } from '../bridge-oidb';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import {
|
||||
C2CRecallRequestSchema,
|
||||
GroupRecallRequestSchema,
|
||||
@@ -28,7 +28,7 @@ export async function recallPrivateMessage(
|
||||
bridge: Bridge, userUin: number, clientSeq: number,
|
||||
msgSeq: number, random: number, timestamp: number,
|
||||
): Promise<void> {
|
||||
const targetUid = await resolveUserUid(bridge, userUin);
|
||||
const targetUid = await bridge.resolveUserUid(userUin);
|
||||
const request = protoEncode({
|
||||
type: 1,
|
||||
targetUid,
|
||||
@@ -53,7 +53,7 @@ export async function markPrivateMessageRead(
|
||||
msgSeq: number,
|
||||
timestamp: number = Math.floor(Date.now() / 1000),
|
||||
): Promise<void> {
|
||||
const uid = await resolveUserUid(bridge, userId);
|
||||
const uid = await bridge.resolveUserUid(userId);
|
||||
|
||||
const request = protoEncode({
|
||||
c2cList: [
|
||||
@@ -96,6 +96,9 @@ export async function markGroupMessageRead(
|
||||
export async function setGroupEssence(bridge: Bridge, groupId: number, sequence: number, random: number, enable: boolean): Promise<void> {
|
||||
const subCmd = enable ? 1 : 2;
|
||||
const cmd = enable ? 'OidbSvcTrpcTcp.0xeac_1' : 'OidbSvcTrpcTcp.0xeac_2';
|
||||
await sendOidbAndCheck(bridge, cmd, 0xEAC, subCmd,
|
||||
{ groupUin: groupId, sequence, random }, OidbEssenceSchema);
|
||||
await runOidb(bridge, {
|
||||
cmd,
|
||||
oidbCmd: 0xEAC, subCmd,
|
||||
request: { schema: OidbEssenceSchema, value: { groupUin: groupId, sequence, random } },
|
||||
});
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
// edit message content — they're purely social signals.
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { sendOidbAndCheck, sendOidbAndDecode } from '../bridge-oidb';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import {
|
||||
Oidb0x9083ReqSchema,
|
||||
Oidb0x9083RespSchema,
|
||||
@@ -13,25 +13,45 @@ import {
|
||||
} from '../proto/oidb-action';
|
||||
|
||||
export async function sendPoke(bridge: Bridge, isGroup: boolean, peerUin: number, targetUin?: number): Promise<void> {
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0xed3_1', 0xED3, 1,
|
||||
{
|
||||
uin: targetUin ?? peerUin,
|
||||
groupUin: isGroup ? peerUin : 0,
|
||||
friendUin: isGroup ? 0 : peerUin,
|
||||
ext: 0,
|
||||
}, OidbPokeSchema);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xed3_1',
|
||||
oidbCmd: 0xED3, subCmd: 1,
|
||||
request: {
|
||||
schema: OidbPokeSchema,
|
||||
value: {
|
||||
uin: targetUin ?? peerUin,
|
||||
groupUin: isGroup ? peerUin : 0,
|
||||
friendUin: isGroup ? 0 : peerUin,
|
||||
ext: 0,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function sendLike(bridge: Bridge, userId: number, count: number): Promise<void> {
|
||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x7e5_104', 0x7E5, 104,
|
||||
{ targetUin: userId, count }, OidbLikeSchema);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x7e5_104',
|
||||
oidbCmd: 0x7E5, subCmd: 104,
|
||||
request: { schema: OidbLikeSchema, value: { targetUin: userId, count } },
|
||||
});
|
||||
}
|
||||
|
||||
export async function setGroupReaction(bridge: Bridge, groupId: number, sequence: number, code: string, isSet: boolean): Promise<void> {
|
||||
const subCmd = isSet ? 1 : 2;
|
||||
const cmd = isSet ? 'OidbSvcTrpcTcp.0x9082_1' : 'OidbSvcTrpcTcp.0x9082_2';
|
||||
await sendOidbAndCheck(bridge, cmd, 0x9082, subCmd,
|
||||
{ groupUin: groupId, sequence, code }, OidbGroupReactionSchema);
|
||||
// Same heuristic NapCat uses: QQ face ids are 1–3 digits ("76"),
|
||||
// unicode codepoints are longer ("128516"). Server requires the
|
||||
// type field to pick the right resolution table; omitting it makes
|
||||
// unicode reactions silently fail.
|
||||
const type = code.length > 3 ? 2 : 1;
|
||||
await runOidb(bridge, {
|
||||
cmd,
|
||||
oidbCmd: 0x9082, subCmd,
|
||||
request: {
|
||||
schema: OidbGroupReactionSchema,
|
||||
value: { groupUin: groupId, sequence, code, type },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getEmojiLikes(
|
||||
@@ -53,7 +73,12 @@ export async function getEmojiLikes(
|
||||
count,
|
||||
field12: 1,
|
||||
};
|
||||
const resp = await sendOidbAndDecode<any>(bridge, 'OidbSvcTrpcTcp.0x9083_1', 0x9083, 1, req, Oidb0x9083ReqSchema, Oidb0x9083RespSchema);
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x9083_1',
|
||||
oidbCmd: 0x9083, subCmd: 1,
|
||||
request: { schema: Oidb0x9083ReqSchema, value: req },
|
||||
response: { schema: Oidb0x9083RespSchema },
|
||||
});
|
||||
const uin = resp?.inner?.userInfo?.uin;
|
||||
const users = uin ? [{ uin: Number(uin) }] : [];
|
||||
const respCookie = resp?.cookie ? Buffer.from(resp.cookie).toString('base64') : '';
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { protoDecode, protoEncode } from '../../protobuf/decode';
|
||||
import { sendOidbAndDecode } from '../bridge-oidb';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import {
|
||||
MiniAppShareReqSchema,
|
||||
MiniAppShareRespSchema,
|
||||
@@ -30,15 +30,12 @@ export async function translateEn2Zh(
|
||||
tag12: 1,
|
||||
};
|
||||
|
||||
const result = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0x990_2',
|
||||
0x990,
|
||||
2,
|
||||
req,
|
||||
Oidb0x990ReqSchema,
|
||||
Oidb0x990RespSchema,
|
||||
);
|
||||
const result = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x990_2',
|
||||
oidbCmd: 0x990, subCmd: 2,
|
||||
request: { schema: Oidb0x990ReqSchema, value: req },
|
||||
response: { schema: Oidb0x990RespSchema },
|
||||
});
|
||||
|
||||
const resp = result?.translateResp;
|
||||
if (!resp) {
|
||||
@@ -125,15 +122,12 @@ export async function clickInlineKeyboardButton(
|
||||
unknown9: 1,
|
||||
};
|
||||
|
||||
const result = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0x112e_1',
|
||||
0x112E,
|
||||
1,
|
||||
req,
|
||||
Oidb0x112eReqSchema,
|
||||
Oidb0x112eRespSchema,
|
||||
);
|
||||
const result = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x112e_1',
|
||||
oidbCmd: 0x112E, subCmd: 1,
|
||||
request: { schema: Oidb0x112eReqSchema, value: req },
|
||||
response: { schema: Oidb0x112eRespSchema },
|
||||
});
|
||||
|
||||
if (!result) {
|
||||
throw new Error('click inline keyboard button result empty');
|
||||
@@ -155,19 +149,16 @@ export async function sendGroupSign(
|
||||
) {
|
||||
const req = {
|
||||
signInInfo: {
|
||||
uin: String(bridge.qqInfo.uin),
|
||||
uin: String(bridge.identity.uin),
|
||||
groupId: String(groupId),
|
||||
version: '9.0.90',
|
||||
},
|
||||
};
|
||||
|
||||
await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0xEB7_1',
|
||||
0xEB7,
|
||||
1,
|
||||
req,
|
||||
Oidb0xeb7ReqSchema,
|
||||
Oidb0xeb7RespSchema,
|
||||
);
|
||||
await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xEB7_1',
|
||||
oidbCmd: 0xEB7, subCmd: 1,
|
||||
request: { schema: Oidb0xeb7ReqSchema, value: req },
|
||||
response: { schema: Oidb0xeb7RespSchema },
|
||||
});
|
||||
}
|
||||
@@ -4,12 +4,13 @@
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { protoDecode, protoEncode } from '../../protobuf/decode';
|
||||
import { sendOidbAndCheck, sendOidbAndDecode, resolveUserUid } from '../bridge-oidb';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import { fetchHighwaySession, uploadHighwayHttp } from '../highway/highway-client';
|
||||
import { computeHashes, loadBinarySource } from '../highway/utils';
|
||||
import {
|
||||
FaceroamOpReqSchema,
|
||||
FaceroamOpRespSchema,
|
||||
GroupAvatarExtraSchema,
|
||||
Oidb0x112aReqSchema,
|
||||
Oidb0x112aRespSchema,
|
||||
Oidb0x7edReqSchema,
|
||||
@@ -32,11 +33,39 @@ export async function setOnlineStatus(
|
||||
extStatus: number = 0,
|
||||
batteryStatus: number = 100,
|
||||
): Promise<void> {
|
||||
const request = protoEncode({
|
||||
status,
|
||||
extStatus,
|
||||
batteryStatus,
|
||||
}, SetStatusReqSchema);
|
||||
await dispatchSetStatus(bridge, { status, extStatus, batteryStatus });
|
||||
}
|
||||
|
||||
/**
|
||||
* DIY (custom) online status. napcat fixes status=10 / extStatus=2000
|
||||
* — the values QQ associates with "I have a custom status string" —
|
||||
* and threads the faceId / wording / faceType through the customExt
|
||||
* sub-message of the same SetStatus wire call.
|
||||
*/
|
||||
export async function setDiyOnlineStatus(
|
||||
bridge: Bridge,
|
||||
faceId: number,
|
||||
wording: string,
|
||||
faceType: number,
|
||||
): Promise<void> {
|
||||
await dispatchSetStatus(bridge, {
|
||||
status: 10,
|
||||
extStatus: 2000,
|
||||
batteryStatus: 0,
|
||||
customExt: { faceId, text: wording, faceType },
|
||||
});
|
||||
}
|
||||
|
||||
async function dispatchSetStatus(
|
||||
bridge: Bridge,
|
||||
value: {
|
||||
status: number;
|
||||
extStatus: number;
|
||||
batteryStatus: number;
|
||||
customExt?: { faceId: number; text: string; faceType: number };
|
||||
},
|
||||
): Promise<void> {
|
||||
const request = protoEncode(value, SetStatusReqSchema);
|
||||
|
||||
const result = await bridge.sendRawPacket('trpc.qq_new_tech.status_svc.StatusService.SetStatus', request);
|
||||
|
||||
@@ -60,7 +89,7 @@ export async function setProfile(
|
||||
nickname?: string,
|
||||
personalNote?: string,
|
||||
): Promise<void> {
|
||||
const uin = BigInt(bridge.qqInfo.uin);
|
||||
const uin = BigInt(bridge.identity.uin);
|
||||
const stringProfiles: any[] = [];
|
||||
const intProfiles: any[] = [];
|
||||
|
||||
@@ -81,14 +110,11 @@ export async function setProfile(
|
||||
stringProfiles,
|
||||
};
|
||||
|
||||
await sendOidbAndCheck(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0x112a_2',
|
||||
0x112A,
|
||||
2,
|
||||
req,
|
||||
OidbSetProfileSchema,
|
||||
);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x112a_2',
|
||||
oidbCmd: 0x112A, subCmd: 2,
|
||||
request: { schema: OidbSetProfileSchema, value: req },
|
||||
});
|
||||
}
|
||||
|
||||
export async function setSelfLongNick(
|
||||
@@ -96,22 +122,19 @@ export async function setSelfLongNick(
|
||||
longNick: string,
|
||||
) {
|
||||
const req = {
|
||||
uin: BigInt(bridge.qqInfo.uin),
|
||||
uin: BigInt(bridge.identity.uin),
|
||||
profile: {
|
||||
tag: 102,
|
||||
value: String(longNick),
|
||||
},
|
||||
};
|
||||
|
||||
await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0x112a_2',
|
||||
0x112A,
|
||||
2,
|
||||
req,
|
||||
Oidb0x112aReqSchema,
|
||||
Oidb0x112aRespSchema,
|
||||
);
|
||||
await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x112a_2',
|
||||
oidbCmd: 0x112A, subCmd: 2,
|
||||
request: { schema: Oidb0x112aReqSchema, value: req },
|
||||
response: { schema: Oidb0x112aRespSchema },
|
||||
});
|
||||
}
|
||||
|
||||
export async function setInputStatus(
|
||||
@@ -119,7 +142,7 @@ export async function setInputStatus(
|
||||
userId: number,
|
||||
eventType: number,
|
||||
) {
|
||||
const targetUid = await resolveUserUid(bridge, userId);
|
||||
const targetUid = await bridge.resolveUserUid(userId);
|
||||
|
||||
if (!targetUid) {
|
||||
throw new Error('target uid not found');
|
||||
@@ -133,15 +156,12 @@ export async function setInputStatus(
|
||||
},
|
||||
};
|
||||
|
||||
await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0xcd4_1',
|
||||
0xCD4,
|
||||
1,
|
||||
req,
|
||||
Oidb0xcd4ReqSchema,
|
||||
Oidb0xcd4RespSchema,
|
||||
);
|
||||
await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xcd4_1',
|
||||
oidbCmd: 0xCD4, subCmd: 1,
|
||||
request: { schema: Oidb0xcd4ReqSchema, value: req },
|
||||
response: { schema: Oidb0xcd4RespSchema },
|
||||
});
|
||||
}
|
||||
|
||||
export async function setAvatar(
|
||||
@@ -156,6 +176,36 @@ export async function setAvatar(
|
||||
await uploadHighwayHttp(bridge, session, 90, loaded.bytes, hashes.md5, new Uint8Array(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set group avatar. Mirrors Lagrange.Core's GroupSetAvatar:
|
||||
* - same highway HTTP upload as personal avatar
|
||||
* - cmdId 3000 (instead of 90)
|
||||
* - GroupAvatarExtra proto carried as the `extend` blob, with the
|
||||
* four protocol-prescribed constants (type=101, field5=3, field6=1,
|
||||
* field3.field1=1) and the target groupUin.
|
||||
*
|
||||
* Source ref: Lagrange.Core/Internal/Context/Logic/Implementation/OperationLogic.cs#GroupSetAvatar.
|
||||
*/
|
||||
export async function setGroupAvatar(
|
||||
bridge: Bridge,
|
||||
groupId: number,
|
||||
source: string,
|
||||
): Promise<void> {
|
||||
const loaded = await loadBinarySource(source, 'group-avatar');
|
||||
if (!loaded.bytes.length) throw new Error('group avatar file is empty');
|
||||
|
||||
const hashes = computeHashes(loaded.bytes);
|
||||
const session = await fetchHighwaySession(bridge);
|
||||
const extra = protoEncode({
|
||||
type: 101,
|
||||
groupUin: groupId,
|
||||
field3: { field1: 1 },
|
||||
field5: 3,
|
||||
field6: 1,
|
||||
}, GroupAvatarExtraSchema);
|
||||
await uploadHighwayHttp(bridge, session, 3000, loaded.bytes, hashes.md5, extra);
|
||||
}
|
||||
|
||||
// ─────────────── queries on me / my contacts ───────────────
|
||||
|
||||
export async function getProfileLike(
|
||||
@@ -167,7 +217,7 @@ export async function getProfileLike(
|
||||
const isSelf = !userId;
|
||||
const targetUid = isSelf
|
||||
? await resolveSelfUid(bridge)
|
||||
: await resolveUserUid(bridge, userId);
|
||||
: await bridge.resolveUserUid(userId);
|
||||
|
||||
if (!targetUid) {
|
||||
throw new Error('target uid not found');
|
||||
@@ -182,15 +232,12 @@ export async function getProfileLike(
|
||||
limit: limit,
|
||||
};
|
||||
|
||||
const result = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'OidbSvcTrpcTcp.0x7ed_12',
|
||||
0x7ED,
|
||||
12,
|
||||
req,
|
||||
Oidb0x7edReqSchema,
|
||||
Oidb0x7edRespSchema,
|
||||
);
|
||||
const result = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x7ed_12',
|
||||
oidbCmd: 0x7ED, subCmd: 12,
|
||||
request: { schema: Oidb0x7edReqSchema, value: req },
|
||||
response: { schema: Oidb0x7edRespSchema },
|
||||
});
|
||||
|
||||
const data = result?.userLikeInfos?.[0];
|
||||
if (!data) {
|
||||
@@ -220,7 +267,7 @@ export async function getUnidirectionalFriendList(
|
||||
bridge: Bridge,
|
||||
) {
|
||||
const reqObj = {
|
||||
uint64_uin: String(bridge.qqInfo.uin),
|
||||
uint64_uin: String(bridge.identity.uin),
|
||||
uint64_top: 0,
|
||||
uint32_req_num: 99,
|
||||
bytes_cookies: '',
|
||||
@@ -230,15 +277,12 @@ export async function getUnidirectionalFriendList(
|
||||
jsonBody: JSON.stringify(reqObj),
|
||||
};
|
||||
|
||||
const result = await sendOidbAndDecode<any>(
|
||||
bridge,
|
||||
'MQUpdateSvc_com_qq_ti.web.OidbSvc.0xe17_0',
|
||||
0xE17,
|
||||
0,
|
||||
req,
|
||||
Oidb0xe17ReqSchema,
|
||||
Oidb0xe17RespSchema,
|
||||
);
|
||||
const result = await runOidb<any>(bridge, {
|
||||
cmd: 'MQUpdateSvc_com_qq_ti.web.OidbSvc.0xe17_0',
|
||||
oidbCmd: 0xE17, subCmd: 0,
|
||||
request: { schema: Oidb0xe17ReqSchema, value: req },
|
||||
response: { schema: Oidb0xe17RespSchema },
|
||||
});
|
||||
|
||||
if (!result || !result.jsonBody) {
|
||||
throw new Error('get unidirectional friend list empty');
|
||||
@@ -251,7 +295,7 @@ export async function getUnidirectionalFriendList(
|
||||
export async function fetchCustomFace(bridge: Bridge, count: number = 10): Promise<string[]> {
|
||||
const req = {
|
||||
inner: { field1: 1, osVersion: '10.0.26200', qqVersion: '9.9.28-46928' },
|
||||
uin: BigInt(bridge.qqInfo.uin),
|
||||
uin: BigInt(bridge.identity.uin),
|
||||
field3: 1,
|
||||
field6: 1,
|
||||
};
|
||||
@@ -265,5 +309,5 @@ export async function fetchCustomFace(bridge: Bridge, count: number = 10): Promi
|
||||
throw new Error(`fetch custom face error: ${(resp as any)?.message || 'unknown'}`);
|
||||
}
|
||||
const faceIds = (resp as any).item?.faceIds || [];
|
||||
return faceIds.slice(0, count).map((id: string) => `https://p.qpic.cn/qq_expression/${bridge.qqInfo.uin}/${id}/0`);
|
||||
return faceIds.slice(0, count).map((id: string) => `https://p.qpic.cn/qq_expression/${bridge.identity.uin}/${id}/0`);
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
// same five-line utility from every themed file.
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { resolveUserUid } from '../bridge-oidb';
|
||||
|
||||
/**
|
||||
* Coerce numbers, strings, and bigints to a plain integer.
|
||||
@@ -37,18 +36,19 @@ export function ensureRetCodeZero(operation: string, code: unknown, msg: unknown
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up the bot's own UID. Cached on QQInfo when warmed up, but
|
||||
* forward/profile actions need a fast path before warmup completes.
|
||||
* Look up the bot's own UID. Cached on Identity once warmup populates
|
||||
* `selfProfile`; forward/profile actions need this fast path before
|
||||
* warmup completes.
|
||||
*/
|
||||
export async function resolveSelfUid(bridge: Bridge): Promise<string> {
|
||||
let selfUid = bridge.qqInfo.selfUid;
|
||||
let selfUid = bridge.identity.selfUid;
|
||||
if (selfUid) return selfUid;
|
||||
|
||||
const selfUin = toInt(bridge.qqInfo.uin);
|
||||
const selfUin = toInt(bridge.identity.uin);
|
||||
if (selfUin <= 0) {
|
||||
throw new Error('self uid is unavailable');
|
||||
}
|
||||
selfUid = await resolveUserUid(bridge, selfUin);
|
||||
selfUid = await bridge.resolveUserUid(selfUin);
|
||||
return selfUid;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user