refactor(packages): rename @snowluma/bridge → @snowluma/protocol

The package previously named "bridge" houses the protocol-byte layer
(OIDB cmds, msg-push decoders, highway uploaders, element-builder,
event bus). The name "bridge" suggested transport/lifecycle, which it
isn't — that role lives in core/hook and core/bridge/manager. Rename
to match what's actually inside.

This is a pure rename: zero logic changes, all 73 import sites updated
mechanically and TS-verified. core/onebot dependencies key updated.
ESLint override path adjusted for the moved oidb-services directory.

Rename detection threshold: git log --find-renames=20% recommended
when following history across this commit — content-replacement
(@snowluma/bridge → @snowluma/protocol) dropped per-file similarity
below git's default 50% on import-heavy files.
This commit is contained in:
DrSmoothl committed 2026-05-23 23:31:03 +08:00
1 parent 98296fcec5
commit c16064d7e3
238 files changed
+247 -284

No files matched your search

@@ -0,0 +1,53 @@
// 0x9067_202 — fetch download-rkey tokens for private/group/fallback
// image scopes. The rkey is a server-issued signed download token used
// to authenticate every CDN GET against `gchat.qpic.cn` / similar
// endpoints.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { NTV2RichMediaReq, NTV2RichMediaResp } from '@snowluma/proto-defs/oidb-actions/media';
import { invokeOidb, type OidbSender } from '../../oidb-service';
const PRIVATE_IMAGE = 10;
const GROUP_IMAGE = 20;
const FALLBACK_IMAGE = 2;
export namespace FetchDownloadRkeys {
export const command = 0x9067;
export const subCommand = 202;
export const uinForm = true;
export interface Params {}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, _: Params): NTV2RichMediaReq => ({
reqHead: {
common: { requestId: 1, command: 202 },
scene: { requestType: 2, businessType: 1, sceneType: 0 },
client: { agentType: 2 },
},
downloadRkey: {
types: [PRIVATE_IMAGE, GROUP_IMAGE, FALLBACK_IMAGE],
},
});
export const deserialize = (_ctx: Deps, body: NTV2RichMediaResp): NTV2RichMediaResp => {
// Propagate server-side OIDB-equivalent error via the embedded
// respHead.retCode — bytes-level OIDB errorCode would already
// have thrown OidbError before deserialize was called.
if (body.respHead?.retCode && body.respHead.retCode !== 0) {
throw new Error(body.respHead.message ?? 'fetch download rkey failed');
}
return body;
};
export const encode = (env: OidbBase<NTV2RichMediaReq>): Uint8Array =>
protobuf_encode<OidbBase<NTV2RichMediaReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<NTV2RichMediaResp> =>
protobuf_decode<OidbBase<NTV2RichMediaResp>>(bytes);
export const invoke = (deps: Deps): Promise<NTV2RichMediaResp> =>
invokeOidb(deps, FetchDownloadRkeys, {});
}
@@ -0,0 +1,54 @@
// 0xFD4_1 — single-page friend-roster fetch.
//
// QQ paginates the friend list with a wire-level cursor (`nextUin`).
// This namespace handles ONE round-trip — the facade drives the
// while-loop until the server stops emitting a next cursor and
// concatenates results into the public FriendInfo[] shape.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbSvcTrpcTcp0xFD4_1Response } from '@snowluma/proto-defs/oidb';
import type { OidbFriendListRequest } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace FetchFriendListPage {
export const command = 0xFD4;
export const subCommand = 1;
export interface Params {
/** Cursor: `null` for the first page, otherwise the previous
* page's `nextUin`. */
nextUin: number | null;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbFriendListRequest => {
const body: any = {
friendCount: 300,
field4: 0,
field6: 1,
field7: 0x7FFFFFFF,
body: [
{ type: 1, number: { numbers: [103, 102, 20002, 27394] } },
{ type: 4, number: { numbers: [100, 101, 102] } },
],
field10002: [13578, 13579, 13573, 13572, 13568],
field10003: 4051,
};
if (p.nextUin !== null) {
body.nextUin = { uin: p.nextUin };
}
return body;
};
export const deserialize = (_ctx: Deps, body: OidbSvcTrpcTcp0xFD4_1Response): OidbSvcTrpcTcp0xFD4_1Response => body;
export const encode = (env: OidbBase<OidbFriendListRequest>): Uint8Array =>
protobuf_encode<OidbBase<OidbFriendListRequest>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbSvcTrpcTcp0xFD4_1Response> =>
protobuf_decode<OidbBase<OidbSvcTrpcTcp0xFD4_1Response>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<OidbSvcTrpcTcp0xFD4_1Response> =>
invokeOidb(deps, FetchFriendListPage, params);
}
@@ -0,0 +1,57 @@
// 0xFE5_2 — fetch the bot's joined-groups list with full per-group
// info.
//
// The verbose `config` blob in the request body asks QQ which
// per-group fields to include. Asking for everything blows the
// named-pipe write buffer on accounts with ~200+ groups (see #42),
// so we keep `config1.*` mostly on but turn off the costly
// `field5002`/`field5003` and entire `config2` block that never map
// back to a decoded field anyway.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbSvcTrpcTcp0xFE5_2Response } from '@snowluma/proto-defs/oidb';
import type { OidbGroupListRequest } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace FetchGroupList {
export const command = 0xFE5;
export const subCommand = 2;
export const uinForm = true;
export interface Params {}
export type Deps = OidbSender;
const allTrue = true;
export const serialize = (_ctx: Deps, _: Params): OidbGroupListRequest => ({
config: {
config1: {
groupOwner: allTrue, field2: allTrue, memberMax: allTrue, memberCount: allTrue,
groupName: allTrue, field8: allTrue, field9: allTrue, field10: allTrue,
field11: allTrue, field12: allTrue, field13: allTrue, field14: allTrue,
field15: allTrue, field16: allTrue, field17: allTrue, field18: allTrue,
question: allTrue, field20: allTrue, field22: allTrue, field23: allTrue,
field24: allTrue, field25: allTrue, field26: allTrue, field27: allTrue,
field28: allTrue, field29: allTrue, field30: allTrue, field31: allTrue,
field32: allTrue, field5001: allTrue, field5002: false, field5003: false,
},
config2: {
field1: false, field2: false, field3: false, field4: false,
field5: false, field6: false, field7: false, field8: false,
},
config3: { field5: allTrue, field6: allTrue },
},
});
export const deserialize = (_ctx: Deps, body: OidbSvcTrpcTcp0xFE5_2Response): OidbSvcTrpcTcp0xFE5_2Response => body;
export const encode = (env: OidbBase<OidbGroupListRequest>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupListRequest>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbSvcTrpcTcp0xFE5_2Response> =>
protobuf_decode<OidbBase<OidbSvcTrpcTcp0xFE5_2Response>>(bytes);
export const invoke = (deps: Deps): Promise<OidbSvcTrpcTcp0xFE5_2Response> =>
invokeOidb(deps, FetchGroupList, {});
}
@@ -0,0 +1,54 @@
// 0xFE7_3 — single-page group-member-roster fetch.
//
// Pagination cursor is the server-issued `token` string. The facade
// drives the loop until `token` comes back empty; per-group caching
// + inflight coalescing also stays on the facade since both need
// state that's per-Bridge (and is what stops Tencent risk-control
// from banning the account on busy clients — see #42).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbSvcTrpcTcp0xFE7_3Response } from '@snowluma/proto-defs/oidb';
import type { OidbGroupMemberListRequest } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace FetchGroupMemberListPage {
export const command = 0xFE7;
export const subCommand = 3;
export interface Params {
groupId: number;
/** Empty string for the first page; pass the previous response's
* `token` to fetch the next page. */
token: string;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbGroupMemberListRequest => {
const body: any = {
groupUin: p.groupId,
field2: 5,
field3: 2,
body: {
memberName: true, memberCard: true, level: true, field13: true,
field16: true, specialTitle: true, field18: true, field20: true,
field21: true, joinTimestamp: true, lastMsgTimestamp: true,
shutUpTimestamp: true, field103: true, field104: true, field105: true,
field106: true, permission: true, field200: true, field201: true,
},
};
if (p.token) body.token = p.token;
return body;
};
export const deserialize = (_ctx: Deps, body: OidbSvcTrpcTcp0xFE7_3Response): OidbSvcTrpcTcp0xFE7_3Response => body;
export const encode = (env: OidbBase<OidbGroupMemberListRequest>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupMemberListRequest>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbSvcTrpcTcp0xFE7_3Response> =>
protobuf_decode<OidbBase<OidbSvcTrpcTcp0xFE7_3Response>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<OidbSvcTrpcTcp0xFE7_3Response> =>
invokeOidb(deps, FetchGroupMemberListPage, params);
}
@@ -0,0 +1,40 @@
// 0x10C0 — fetch pending group-add requests.
// subCommand 1 = main inbox, 2 = filtered (low-priority) inbox
//
// Returns the wire shape verbatim — the facade does the GroupRequestInfo
// mapping because it also needs to thread the `filtered` flag onto
// each entry, which the wire doesn't carry.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbSvcTrpcTcp0x10C0Response } from '@snowluma/proto-defs/oidb';
import type { OidbGroupRequestList } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace FetchGroupRequests {
export const command = 0x10C0;
export interface Params {
/** false → subCmd 1 (main inbox), true → subCmd 2 (filtered). */
filtered: boolean;
}
export type Deps = OidbSender;
export const resolveSubCommand = (p: Params): number => p.filtered ? 2 : 1;
export const serialize = (_ctx: Deps, _: Params): OidbGroupRequestList => ({
count: 20,
field2: 0,
});
export const deserialize = (_ctx: Deps, body: OidbSvcTrpcTcp0x10C0Response): OidbSvcTrpcTcp0x10C0Response => body;
export const encode = (env: OidbBase<OidbGroupRequestList>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupRequestList>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbSvcTrpcTcp0x10C0Response> =>
protobuf_decode<OidbBase<OidbSvcTrpcTcp0x10C0Response>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<OidbSvcTrpcTcp0x10C0Response> =>
invokeOidb(deps, FetchGroupRequests, params);
}
@@ -0,0 +1,99 @@
// 0xFE1_2 (UID form) — fetch a user's profile when only the UID is
// known. Same OIDB cmd + subcmd as `FetchUserProfile` (by UIN) but
// the request body's field 1 is `uid: string` instead of `uin:
// uint32`, and `reserved` stays 0 (no `uinForm`).
//
// Why two namespaces for the same (cmd, subcmd):
// - Group join requests / invitations carry the stranger's UID
// only — we never get a UIN for someone who hasn't joined yet.
// - The Tencent server WILL reject a UIN-form request with a uid-
// shaped value or vice versa, so the two variants must encode
// to byte-different wires.
// - Matches Lagrange's `OidbSvcTrpcTcp0xFE1_2Uid` vs `…Uin` split
// at `dev/Lagrange.Core/.../OidbSvcTrpcTcp0xFE1_2.cs:9-26`
// and the dispatch at
// `dev/Lagrange.Core/.../FetchUserInfoService.cs:66-78`.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
AvatarInfo,
OidbUserInfoByUidRequest,
OidbUserInfoResponse,
} from '@snowluma/proto-defs/oidb-actions/base';
import type { UserProfileInfo } from '../../qq-info';
import { invokeOidb, type OidbSender } from '../../oidb-service';
const REQUESTED_KEYS = [
20002, 27394, 20009, 20031, 101, 103, 102, 20020, 20003, 20026,
105, 27372, 27406, 20037,
];
export namespace FetchUserProfileByUid {
export const command = 0xFE1;
export const subCommand = 2;
// No `uinForm` — the UID variant uses the default `reserved=0`
// envelope, mirroring Lagrange's untagged constructor at
// `OidbSvcTrpcTcp0xFE1_2.cs:9` (isUid=false → Reserved=0).
export interface Params {
uid: string;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbUserInfoByUidRequest => ({
uid: p.uid,
keys: REQUESTED_KEYS.map(k => ({ key: k })),
});
export const deserialize = (_ctx: Deps, body: OidbUserInfoResponse): UserProfileInfo => {
if (!body.body) throw new Error('user info response body missing');
const info: UserProfileInfo = {
uin: body.body.uin ?? 0,
uid: body.body.uid ?? '',
nickname: '', remark: '', qid: '', sex: 'unknown', age: 0, sign: '', avatar: '', level: 0,
};
if (body.body.properties) {
const bytesMap = new Map<number, Uint8Array>();
const numMap = new Map<number, number>();
for (const bp of body.body.properties.bytesProperties ?? []) {
bytesMap.set(bp.code ?? 0, bp.value ?? new Uint8Array(0));
}
for (const np of body.body.properties.numberProperties ?? []) {
numMap.set(np.number1 ?? 0, np.number2 ?? 0);
}
const getString = (code: number): string => {
const b = bytesMap.get(code);
return b ? Buffer.from(b).toString('utf8') : '';
};
info.nickname = getString(20002);
info.remark = getString(103);
info.qid = getString(27394);
info.sign = getString(102);
const avatarBytes = bytesMap.get(101);
if (avatarBytes) {
const av = protobuf_decode<AvatarInfo>(avatarBytes);
if (av?.url) info.avatar = av.url + '640';
}
const sexNum = numMap.get(20009) ?? 0;
info.sex = sexNum === 1 ? 'male' : sexNum === 2 ? 'female' : 'unknown';
info.age = numMap.get(20037) ?? 0;
info.level = numMap.get(105) ?? 0;
}
return info;
};
export const encode = (env: OidbBase<OidbUserInfoByUidRequest>): Uint8Array =>
protobuf_encode<OidbBase<OidbUserInfoByUidRequest>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbUserInfoResponse> =>
protobuf_decode<OidbBase<OidbUserInfoResponse>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<UserProfileInfo> =>
invokeOidb(deps, FetchUserProfileByUid, params);
}
@@ -0,0 +1,115 @@
// 0xFE1_2 — fetch a user's profile (nickname / qid / sex / age / sign
// / avatar / QQ level).
//
// `uinForm` is set so the server takes the UIN-form validation path;
// without it newer NTQQ versions reject the request with
// `[oidb] one of uid/openid is invaild`. Matches Lagrange.Core's
// FetchStrangerByUin (Reserved = 1).
//
// Property key catalogue (cross-checked against LagrangeV2's
// FetchStrangerService.cs):
// 101 — avatar info (proto-encoded AvatarInfo)
// 102 — sign (signature)
// 103 — remark
// 105 — QQ level (numeric)
// 20002 — nickname
// 20009 — gender (1 male / 2 female / 255 unknown)
// 20037 — age
// 27394 — QID
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
AvatarInfo,
OidbUserInfoRequest,
OidbUserInfoResponse,
} from '@snowluma/proto-defs/oidb-actions/base';
import type { UserProfileInfo } from '../../qq-info';
import { invokeOidb, type OidbSender } from '../../oidb-service';
const REQUESTED_KEYS = [
20002, 27394, 20009, 20031, 101, 103, 102, 20020, 20003, 20026,
105, 27372, 27406, 20037,
];
export namespace FetchUserProfile {
export const command = 0xFE1;
export const subCommand = 2;
export const uinForm = true;
export interface Params {
uin: number;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbUserInfoRequest => ({
uin: p.uin,
keys: REQUESTED_KEYS.map(k => ({ key: k })),
});
/** Defaults the response uin to `requestedUin` because the server
* sometimes elides its echo. `invoke` below binds `params.uin` via
* the spec override so the namespace's call surface still takes
* only `(ctx, body)`. */
export const deserializeWithFallback = (
body: OidbUserInfoResponse, requestedUin: number,
): UserProfileInfo => {
if (!body.body) throw new Error('user info response body missing');
const info: UserProfileInfo = {
uin: body.body.uin ?? requestedUin,
uid: body.body.uid ?? '',
nickname: '', remark: '', qid: '', sex: 'unknown', age: 0, sign: '', avatar: '', level: 0,
};
if (body.body.properties) {
const bytesMap = new Map<number, Uint8Array>();
const numMap = new Map<number, number>();
for (const bp of body.body.properties.bytesProperties ?? []) {
bytesMap.set(bp.code ?? 0, bp.value ?? new Uint8Array(0));
}
for (const np of body.body.properties.numberProperties ?? []) {
numMap.set(np.number1 ?? 0, np.number2 ?? 0);
}
const getString = (code: number): string => {
const b = bytesMap.get(code);
return b ? Buffer.from(b).toString('utf8') : '';
};
info.nickname = getString(20002);
info.remark = getString(103);
info.qid = getString(27394);
info.sign = getString(102);
const avatarBytes = bytesMap.get(101);
if (avatarBytes) {
const av = protobuf_decode<AvatarInfo>(avatarBytes);
if (av?.url) info.avatar = av.url + '640';
}
const sexNum = numMap.get(20009) ?? 0;
info.sex = sexNum === 1 ? 'male' : sexNum === 2 ? 'female' : 'unknown';
info.age = numMap.get(20037) ?? 0;
info.level = numMap.get(105) ?? 0;
}
return info;
};
// Default deserialize uses uin=0 fallback — invoke() rewires it to
// the requested uin via the per-call spec override below. Tests
// that call deserialize directly should use deserializeWithFallback.
export const deserialize = (_ctx: Deps, body: OidbUserInfoResponse): UserProfileInfo =>
deserializeWithFallback(body, 0);
export const encode = (env: OidbBase<OidbUserInfoRequest>): Uint8Array =>
protobuf_encode<OidbBase<OidbUserInfoRequest>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbUserInfoResponse> =>
protobuf_decode<OidbBase<OidbUserInfoResponse>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<UserProfileInfo> =>
invokeOidb(deps, {
...FetchUserProfile,
deserialize: (_ctx, body) => deserializeWithFallback(body, params.uin),
}, params);
}
@@ -0,0 +1,50 @@
// 0x929D_0 — fetch the catalog of AI voices available for synthesis
// in a given group, grouped by category. Returns the categories
// straight from the wire (caller already expects the wire shape).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
OidbAiVoiceListReq, OidbAiVoiceListResp,
} from '@snowluma/proto-defs/oidb-actions/media';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export interface AiVoiceItem {
voiceId: string;
voiceDisplayName: string;
voiceExampleUrl: string;
}
export interface AiVoiceCategory {
category: string;
voices: AiVoiceItem[];
}
export namespace FetchAiVoiceList {
export const command = 0x929D;
export const subCommand = 0;
export interface Params {
groupId: number;
chatType: number;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbAiVoiceListReq => ({
groupUin: p.groupId,
chatType: p.chatType,
});
export const deserialize = (_ctx: Deps, body: OidbAiVoiceListResp): AiVoiceCategory[] =>
(body.content as AiVoiceCategory[] | undefined) ?? [];
export const encode = (env: OidbBase<OidbAiVoiceListReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbAiVoiceListReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbAiVoiceListResp> =>
protobuf_decode<OidbBase<OidbAiVoiceListResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<AiVoiceCategory[]> =>
invokeOidb(deps, FetchAiVoiceList, params);
}
@@ -0,0 +1,68 @@
// 0x929B_0 — kick off AI voice synthesis and poll until the rendered
// media is available. The server may return an empty msgInfo while
// the render is in-flight; the facade polls up to `maxRetries` times.
//
// `sessionId` is a random 32-bit value used by the server to
// de-duplicate retries of the same synthesis request.
//
// Each `invoke()` is a SINGLE poll — the retry loop lives on the
// facade so callers can plug their own back-off / cancellation in
// without forking the namespace.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
OidbAiVoiceReq, OidbAiVoiceResp,
} from '@snowluma/proto-defs/oidb-actions/media';
import { invokeOidb, type OidbSender } from '../../oidb-service';
/** Subset of AiVoiceMediaIndex (defined in @snowluma/core/apis/shared)
* that the AI voice response payload populates. Kept inline here so
* the namespace stays self-contained against @snowluma/protocol — the
* facade casts back to the richer core-side type. */
export interface AiVoiceMediaIndex {
info?: { fileSize?: number; fileName?: string; type?: { type?: number; voiceFormat?: number } };
fileUuid?: string;
storeId?: number;
uploadTime?: number;
ttl?: number;
subType?: number;
}
export namespace FetchAiVoice {
export const command = 0x929B;
export const subCommand = 0;
export interface Params {
groupId: number;
voiceId: string;
text: string;
chatType: number;
/** Random 32-bit session id; server uses this to deduplicate polls. */
sessionId: number;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbAiVoiceReq => ({
groupUin: p.groupId,
voiceId: p.voiceId,
text: p.text,
chatType: p.chatType,
session: { sessionId: p.sessionId },
});
export const deserialize = (_ctx: Deps, body: OidbAiVoiceResp): AiVoiceMediaIndex | null => {
const node = body.msgInfo?.msgInfoBody?.[0]?.index as AiVoiceMediaIndex | undefined;
return node ?? null;
};
export const encode = (env: OidbBase<OidbAiVoiceReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbAiVoiceReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbAiVoiceResp> =>
protobuf_decode<OidbBase<OidbAiVoiceResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<AiVoiceMediaIndex | null> =>
invokeOidb(deps, FetchAiVoice, params);
}
@@ -0,0 +1,60 @@
// 0xFE1_2 — fetch the stranger's status (online / away / busy /
// invisible). Same OIDB cmd as fetchUserProfile but a different
// request shape (only key 27372 = status, no other property keys),
// and we decode the ext-bigint status word into napcat's
// (status × 10, ext_status) pair.
//
// `uinForm` is set so the server takes the UIN-form validation path;
// without it newer NTQQ rejects with `[oidb] one of uid/openid is
// invaild`. Same flag fetchUserProfile uses.
//
// On any transport / decode failure the deserialize step is bypassed
// — the facade swallows the namespace-level exception and surfaces
// `null` so callers get a clean retcode.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { OidbStrangerStatusReq, OidbStrangerStatusResp } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export interface StrangerStatus {
status: number;
ext_status: number;
}
export namespace GetStrangerStatus {
export const command = 0xFE1;
export const subCommand = 2;
export const uinForm = true;
export interface Params {
uin: number;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbStrangerStatusReq => ({
uin: p.uin,
key: [{ key: 27372 }],
});
export const deserialize = (_ctx: Deps, body: OidbStrangerStatusResp): StrangerStatus | null => {
const raw = body.data?.status?.value;
if (raw === undefined || raw === null) return null;
const extBig = typeof raw === 'bigint' ? raw : BigInt(raw as any);
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 };
};
export const encode = (env: OidbBase<OidbStrangerStatusReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbStrangerStatusReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbStrangerStatusResp> =>
protobuf_decode<OidbBase<OidbStrangerStatusResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<StrangerStatus | null> =>
invokeOidb(deps, GetStrangerStatus, params);
}
@@ -0,0 +1,48 @@
// 0xF90 — group todo (群待办) CRUD.
// subCommand 1 = set, 2 = complete, 3 = cancel
//
// All three sub-cmds share the same request shape ((groupUin, msgSeq))
// so they collapse into one namespace with a dynamic subcmd resolver.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbGroupTodo } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export type GroupTodoAction = 'set' | 'complete' | 'cancel';
const ACTION_TO_SUBCMD: Record<GroupTodoAction, number> = {
set: 1,
complete: 2,
cancel: 3,
};
export namespace GroupTodo {
export const command = 0xF90;
export interface Params {
groupId: number;
msgSeq: bigint;
action: GroupTodoAction;
}
export type Deps = OidbSender;
export const resolveSubCommand = (p: Params): number => ACTION_TO_SUBCMD[p.action];
export const serialize = (_ctx: Deps, p: Params): OidbGroupTodo => ({
groupUin: p.groupId,
msgSeq: p.msgSeq,
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbGroupTodo>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupTodo>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, GroupTodo, params);
}
@@ -0,0 +1,53 @@
// 0x126B_0 — delete a friend (optionally with block flag).
//
// The deeply-nested field2 sub-message is a server-side discriminator
// that must be sent verbatim — the magic numbers (130 / 109 / 8/8/50)
// match the wire shape NTQQ's own client emits and aren't a SnowLuma
// invention. Server rejects the request if any of them is wrong.
//
// Cache invalidation (re-fetching the friend list after deletion)
// lives in the facade — keeps this namespace dependency-free of
// `apis.contacts` and the OneBot-side caches.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbDeleteFriend } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export namespace DeleteFriend {
export const command = 0x126B;
export const subCommand = 0;
export interface Params {
userId: number;
/** Also block (拉黑) the user. Default false. */
block?: boolean;
}
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
export const serialize = async (ctx: Deps, p: Params): Promise<OidbDeleteFriend> => ({
field1: {
targetUid: await ctx.resolveUserUid(p.userId),
field2: {
field1: 130,
field2: 109,
field3: { field1: 8, field2: 8, field3: 50 },
},
block: p.block ?? false,
field4: false,
},
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbDeleteFriend>): Uint8Array =>
protobuf_encode<OidbBase<OidbDeleteFriend>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, DeleteFriend, params);
}
@@ -0,0 +1,47 @@
// 0xB5D_44 — accept (3) / reject (5) an inbound friend request.
//
// Caller passes either a pre-resolved UID string or a numeric uin
// (encoded as a digit-only string); we detect the latter and resolve
// to UID first.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbFriendRequestAction } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export namespace HandleFriendRequest {
export const command = 0xB5D;
export const subCommand = 44;
export interface Params {
/** Pre-resolved UID, or a digit-only numeric uin to resolve on demand. */
uidOrFlag: string;
approve: boolean;
}
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
export const serialize = async (ctx: Deps, p: Params): Promise<OidbFriendRequestAction> => {
const targetUid = /^\d+$/.test(p.uidOrFlag)
? await ctx.resolveUserUid(parseInt(p.uidOrFlag, 10))
: p.uidOrFlag;
return {
// Server discriminator: 3 = accept, 5 = reject. Pre-fix values
// verified against current production behaviour.
accept: p.approve ? 3 : 5,
targetUid,
};
};
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbFriendRequestAction>): Uint8Array =>
protobuf_encode<OidbBase<OidbFriendRequestAction>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, HandleFriendRequest, params);
}
@@ -0,0 +1,36 @@
// 0xB6E_2 — set the remark (备注) shown for a friend in the bot's
// own roster. Doesn't affect what the friend sees.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbSetFriendRemark } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export namespace SetFriendRemark {
export const command = 0xB6E;
export const subCommand = 2;
export interface Params {
userId: number;
remark: string;
}
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
export const serialize = async (ctx: Deps, p: Params): Promise<OidbSetFriendRemark> => ({
targetUid: await ctx.resolveUserUid(p.userId),
remark: p.remark,
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbSetFriendRemark>): Uint8Array =>
protobuf_encode<OidbBase<OidbSetFriendRemark>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SetFriendRemark, params);
}
@@ -0,0 +1,58 @@
// 0x8A7_0 — query "@everyone" remaining-use budget for the bot in
// the given group. Server returns two independent counters: a
// per-uin budget (the bot's daily allowance) and a per-group budget
// (the group's shared allowance). The OneBot action surfaces both
// alongside a single `can_at_all` boolean.
//
// The req's `basic{1,2,3}` triplet (1/2/1) is the wire-known
// validation cookie NTQQ emits; the server rejects requests with
// different values. `type = 0` means "query" (no other type seen).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { Oidb0x8a7Req, Oidb0x8a7Resp } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export interface AtAllRemain {
can_at_all: boolean;
remain_at_all_count_for_group: number;
remain_at_all_count_for_uin: number;
}
export namespace GetAtAllRemain {
export const command = 0x8A7;
export const subCommand = 0;
export interface Params { groupId: number; }
export type Deps = OidbSender & Pick<BridgeContext, 'identity'>;
export const serialize = (ctx: Deps, p: Params): Oidb0x8a7Req => ({
basic1: 1,
basic2: 2,
basic3: 1,
uin: BigInt(ctx.identity.uin),
groupId: BigInt(p.groupId),
type: 0,
});
export const deserialize = (_ctx: Deps, body: Oidb0x8a7Resp): AtAllRemain => {
// Cast numbers to plain Number: the OIDB layer may surface uint32
// as BigInt and the WebUI JSON serializer chokes on those.
return {
can_at_all: !!body.canAtAll,
remain_at_all_count_for_group: Number(body.groupRemain ?? 0),
remain_at_all_count_for_uin: Number(body.uinRemain ?? 0),
};
};
export const encode = (env: OidbBase<Oidb0x8a7Req>): Uint8Array =>
protobuf_encode<OidbBase<Oidb0x8a7Req>>(env);
export const decode = (bytes: Uint8Array): OidbBase<Oidb0x8a7Resp> =>
protobuf_decode<OidbBase<Oidb0x8a7Resp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<AtAllRemain> =>
invokeOidb(deps, GetAtAllRemain, params);
}
@@ -0,0 +1,42 @@
// 0x8A0_1 — single-member kick. The batch variant (kickMembers) uses
// the same cmd but a different proto body shape; kept as a separate
// namespace because proton needs distinct types per call site.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbKickMember } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export namespace KickMember {
export const command = 0x8A0;
export const subCommand = 1;
export interface Params {
groupId: number;
userId: number;
/** Reject the kicked user's future join requests. */
reject: boolean;
reason?: string;
}
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
export const serialize = async (ctx: Deps, p: Params): Promise<OidbKickMember> => ({
groupUin: p.groupId,
targetUid: await ctx.resolveUserUid(p.userId, p.groupId),
rejectAddRequest: p.reject,
reason: p.reason ?? '',
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbKickMember>): Uint8Array =>
protobuf_encode<OidbBase<OidbKickMember>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, KickMember, params);
}
@@ -0,0 +1,41 @@
// 0x8A0_1 — batch member kick (repeated targetUids). Same cmd+subcmd
// as KickMember (single) but a different proto body shape; separate
// namespace so proton can monomorphize independently.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { Oidb0x8a0Req } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export namespace KickMembers {
export const command = 0x8A0;
export const subCommand = 1;
export interface Params {
groupId: number;
userIds: number[];
reject: boolean;
}
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
export const serialize = async (ctx: Deps, p: Params): Promise<Oidb0x8a0Req> => ({
groupId: BigInt(p.groupId),
targetUids: await Promise.all(p.userIds.map(uid => ctx.resolveUserUid(uid, p.groupId))),
rejectAddRequest: p.reject ? 1 : 0,
kickReason: new Uint8Array(0),
field12: 0,
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<Oidb0x8a0Req>): Uint8Array =>
protobuf_encode<OidbBase<Oidb0x8a0Req>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, KickMembers, params);
}
@@ -0,0 +1,23 @@
// 0x1097_1 — leave a group (退群).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbLeaveGroup } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace LeaveGroup {
export const command = 0x1097;
export const subCommand = 1;
export interface Params { groupId: number; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbLeaveGroup => ({ groupUin: p.groupId });
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbLeaveGroup>): Uint8Array =>
protobuf_encode<OidbBase<OidbLeaveGroup>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, LeaveGroup, params);
}
@@ -0,0 +1,34 @@
// 0x89A_0 — toggle group全员禁言. `state` is the duration multiplier
// (0xFFFFFFFF for permanent mute, 0 for unmute). Multiple OIDB cmds
// share the (0x89A, 0) tuple — see also SetAddOption / SetSearch /
// SetName — disambiguated by the body proto shape.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbMuteAll } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace MuteAll {
export const command = 0x89A;
export const subCommand = 0;
export interface Params { groupId: number; enable: boolean; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbMuteAll => ({
groupUin: p.groupId,
muteState: { state: p.enable ? 0xFFFFFFFF : 0 },
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbMuteAll>): Uint8Array =>
protobuf_encode<OidbBase<OidbMuteAll>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, MuteAll, params);
}
@@ -0,0 +1,36 @@
// 0x1253_1 — mute a single group member for `duration` seconds.
// Server treats duration = 0 as "unmute now".
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbMuteMember } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export namespace MuteMember {
export const command = 0x1253;
export const subCommand = 1;
export interface Params { groupId: number; userId: number; duration: number; }
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
export const serialize = async (ctx: Deps, p: Params): Promise<OidbMuteMember> => ({
groupUin: p.groupId, type: 1,
body: {
targetUid: await ctx.resolveUserUid(p.userId, p.groupId),
duration: p.duration,
},
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbMuteMember>): Uint8Array =>
protobuf_encode<OidbBase<OidbMuteMember>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, MuteMember, params);
}
@@ -0,0 +1,34 @@
// 0x89A_0 — set group "how to join" option (anyone / verification /
// owner-only / etc). Same cmd+subcmd as MuteAll / SetSearch / SetName
// — disambiguated by the body proto shape.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { Oidb0x89a_0AddOption } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace SetAddOption {
export const command = 0x89A;
export const subCommand = 0;
export interface Params { groupId: number; addType: number; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): Oidb0x89a_0AddOption => ({
groupUin: BigInt(p.groupId),
settings: { addType: p.addType },
field12: 0,
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<Oidb0x89a_0AddOption>): Uint8Array =>
protobuf_encode<OidbBase<Oidb0x89a_0AddOption>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SetAddOption, params);
}
@@ -0,0 +1,49 @@
// 0x10C8 — approve/reject a pending group join request.
// subCommand 1 = main inbox, 2 = filtered inbox
//
// `uinForm=true` matches the request shape NTQQ emits. `accept: 1`
// is the server discriminator for approve; `2` for reject.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbGroupRequestAction } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace SetAddRequest {
export const command = 0x10C8;
export const uinForm = true;
export interface Params {
groupId: number;
sequence: number;
eventType: number;
approve: boolean;
reason?: string;
filtered?: boolean;
}
export type Deps = OidbSender;
export const resolveSubCommand = (p: Params): number => p.filtered ? 2 : 1;
export const serialize = (_ctx: Deps, p: Params): OidbGroupRequestAction => ({
accept: p.approve ? 1 : 2,
body: {
sequence: BigInt(p.sequence),
eventType: p.eventType,
groupUin: p.groupId,
message: p.reason ?? '',
},
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbGroupRequestAction>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupRequestAction>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SetAddRequest, params);
}
@@ -0,0 +1,30 @@
// 0x1096_1 — promote / demote a member to/from group administrator.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbSetAdmin } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export namespace SetAdmin {
export const command = 0x1096;
export const subCommand = 1;
export interface Params { groupId: number; userId: number; enable: boolean; }
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
export const serialize = async (ctx: Deps, p: Params): Promise<OidbSetAdmin> => ({
groupUin: p.groupId,
uid: await ctx.resolveUserUid(p.userId, p.groupId),
isAdmin: p.enable,
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbSetAdmin>): Uint8Array =>
protobuf_encode<OidbBase<OidbSetAdmin>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SetAdmin, params);
}
@@ -0,0 +1,27 @@
// 0x89A_15 — rename the group.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbRenameGroup } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace SetGroupName {
export const command = 0x89A;
export const subCommand = 15;
export interface Params { groupId: number; name: string; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbRenameGroup => ({
groupUin: p.groupId, body: { targetName: p.name },
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbRenameGroup>): Uint8Array =>
protobuf_encode<OidbBase<OidbRenameGroup>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SetGroupName, params);
}
@@ -0,0 +1,29 @@
// 0xF16_1 — set the bot's local-only label/remark for a group (only
// the bot sees this — the group's actual name is untouched).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { Oidb0xf16Req } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace SetGroupRemark {
export const command = 0xF16;
export const subCommand = 1;
export interface Params { groupId: number; remark: string; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): Oidb0xf16Req => ({
inner: { groupId: BigInt(p.groupId), remark: p.remark },
field12: 0,
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<Oidb0xf16Req>): Uint8Array =>
protobuf_encode<OidbBase<Oidb0xf16Req>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SetGroupRemark, params);
}
@@ -0,0 +1,32 @@
// 0x8FC_3 — set a member's group-card (群名片).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbRenameMember } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export namespace SetMemberCard {
export const command = 0x8FC;
export const subCommand = 3;
export interface Params { groupId: number; userId: number; card: string; }
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
export const serialize = async (ctx: Deps, p: Params): Promise<OidbRenameMember> => ({
groupUin: p.groupId,
body: {
targetUid: await ctx.resolveUserUid(p.userId, p.groupId),
targetName: p.card,
},
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbRenameMember>): Uint8Array =>
protobuf_encode<OidbBase<OidbRenameMember>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SetMemberCard, params);
}
@@ -0,0 +1,33 @@
// 0x89A_0 — toggle group "searchable" flag. Same cmd+subcmd shape as
// MuteAll / SetAddOption / SetName.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { Oidb0x89a_0Search } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace SetSearch {
export const command = 0x89A;
export const subCommand = 0;
export interface Params { groupId: number; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): Oidb0x89a_0Search => ({
groupUin: BigInt(p.groupId),
settings: new Uint8Array(0),
field12: 0,
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<Oidb0x89a_0Search>): Uint8Array =>
protobuf_encode<OidbBase<Oidb0x89a_0Search>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SetSearch, params);
}
@@ -0,0 +1,34 @@
// 0x8FC_2 — assign a member a "special title" (群头衔). `expireTime=-1`
// is the wire constant for "permanent".
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbSpecialTitle } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export namespace SetSpecialTitle {
export const command = 0x8FC;
export const subCommand = 2;
export interface Params { groupId: number; userId: number; title: string; }
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
export const serialize = async (ctx: Deps, p: Params): Promise<OidbSpecialTitle> => ({
groupUin: p.groupId,
body: {
targetUid: await ctx.resolveUserUid(p.userId, p.groupId),
specialTitle: p.title,
expireTime: -1,
},
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbSpecialTitle>): Uint8Array =>
protobuf_encode<OidbBase<OidbSpecialTitle>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SetSpecialTitle, params);
}
@@ -0,0 +1,42 @@
// 0x6D7_0 — create a sub-folder under `parentId` in the group file
// hierarchy. parentId='/' is the root.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
OidbGroupFileFolderReq, OidbGroupFileFolderResp,
} from '@snowluma/proto-defs/oidb-actions/group-file';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import { ensureRetCodeZero } from '../shared';
export namespace CreateGroupFolder {
export const command = 0x6D7;
export const subCommand = 0;
export const uinForm = true;
export interface Params { groupId: number; parentId: string; folderName: string; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbGroupFileFolderReq => ({
create: {
groupUin: p.groupId,
rootDirectory: p.parentId,
folderName: p.folderName,
},
});
export const deserialize = (_ctx: Deps, body: OidbGroupFileFolderResp): void => {
const result = body.create;
if (!result) throw new Error('group folder create response missing');
ensureRetCodeZero('group folder create', result.retcode, result.retMsg, result.clientWording);
};
export const encode = (env: OidbBase<OidbGroupFileFolderReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupFileFolderReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbGroupFileFolderResp> =>
protobuf_decode<OidbBase<OidbGroupFileFolderResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, CreateGroupFolder, params);
}
@@ -0,0 +1,41 @@
// 0x6D6_3 — delete a single group file by id.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
OidbGroupFileReq, OidbGroupFileResp,
} from '@snowluma/proto-defs/oidb-actions/group-file';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import { ensureRetCodeZero } from '../shared';
export namespace DeleteGroupFile {
export const command = 0x6D6;
export const subCommand = 3;
export const uinForm = true;
export interface Params { groupId: number; fileId: string; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbGroupFileReq => ({
delete: {
groupUin: p.groupId,
busId: 102,
fileId: p.fileId,
},
});
export const deserialize = (_ctx: Deps, body: OidbGroupFileResp): void => {
const result = body.delete;
if (!result) throw new Error('group file delete response missing');
ensureRetCodeZero('group file delete', result.retCode, result.retMsg, result.clientWording);
};
export const encode = (env: OidbBase<OidbGroupFileReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupFileReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbGroupFileResp> =>
protobuf_decode<OidbBase<OidbGroupFileResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, DeleteGroupFile, params);
}
@@ -0,0 +1,38 @@
// 0x6D7_1 — delete a group folder by id (any files inside are
// orphaned; UI sometimes pre-empties first via per-file deletes).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
OidbGroupFileFolderReq, OidbGroupFileFolderResp,
} from '@snowluma/proto-defs/oidb-actions/group-file';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import { ensureRetCodeZero } from '../shared';
export namespace DeleteGroupFolder {
export const command = 0x6D7;
export const subCommand = 1;
export const uinForm = true;
export interface Params { groupId: number; folderId: string; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbGroupFileFolderReq => ({
delete: { groupUin: p.groupId, folderId: p.folderId },
});
export const deserialize = (_ctx: Deps, body: OidbGroupFileFolderResp): void => {
const result = body.delete;
if (!result) throw new Error('group folder delete response missing');
ensureRetCodeZero('group folder delete', result.retcode, result.retMsg, result.clientWording);
};
export const encode = (env: OidbBase<OidbGroupFileFolderReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupFileFolderReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbGroupFileFolderResp> =>
protobuf_decode<OidbBase<OidbGroupFileFolderResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, DeleteGroupFolder, params);
}
@@ -0,0 +1,42 @@
// 0x6D8_3 — fetch group file slot usage. Returns the current count
// alongside the server-side ceiling (NTQQ's `maxCount` default is
// 10000; we surface that fallback so the OneBot action can render
// the gauge without a second call when the server elides the field).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
OidbGroupFileCountViewReq, OidbGroupFileCountViewResp,
} from '@snowluma/proto-defs/oidb-actions/group-file';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export interface GroupFileCount {
fileCount: number;
maxCount: number;
}
export namespace GetGroupFileCount {
export const command = 0x6D8;
export const subCommand = 3;
export interface Params { groupId: number; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbGroupFileCountViewReq => ({
count: { groupUin: p.groupId, appId: 7, busId: 0 },
});
export const deserialize = (_ctx: Deps, body: OidbGroupFileCountViewResp): GroupFileCount => ({
fileCount: Number(body.count?.fileCount ?? 0),
maxCount: Number(body.count?.maxCount ?? 10000),
});
export const encode = (env: OidbBase<OidbGroupFileCountViewReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupFileCountViewReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbGroupFileCountViewResp> =>
protobuf_decode<OidbBase<OidbGroupFileCountViewResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<GroupFileCount> =>
invokeOidb(deps, GetGroupFileCount, params);
}
@@ -0,0 +1,44 @@
// 0x6D6_2 — resolve a group file_id → ftn_handler download URL. The
// server returns a `downloadUrl` blob (raw bytes that hex-encode the
// download key) and a `downloadDns` host. The facade composes the
// final `https://<dns>/ftn_handler/<HEX>/?fname=<fileId>` string.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
OidbGroupFileReq, OidbGroupFileResp, OidbGroupFileDownloadResp,
} from '@snowluma/proto-defs/oidb-actions/group-file';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace GetGroupFileUrl {
export const command = 0x6D6;
export const subCommand = 2;
export const uinForm = true;
export interface Params { groupId: number; fileId: string; busId: number; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbGroupFileReq => ({
download: {
groupUin: p.groupId,
appId: 7,
busId: p.busId,
fileId: p.fileId,
},
});
export const deserialize = (_ctx: Deps, body: OidbGroupFileResp): OidbGroupFileDownloadResp => {
const download = body.download;
if (!download) throw new Error('group file url response missing');
return download;
};
export const encode = (env: OidbBase<OidbGroupFileReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupFileReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbGroupFileResp> =>
protobuf_decode<OidbBase<OidbGroupFileResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<OidbGroupFileDownloadResp> =>
invokeOidb(deps, GetGroupFileUrl, params);
}
@@ -0,0 +1,49 @@
// 0x126E_200 — fetch a download URL for a group-scope rich-media node
// (voice in this case — busiType=3 means "ptt/voice", sceneType=2
// means group). Pairs with the c2c-scope variant `GetPrivatePttUrl`
// (0x126D_200) which only differs in scene.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { NTV2RichMediaReq, NTV2RichMediaResp } from '@snowluma/proto-defs/oidb-actions/media';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import {
normalizeMediaNode, parseNtv2DownloadUrl, type NtMediaIndex,
} from './ntv2-download';
export namespace GetGroupPttUrl {
export const command = 0x126E;
export const subCommand = 200;
export const uinForm = true;
export interface Params { groupId: number; node: NtMediaIndex; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): NTV2RichMediaReq => ({
reqHead: {
common: { requestId: 4, command: 200 },
scene: {
requestType: 1,
businessType: 3,
sceneType: 2,
group: { groupUin: p.groupId },
},
client: { agentType: 2 },
},
download: {
node: normalizeMediaNode(p.node) as any,
download: { video: { busiType: 0, sceneType: 0 } },
},
});
export const deserialize = (_ctx: Deps, body: NTV2RichMediaResp): string => parseNtv2DownloadUrl(body);
export const encode = (env: OidbBase<NTV2RichMediaReq>): Uint8Array =>
protobuf_encode<OidbBase<NTV2RichMediaReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<NTV2RichMediaResp> =>
protobuf_decode<OidbBase<NTV2RichMediaResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<string> =>
invokeOidb(deps, GetGroupPttUrl, params);
}
@@ -0,0 +1,48 @@
// 0x11EA_200 — video URL fetch, group scope. Same envelope shape as
// GetGroupPttUrl; `requestType=2 + businessType=2` swaps voice for
// video. The scene's `group` block carries the group uin.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { NTV2RichMediaReq, NTV2RichMediaResp } from '@snowluma/proto-defs/oidb-actions/media';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import {
normalizeMediaNode, parseNtv2DownloadUrl, type NtMediaIndex,
} from './ntv2-download';
export namespace GetGroupVideoUrl {
export const command = 0x11EA;
export const subCommand = 200;
export const uinForm = true;
export interface Params { groupId: number; node: NtMediaIndex; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): NTV2RichMediaReq => ({
reqHead: {
common: { requestId: 1, command: 200 },
scene: {
requestType: 2,
businessType: 2,
sceneType: 2,
group: { groupUin: p.groupId },
},
client: { agentType: 2 },
},
download: {
node: normalizeMediaNode(p.node) as any,
download: { video: { busiType: 0, sceneType: 0 } },
},
});
export const deserialize = (_ctx: Deps, body: NTV2RichMediaResp): string => parseNtv2DownloadUrl(body);
export const encode = (env: OidbBase<NTV2RichMediaReq>): Uint8Array =>
protobuf_encode<OidbBase<NTV2RichMediaReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<NTV2RichMediaResp> =>
protobuf_decode<OidbBase<NTV2RichMediaResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<string> =>
invokeOidb(deps, GetGroupVideoUrl, params);
}
@@ -0,0 +1,56 @@
// 0xE37_1200 — resolve a private (c2c) file_id → http download URL.
// Carries an opaque 4-byte `field99999` magic the server's deserializer
// requires (Lagrange has the same constant). The facade composes the
// final `http://<server>:<port><url>&isthumb=0` string.
//
// 5s timeout matches the original facade — the server batches these
// at low priority and stalls past the default 30s.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
OidbPrivateFileDownloadReq, OidbPrivateFileDownloadResp,
OidbPrivateFileDownloadRespResult,
} from '@snowluma/proto-defs/oidb-actions/media';
import { invokeOidb, type OidbSender } from '../../oidb-service';
const TIMEOUT_MS = 5000;
export namespace GetPrivateFileUrl {
export const command = 0xE37;
export const subCommand = 1200;
export interface Params { selfUid: string; fileId: string; fileHash: string; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbPrivateFileDownloadReq => ({
subCommand: 1200,
field2: 1,
body: {
receiverUid: p.selfUid,
fileUuid: p.fileId,
type: 2,
fileHash: p.fileHash,
t2: 0,
},
field101: 3,
field102: 103,
field200: 1,
field99999: new Uint8Array([0xC0, 0x85, 0x2C, 0x01]),
});
export const deserialize = (_ctx: Deps, body: OidbPrivateFileDownloadResp): OidbPrivateFileDownloadRespResult => {
const result = body.body?.result;
if (!result) throw new Error('private file url response invalid');
return result;
};
export const encode = (env: OidbBase<OidbPrivateFileDownloadReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbPrivateFileDownloadReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbPrivateFileDownloadResp> =>
protobuf_decode<OidbBase<OidbPrivateFileDownloadResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<OidbPrivateFileDownloadRespResult> =>
invokeOidb(deps, GetPrivateFileUrl, params, TIMEOUT_MS);
}
@@ -0,0 +1,48 @@
// 0x126D_200 — c2c-scope counterpart of GetGroupPttUrl. Same shape,
// `scene` is `c2c` rather than `group`. Needs the bot's own uid to
// fill the c2c.targetUid slot.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { NTV2RichMediaReq, NTV2RichMediaResp } from '@snowluma/proto-defs/oidb-actions/media';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import {
normalizeMediaNode, parseNtv2DownloadUrl, type NtMediaIndex,
} from './ntv2-download';
export namespace GetPrivatePttUrl {
export const command = 0x126D;
export const subCommand = 200;
export const uinForm = true;
export interface Params { selfUid: string; node: NtMediaIndex; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): NTV2RichMediaReq => ({
reqHead: {
common: { requestId: 1, command: 200 },
scene: {
requestType: 1,
businessType: 3,
sceneType: 1,
c2c: { accountType: 2, targetUid: p.selfUid },
},
client: { agentType: 2 },
},
download: {
node: normalizeMediaNode(p.node) as any,
download: { video: { busiType: 0, sceneType: 0 } },
},
});
export const deserialize = (_ctx: Deps, body: NTV2RichMediaResp): string => parseNtv2DownloadUrl(body);
export const encode = (env: OidbBase<NTV2RichMediaReq>): Uint8Array =>
protobuf_encode<OidbBase<NTV2RichMediaReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<NTV2RichMediaResp> =>
protobuf_decode<OidbBase<NTV2RichMediaResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<string> =>
invokeOidb(deps, GetPrivatePttUrl, params);
}
@@ -0,0 +1,48 @@
// 0x11E9_200 — c2c-scope video URL fetch (pair of GetGroupVideoUrl).
// `scene.c2c.targetUid` is the bot's own uid; the server uses it as
// the read-side identity for the asset lookup.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { NTV2RichMediaReq, NTV2RichMediaResp } from '@snowluma/proto-defs/oidb-actions/media';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import {
normalizeMediaNode, parseNtv2DownloadUrl, type NtMediaIndex,
} from './ntv2-download';
export namespace GetPrivateVideoUrl {
export const command = 0x11E9;
export const subCommand = 200;
export const uinForm = true;
export interface Params { selfUid: string; node: NtMediaIndex; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): NTV2RichMediaReq => ({
reqHead: {
common: { requestId: 1, command: 200 },
scene: {
requestType: 2,
businessType: 2,
sceneType: 1,
c2c: { accountType: 2, targetUid: p.selfUid },
},
client: { agentType: 2 },
},
download: {
node: normalizeMediaNode(p.node) as any,
download: { video: { busiType: 0, sceneType: 0 } },
},
});
export const deserialize = (_ctx: Deps, body: NTV2RichMediaResp): string => parseNtv2DownloadUrl(body);
export const encode = (env: OidbBase<NTV2RichMediaReq>): Uint8Array =>
protobuf_encode<OidbBase<NTV2RichMediaReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<NTV2RichMediaResp> =>
protobuf_decode<OidbBase<NTV2RichMediaResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<string> =>
invokeOidb(deps, GetPrivateVideoUrl, params);
}
@@ -0,0 +1,55 @@
// 0x6D8_1 — ONE page of the group-file listing under `targetDirectory`.
// Paginated; the facade loops this until `isEnd=true` or the page cap
// is hit. Each page yields a mix of files (`type=1`) and folders
// (`type=2`); the caller flattens them.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
OidbGroupFileViewReq, OidbGroupFileViewResp, OidbGroupFileListResp,
} from '@snowluma/proto-defs/oidb-actions/group-file';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace ListGroupFilesPage {
export const command = 0x6D8;
export const subCommand = 1;
export const uinForm = true;
export interface Params {
groupId: number;
targetDirectory: string;
startIndex: number;
pageSize: number;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbGroupFileViewReq => ({
list: {
groupUin: p.groupId,
appId: 7,
targetDirectory: p.targetDirectory,
fileCount: p.pageSize,
sortBy: 1,
startIndex: p.startIndex,
field17: 2,
field18: 0,
},
});
/** Returns the list body directly so the facade can inspect
* `items`, `isEnd`, and `retCode` in one place. Returns null when
* the server elides the list entirely (end-of-stream sentinel). */
export const deserialize = (_ctx: Deps, body: OidbGroupFileViewResp): OidbGroupFileListResp | null => {
return body.list ?? null;
};
export const encode = (env: OidbBase<OidbGroupFileViewReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupFileViewReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbGroupFileViewResp> =>
protobuf_decode<OidbBase<OidbGroupFileViewResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<OidbGroupFileListResp | null> =>
invokeOidb(deps, ListGroupFilesPage, params);
}
@@ -0,0 +1,47 @@
// 0x6D6_5 — move a group file between folders.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
OidbGroupFileReq, OidbGroupFileResp,
} from '@snowluma/proto-defs/oidb-actions/group-file';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import { ensureRetCodeZero } from '../shared';
export namespace MoveGroupFile {
export const command = 0x6D6;
export const subCommand = 5;
export const uinForm = true;
export interface Params {
groupId: number; fileId: string;
parentDirectory: string; targetDirectory: string;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbGroupFileReq => ({
move: {
groupUin: p.groupId,
appId: 7,
busId: 102,
fileId: p.fileId,
parentDirectory: p.parentDirectory,
targetDirectory: p.targetDirectory,
},
});
export const deserialize = (_ctx: Deps, body: OidbGroupFileResp): void => {
const result = body.move;
if (!result) throw new Error('group file move response missing');
ensureRetCodeZero('group file move', result.retCode, result.retMsg, result.clientWording);
};
export const encode = (env: OidbBase<OidbGroupFileReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupFileReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbGroupFileResp> =>
protobuf_decode<OidbBase<OidbGroupFileResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, MoveGroupFile, params);
}
@@ -0,0 +1,87 @@
// Shared deserializer for the four NTV2-rich-media URL fetchers:
// - get-group-ptt-url (0x126E_200)
// - get-private-ptt-url (0x126D_200)
// - get-group-video-url (0x11EA_200)
// - get-private-video-url (0x11E9_200)
//
// All four hit the `MultiMedia.OidbSvc.0x...` family with the same
// `NTV2RichMediaReq` shape; only the `scene` block + the wire cmd
// differ. The response is parsed into a `domain + urlPath +
// rKeyParam` triple → composed into `https://<domain><path><rKey>`.
import type { NTV2RichMediaResp } from '@snowluma/proto-defs/oidb-actions/media';
import { ensureRetCodeZero } from '../shared';
export function parseNtv2DownloadUrl(body: NTV2RichMediaResp): string {
ensureRetCodeZero('ntv2 download', body.respHead?.retCode, body.respHead?.message, undefined);
const domain = typeof body.download?.info?.domain === 'string' ? body.download.info.domain : '';
const path = typeof body.download?.info?.urlPath === 'string' ? body.download.info.urlPath : '';
const rKeyParam = typeof body.download?.rKeyParam === 'string' ? body.download.rKeyParam : '';
if (!domain || !path) throw new Error('ntv2 download response invalid');
return `https://${domain}${path}${rKeyParam}`;
}
/** Normalize a MediaIndexNode-shaped object into the wire-fields the
* NTV2RichMedia `download.node` slot expects: `info{...}` /
* `fileUuid` / `storeId` / `uploadTime` / `ttl` / `subType`. */
export function normalizeMediaNode(node: NtMediaIndex): Record<string, unknown> {
const fileUuid = typeof node.fileUuid === 'string' ? node.fileUuid : '';
if (!fileUuid) throw new Error('media node fileUuid is required');
const info = node.info ?? {};
const type = info.type ?? {};
return {
info: {
fileSize: toInt(info.fileSize),
fileHash: typeof info.fileHash === 'string' ? info.fileHash : '',
fileSha1: typeof info.fileSha1 === 'string' ? info.fileSha1 : '',
fileName: typeof info.fileName === 'string' ? info.fileName : '',
type: {
type: toInt(type.type),
picFormat: toInt(type.picFormat),
videoFormat: toInt(type.videoFormat),
voiceFormat: toInt(type.voiceFormat),
},
width: toInt(info.width),
height: toInt(info.height),
time: toInt(info.time),
original: toInt(info.original),
},
fileUuid,
storeId: toInt(node.storeId),
uploadTime: toInt(node.uploadTime),
ttl: toInt(node.ttl),
subType: toInt(node.subType),
};
}
function toInt(value: unknown): number {
if (typeof value === 'number' && Number.isFinite(value)) return Math.trunc(value);
if (typeof value === 'bigint') return Number(value);
return 0;
}
export interface NtMediaIndex {
info?: {
fileSize?: number;
fileHash?: string;
fileSha1?: string;
fileName?: string;
width?: number;
height?: number;
time?: number;
original?: number;
type?: {
type?: number;
picFormat?: number;
videoFormat?: number;
voiceFormat?: number;
};
};
fileUuid?: string;
storeId?: number;
uploadTime?: number;
ttl?: number;
subType?: number;
}
@@ -0,0 +1,47 @@
// 0x6D9_4 — publish a previously-uploaded group file as a chat
// message (the file-bubble in the group transcript).
//
// The QQ-NT server rejects the legacy `TransElem(elemType=24)` payload
// on outgoing send (`result=79`) so the file-publish path goes via a
// dedicated OIDB hop instead of `MessageSvc.PbSendMsg`. Mirror
// Lagrange.Core V2's `GroupSendFileService.cs`:
// - `info.field3` is a 31-bit random — Lagrange does `Random.Shared.Next()`
// - `info.field5 = true` is the discriminator the server's deserializer
// expects to recognise this branch.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbGroupSendFileReq } from '@snowluma/proto-defs/oidb-actions/group-file';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace PublishGroupFile {
export const command = 0x6D9;
export const subCommand = 4;
export interface Params { groupId: number; fileId: string; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbGroupSendFileReq => ({
body: {
groupUin: p.groupId,
type: 2,
info: {
busiType: 102,
fileId: p.fileId,
field3: Math.floor(Math.random() * 0x7fffffff) >>> 0,
field5: true,
},
},
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbGroupSendFileReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupSendFileReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, PublishGroupFile, params);
}
@@ -0,0 +1,43 @@
// 0x6D7_2 — rename a group folder. Note the wire field is
// `newFolderName` (not `folderName`); the rename slot lives on the
// shared `OidbGroupFileFolderReq` envelope.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
OidbGroupFileFolderReq, OidbGroupFileFolderResp,
} from '@snowluma/proto-defs/oidb-actions/group-file';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import { ensureRetCodeZero } from '../shared';
export namespace RenameGroupFolder {
export const command = 0x6D7;
export const subCommand = 2;
export const uinForm = true;
export interface Params { groupId: number; folderId: string; newFolderName: string; }
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbGroupFileFolderReq => ({
rename: {
groupUin: p.groupId,
folderId: p.folderId,
newFolderName: p.newFolderName,
},
});
export const deserialize = (_ctx: Deps, body: OidbGroupFileFolderResp): void => {
const result = body.rename;
if (!result) throw new Error('group folder rename response missing');
ensureRetCodeZero('group folder rename', result.retcode, result.retMsg, result.clientWording);
};
export const encode = (env: OidbBase<OidbGroupFileFolderReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupFileFolderReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbGroupFileFolderResp> =>
protobuf_decode<OidbBase<OidbGroupFileFolderResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, RenameGroupFolder, params);
}
@@ -0,0 +1,69 @@
// 0x6D6_0 — group-file upload preflight. Hands the server the file
// metadata + hashes and gets back:
// - `boolFileExist` — if true, the bytes are already on the server
// and the highway step is skipped
// - `fileId` — the persistent id used by `publish` (0x6D9_4) and
// later download/delete/move calls
// - upload host/port + the `fileKey`/`checkKey` blob the highway
// PUT needs in its FileUploadExt envelope
//
// This namespace ONLY does the preflight; the highway PUT and the
// follow-on `publish` chat-message hop live on the facade because
// they're orchestration (highway client, ext blob composition) that
// doesn't fit a single OIDB call boundary.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
OidbGroupFileReq, OidbGroupFileResp, OidbGroupFileUploadResp,
} from '@snowluma/proto-defs/oidb-actions/group-file';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace UploadGroupFileRequest {
export const command = 0x6D6;
export const subCommand = 0;
export const uinForm = true;
export interface Params {
groupId: number;
fileName: string;
folderId: string;
fileSize: number;
fileSha1: Uint8Array;
fileMd5: Uint8Array;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbGroupFileReq => ({
file: {
groupUin: p.groupId,
appId: 4,
busId: 102,
entrance: 6,
targetDirectory: p.folderId,
fileName: p.fileName,
localDirectory: `/${p.fileName}`,
fileSize: BigInt(p.fileSize),
fileSha1: p.fileSha1,
fileSha3: new Uint8Array(0),
fileMd5: p.fileMd5,
field15: true,
},
});
export const deserialize = (_ctx: Deps, body: OidbGroupFileResp): OidbGroupFileUploadResp => {
const upload = body.upload;
if (!upload) throw new Error('group file upload response missing');
return upload;
};
export const encode = (env: OidbBase<OidbGroupFileReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupFileReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbGroupFileResp> =>
protobuf_decode<OidbBase<OidbGroupFileResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<OidbGroupFileUploadResp> =>
invokeOidb(deps, UploadGroupFileRequest, params);
}
@@ -0,0 +1,70 @@
// 0xE37_1700 — private (c2c) file upload preflight. Server returns
// the same shape of upload-host info as the group-file path but the
// fields are laid out differently (rtpMediaPlatformUploadAddress is
// the primary host source on current QQ-NT; legacy `uploadIp` /
// `uploadDomain` / `uploadIpList[]` are fallbacks).
//
// As with the group-file preflight, this namespace ONLY does the
// preflight; the highway PUT and the follow-on `sendC2cFile` chat
// hop live on the facade.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
OidbPrivateFileUploadReq, OidbPrivateFileUploadResp,
OidbPrivateFileUploadRespBody,
} from '@snowluma/proto-defs/oidb-actions/media';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace UploadPrivateFileRequest {
export const command = 0xE37;
export const subCommand = 1700;
export interface Params {
senderUid: string;
receiverUid: string;
fileName: string;
fileSize: number;
fileSha1: Uint8Array;
fileMd5: Uint8Array;
/** md5 over the first 10 MiB; caller passes this in because we
* can't redo the hash here without re-reading the source. */
md510MCheckSum: Uint8Array;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbPrivateFileUploadReq => ({
command: 1700,
seq: 0,
upload: {
senderUid: p.senderUid,
receiverUid: p.receiverUid,
fileSize: p.fileSize,
fileName: p.fileName,
md510MCheckSum: p.md510MCheckSum,
sha1CheckSum: p.fileSha1,
localPath: '/',
md5CheckSum: p.fileMd5,
sha3CheckSum: new Uint8Array(0),
},
businessId: 3,
clientType: 1,
flagSupportMediaPlatform: 1,
});
export const deserialize = (_ctx: Deps, body: OidbPrivateFileUploadResp): OidbPrivateFileUploadRespBody => {
const upload = body.upload;
if (!upload) throw new Error('private file upload response missing');
return upload;
};
export const encode = (env: OidbBase<OidbPrivateFileUploadReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbPrivateFileUploadReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbPrivateFileUploadResp> =>
protobuf_decode<OidbBase<OidbPrivateFileUploadResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<OidbPrivateFileUploadRespBody> =>
invokeOidb(deps, UploadPrivateFileRequest, params);
}
@@ -0,0 +1,56 @@
// 0x7E5_104 — send "thumbs up" (赞) to another user (profile-card 点赞).
//
// Wire shape lives at fields 11/12/13 with a uid (NOT uin) target and a
// fixed `sourceId = 71` marker for the profile-card entry point. The
// server rejects uin-form payloads with "被点赞 QQ 号非法", so we resolve
// uin → uid through the identity service before encoding.
//
// `count` is the number of likes in this single call (QQ allows 1–20
// batched). Server caps daily quotas separately.
//
// Upstream parity:
// - Lagrange.Core `OidbSvcTrpcTcp0x7E5_104` (fields 11/12/13):
// dev/Lagrange.Core/.../Service/Oidb/Request/OidbSvcTrpcTcp0x7E5_104.cs:14-18
// - Lagrange.Core `FriendLikeService` (always emits `Field2 = 71`):
// dev/Lagrange.Core/.../Service/Action/FriendLikeService.cs:18-23
// - NapCat `UserApi.like` (`setBuddyProfileLike` with sourceId 71):
// dev/NapCatQQ/packages/napcat-core/apis/user.ts:63-70
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbLike } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export namespace SendLike {
export const command = 0x7E5;
export const subCommand = 104;
export interface Params {
userId: number;
count: number;
}
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
export const serialize = async (ctx: Deps, p: Params): Promise<OidbLike> => {
const targetUid = await ctx.resolveUserUid(p.userId);
if (!targetUid) throw new Error(`failed to resolve uid for ${p.userId}`);
return {
targetUid,
sourceId: 71,
count: p.count,
};
};
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbLike>): Uint8Array =>
protobuf_encode<OidbBase<OidbLike>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SendLike, params);
}
@@ -0,0 +1,48 @@
// 0xED3_1 — group / friend poke (the "戳一戳" / "拍一拍" notice).
//
// Same envelope shape for both flavors; the discriminator is which of
// `groupUin` / `friendUin` is set:
// - group poke: groupUin = peer (the group), friendUin = 0,
// uin = targetUin (the member being poked) or peer
// - friend poke: groupUin = 0, friendUin = peer (the friend's uin),
// uin = targetUin or peer
// `ext` is always 0; QQ-NT uses it for "double-poke" / "shake" subtypes
// that SnowLuma hasn't exposed yet.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbPoke } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace SendPoke {
export const command = 0xED3;
export const subCommand = 1;
export interface Params {
isGroup: boolean;
/** Group uin (if isGroup) or friend uin (otherwise). */
peerUin: number;
/** Specific member to poke in a group; defaults to peer for friend pokes. */
targetUin?: number;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbPoke => ({
uin: p.targetUin ?? p.peerUin,
groupUin: p.isGroup ? p.peerUin : 0,
friendUin: p.isGroup ? 0 : p.peerUin,
ext: 0,
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbPoke>): Uint8Array =>
protobuf_encode<OidbBase<OidbPoke>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SendPoke, params);
}
@@ -0,0 +1,44 @@
// 0xEAC — set / unset a group "essence" message (群精华).
// subCommand 1 = mark as essence, 2 = remove from essence
//
// `random` is the message's wire-level random field (carried through
// from the original send so the server can resolve the canonical
// message identity).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbEssence } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace SetEssence {
export const command = 0xEAC;
export interface Params {
groupId: number;
sequence: number;
random: number;
/** true = mark essence (subCmd 1), false = unmark (subCmd 2). */
enable: boolean;
}
export type Deps = OidbSender;
export const resolveSubCommand = (p: Params): number => p.enable ? 1 : 2;
export const serialize = (_ctx: Deps, p: Params): OidbEssence => ({
groupUin: p.groupId,
sequence: p.sequence,
random: p.random,
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbEssence>): Uint8Array =>
protobuf_encode<OidbBase<OidbEssence>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SetEssence, params);
}
@@ -0,0 +1,60 @@
// 0x112E_1 — relay an inline-keyboard-button click event to the bot
// owning the button (so the bot can react). All identity fields go on
// the wire as uint_64 → callers pass JS numbers and we widen here.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { Oidb0x112eReq, Oidb0x112eResp } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export interface InlineButtonClickResult {
result: number;
errMsg: string;
status: 0;
promptText: string;
promptType: 0;
promptIcon: 0;
}
export namespace ClickInlineKeyboardButton {
export const command = 0x112E;
export const subCommand = 1;
export interface Params {
groupId: number;
botAppid: number;
buttonId: string;
callbackData: string;
msgSeq: number;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): Oidb0x112eReq => ({
botAppid: BigInt(p.botAppid),
msgSeq: BigInt(p.msgSeq),
buttonId: String(p.buttonId),
callbackData: String(p.callbackData || ''),
unknown7: 0,
groupId: BigInt(p.groupId),
unknown9: 1,
});
export const deserialize = (_ctx: Deps, body: Oidb0x112eResp): InlineButtonClickResult => ({
result: Number(body.result || 0),
errMsg: body.errMsg || '',
status: 0,
promptText: body.promptText || '',
promptType: 0,
promptIcon: 0,
});
export const encode = (env: OidbBase<Oidb0x112eReq>): Uint8Array =>
protobuf_encode<OidbBase<Oidb0x112eReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<Oidb0x112eResp> =>
protobuf_decode<OidbBase<Oidb0x112eResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<InlineButtonClickResult> =>
invokeOidb(deps, ClickInlineKeyboardButton, params);
}
@@ -0,0 +1,48 @@
// 0xEB7_1 — group daily sign-in (群打卡).
//
// **Wire name case**: historically SnowLuma sent this cmd as
// `OidbSvcTrpcTcp.0xEB7_1` (uppercase EB7) while every other cmd uses
// lowercase. The server accepts either, but the refactor's hard rule
// is "wire-byte-equal to before", so we keep the uppercase via the
// `wireName` override. This is the ONLY cmd in the codebase with this
// quirk — every new cmd should use the default lowercase scheme.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { Oidb0xeb7Req, Oidb0xeb7Resp } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export namespace SendGroupSign {
export const command = 0xEB7;
export const subCommand = 1;
/** Override the default lowercase wire-name to preserve the
* historic `OidbSvcTrpcTcp.0xEB7_1` byte-for-byte. */
export const wireName = (): string => 'OidbSvcTrpcTcp.0xEB7_1';
export interface Params {
groupId: number;
}
export type Deps = OidbSender & Pick<BridgeContext, 'identity'>;
export const serialize = (ctx: Deps, p: Params): Oidb0xeb7Req => ({
signInInfo: {
uin: String(ctx.identity.uin),
groupId: String(p.groupId),
version: '9.0.90',
},
});
export const deserialize = (_ctx: Deps, _: Oidb0xeb7Resp): void => {};
export const encode = (env: OidbBase<Oidb0xeb7Req>): Uint8Array =>
protobuf_encode<OidbBase<Oidb0xeb7Req>>(env);
export const decode = (bytes: Uint8Array): OidbBase<Oidb0xeb7Resp> =>
protobuf_decode<OidbBase<Oidb0xeb7Resp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SendGroupSign, params);
}
@@ -0,0 +1,45 @@
// 0x990_2 — server-side English → Chinese translation. Returns the
// translated `dstWords` 1:1 paired with the input `words`. Magic
// constants `tag10=1` / `tag12=1` are documented as "always 1" in
// production traffic (purpose unknown).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { Oidb0x990Req, Oidb0x990Resp } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace TranslateEnToZh {
export const command = 0x990;
export const subCommand = 2;
export interface Params {
words: string[];
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): Oidb0x990Req => ({
translateReq: {
srcLang: 'en',
dstLang: 'zh',
words: p.words,
},
tag10: 1,
tag12: 1,
});
export const deserialize = (_ctx: Deps, body: Oidb0x990Resp): string[] => {
const resp = body.translateResp;
if (!resp) throw new Error('translate response empty');
return resp.dstWords || [];
};
export const encode = (env: OidbBase<Oidb0x990Req>): Uint8Array =>
protobuf_encode<OidbBase<Oidb0x990Req>>(env);
export const decode = (bytes: Uint8Array): OidbBase<Oidb0x990Resp> =>
protobuf_decode<OidbBase<Oidb0x990Resp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<string[]> =>
invokeOidb(deps, TranslateEnToZh, params);
}
@@ -0,0 +1,100 @@
// 0x7ED_12 — fetch QQ "thumbs up" (赞) summary for self or another user.
//
// Self lookup needs the bot's own UID, hence the `identity` dependency.
// For other users we use `resolveUserUid` to translate the uin first.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { Oidb0x7edReq, Oidb0x7edResp } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export interface LikeInfo {
uid: string;
time: number;
favoriteInfo: {
total_count: number;
last_time: number;
today_count: number;
userInfos: never[];
};
voteInfo: {
total_count: number;
new_count: number;
new_nearby_count: number;
last_visit_time: number;
userInfos: never[];
};
}
export namespace GetLike {
export const command = 0x7ED;
export const subCommand = 12;
export interface Params {
/** Omit / 0 → query self. */
userId?: number;
start?: number;
limit?: number;
}
export type Deps = OidbSender & Pick<BridgeContext, 'identity' | 'resolveUserUid'>;
export const serialize = async (ctx: Deps, p: Params): Promise<Oidb0x7edReq> => {
const targetUid = p.userId
? await ctx.resolveUserUid(p.userId)
: await resolveSelf(ctx);
if (!targetUid) throw new Error('target uid not found');
return {
targetUid,
basic: 1,
vote: 1,
favorite: 1,
start: p.start ?? 0,
limit: p.limit ?? 10,
};
};
export const deserialize = (_ctx: Deps, body: Oidb0x7edResp): LikeInfo => {
const data = body.userLikeInfos?.[0];
if (!data) throw new Error('get profile like info empty');
return {
uid: data.uid ?? '',
time: Number(data.time ?? 0),
favoriteInfo: {
total_count: data.favoriteInfo?.totalCount || 0,
last_time: Number(data.favoriteInfo?.lastTime || 0),
today_count: data.favoriteInfo?.newCount || 0,
userInfos: [],
},
voteInfo: {
total_count: data.voteInfo?.totalCount || 0,
new_count: data.voteInfo?.newCount || 0,
new_nearby_count: 0,
last_visit_time: Number(data.voteInfo?.lastTime || 0),
userInfos: [],
},
};
};
export const encode = (env: OidbBase<Oidb0x7edReq>): Uint8Array =>
protobuf_encode<OidbBase<Oidb0x7edReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<Oidb0x7edResp> =>
protobuf_decode<OidbBase<Oidb0x7edResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<LikeInfo> =>
invokeOidb(deps, GetLike, params);
}
async function resolveSelf(deps: Pick<BridgeContext, 'identity' | 'resolveUserUid'>): Promise<string> {
// Mirrors `apis/shared.ts::resolveSelfUid` — kept inline here so the
// namespace is self-contained against just the BridgeContext slice.
const cached = deps.identity.selfUid;
if (cached) return cached;
const selfUin = Number(deps.identity.uin);
if (!Number.isFinite(selfUin) || selfUin <= 0) {
throw new Error('self uid is unavailable');
}
return deps.resolveUserUid(selfUin);
}
@@ -0,0 +1,52 @@
// 0xE17_0 — fetch the unidirectional friend block list. Wire name is
// non-standard (`MQUpdateSvc_com_qq_ti.web.OidbSvc.0xe17_0`) — uses
// the `wireName` override to bypass the default
// `OidbSvcTrpcTcp.0xNNNN_N` scheme.
//
// Request and response carry a JSON-encoded string in a single
// protobuf field, so the namespace's `serialize` / `deserialize` do
// the JSON marshalling.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { Oidb0xe17Req, Oidb0xe17Resp } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export namespace GetUnidirectionalFriendList {
export const command = 0xE17;
export const subCommand = 0;
/** Wire name override — this cmd lives outside the standard
* `OidbSvcTrpcTcp.0xNNNN_N` namespace. */
export const wireName = (): string => 'MQUpdateSvc_com_qq_ti.web.OidbSvc.0xe17_0';
export interface Params {}
export type Deps = OidbSender & Pick<BridgeContext, 'identity'>;
export const serialize = (ctx: Deps, _p: Params): Oidb0xe17Req => {
const reqObj = {
uint64_uin: String(ctx.identity.uin),
uint64_top: 0,
uint32_req_num: 99,
bytes_cookies: '',
};
return { jsonBody: JSON.stringify(reqObj) };
};
export const deserialize = (_ctx: Deps, body: Oidb0xe17Resp): unknown[] => {
if (!body || !body.jsonBody) throw new Error('get unidirectional friend list empty');
const parsed = JSON.parse(body.jsonBody);
return parsed.rpt_block_list || [];
};
export const encode = (env: OidbBase<Oidb0xe17Req>): Uint8Array =>
protobuf_encode<OidbBase<Oidb0xe17Req>>(env);
export const decode = (bytes: Uint8Array): OidbBase<Oidb0xe17Resp> =>
protobuf_decode<OidbBase<Oidb0xe17Resp>>(bytes);
export const invoke = (deps: Deps): Promise<unknown[]> =>
invokeOidb(deps, GetUnidirectionalFriendList, {});
}
@@ -0,0 +1,47 @@
// 0xCD4_1 — set typing / recording / etc. "input status" indicator
// shown to a peer in a 1:1 chat.
//
// Resolves the target uin → uid via the identity service before
// building the body. `chatType: 0` is the wire constant for friend
// chats (the only flavor SnowLuma currently supports here).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { Oidb0xcd4Req, Oidb0xcd4Resp } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export namespace SetInputStatus {
export const command = 0xCD4;
export const subCommand = 1;
export interface Params {
userId: number;
eventType: number;
}
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
export const serialize = async (ctx: Deps, p: Params): Promise<Oidb0xcd4Req> => {
const targetUid = await ctx.resolveUserUid(p.userId);
if (!targetUid) throw new Error('target uid not found');
return {
reqBody: {
uid: targetUid,
chatType: 0,
eventType: p.eventType,
},
};
};
export const deserialize = (_ctx: Deps, _: Oidb0xcd4Resp): void => {};
export const encode = (env: OidbBase<Oidb0xcd4Req>): Uint8Array =>
protobuf_encode<OidbBase<Oidb0xcd4Req>>(env);
export const decode = (bytes: Uint8Array): OidbBase<Oidb0xcd4Resp> =>
protobuf_decode<OidbBase<Oidb0xcd4Resp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SetInputStatus, params);
}
@@ -0,0 +1,50 @@
// 0x112A_2 — write profile string/int field-value pairs.
//
// SnowLuma's facade currently exposes only nickname (field 20002) and
// personalNote (field 102) but the underlying wire supports arbitrary
// (fieldId, value) tuples. The `invoke` short-circuits when both
// inputs are undefined so the facade's historic no-op-on-no-input
// behaviour is preserved (no wasted SSO round-trip).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { Oidb0x112aResp, OidbSetProfile } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export namespace SetProfile {
export const command = 0x112A;
export const subCommand = 2;
export interface Params {
nickname?: string;
personalNote?: string;
}
/** Needs identity to read `uin` for the request body. */
export type Deps = OidbSender & Pick<BridgeContext, 'identity'>;
export const serialize = (ctx: Deps, p: Params): OidbSetProfile => {
const stringProfiles: { fieldId: number; value: string }[] = [];
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 };
};
export const deserialize = (_ctx: Deps, _: Oidb0x112aResp): void => {};
export const encode = (env: OidbBase<OidbSetProfile>): Uint8Array =>
protobuf_encode<OidbBase<OidbSetProfile>>(env);
export const decode = (bytes: Uint8Array): OidbBase<Oidb0x112aResp> =>
protobuf_decode<OidbBase<Oidb0x112aResp>>(bytes);
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) {
return Promise.resolve();
}
return invokeOidb(deps, SetProfile, params);
};
}
@@ -0,0 +1,39 @@
// 0x112A_2 — set the self "long nick" / personal signature. Same cmd
// as SetProfile but a different request shape (uses the single
// `profile: { tag, value }` field instead of the repeated string
// profiles list). Kept separate because the wire body is structurally
// different — proton needs distinct types so the codec is correctly
// monomorphized per call site.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { Oidb0x112aReq, Oidb0x112aResp } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
export namespace SetSelfLongNick {
export const command = 0x112A;
export const subCommand = 2;
export interface Params {
longNick: string;
}
export type Deps = OidbSender & Pick<BridgeContext, 'identity'>;
export const serialize = (ctx: Deps, p: Params): Oidb0x112aReq => ({
uin: BigInt(ctx.identity.uin),
profile: { tag: 102, value: String(p.longNick) },
});
export const deserialize = (_ctx: Deps, _: Oidb0x112aResp): void => {};
export const encode = (env: OidbBase<Oidb0x112aReq>): Uint8Array =>
protobuf_encode<OidbBase<Oidb0x112aReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<Oidb0x112aResp> =>
protobuf_decode<OidbBase<Oidb0x112aResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SetSelfLongNick, params);
}
@@ -0,0 +1,72 @@
// 0x9084_1 — fetch per-emoji reaction summary on a group message.
//
// Server returns the full summary unconditionally; the emoji_id /
// emoji_type / count fields in the request body are ignored by the
// summary handler but kept to mirror the working 0x9083_1 request shape
// (same `Pick` of fields the wire format prefers).
//
// "Used" entries carry (lastReactionTime, count, emojiType, emojiId).
// Catalog-tail entries (available reactions the server suggests but
// nobody has reacted with) carry only emojiType + emojiId — filtered
// out here so callers see only the meaningful subset.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
Oidb0x9084Req, Oidb0x9084Resp,
} from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace FetchReactionSummary {
export const command = 0x9084;
export const subCommand = 1;
export interface Params {
groupId: number;
sequence: number;
}
export interface ReactionSummaryEntry {
emojiId: string;
emojiType: number;
count: number;
/** Unix epoch seconds of the most recent reaction. */
lastReactionTime: number;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): Oidb0x9084Req => ({
groupId: BigInt(p.groupId),
sequence: BigInt(p.sequence),
emojiId: '',
emojiType: 0,
cookie: new Uint8Array(0),
count: 0,
field12: 1,
});
export const deserialize = (_ctx: Deps, body: Oidb0x9084Resp): ReactionSummaryEntry[] => {
const out: ReactionSummaryEntry[] = [];
for (const e of body.entries ?? []) {
const count = e.count ?? 0;
if (count <= 0) continue; // skip catalog-tail entries
out.push({
emojiId: e.emojiId ?? '',
emojiType: e.emojiType ?? 1,
count,
lastReactionTime: Number(e.lastReactionTime ?? 0n),
});
}
return out;
};
export const encode = (env: OidbBase<Oidb0x9084Req>): Uint8Array =>
protobuf_encode<OidbBase<Oidb0x9084Req>>(env);
export const decode = (bytes: Uint8Array): OidbBase<Oidb0x9084Resp> =>
protobuf_decode<OidbBase<Oidb0x9084Resp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<ReactionSummaryEntry[]> =>
invokeOidb(deps, FetchReactionSummary, params);
}
@@ -0,0 +1,71 @@
// 0x9083_1 — historic "fetch reactor user list" cmd. CONFIRMED to be
// a real server endpoint (errorCode=0, trace string echoes the cmd
// name), but its reply is always a 4-byte minimal ack `18 01 20 01`
// regardless of the message / emoji / whether the bot just set a
// reaction. The actual "who reacted" data is NOT served via SSO at
// all — NTQQ's own client uses a wrapper-internal cache. SnowLuma
// mirrors that with `ReactionStore` (fed from GroupMsgEmojiLikeEvent
// push) on the OneBot side.
//
// This namespace exists as a legacy stub so older callers don't crash
// — `invoke` always returns an empty user list. Newer code should
// query `ReactionStore` instead.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type {
Oidb0x9083Req, Oidb0x9083Resp,
} from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace GetEmojiLikes {
export const command = 0x9083;
export const subCommand = 1;
export interface Params {
groupId: number;
sequence: number;
emojiId: string;
emojiType?: number;
count?: number;
/** Base64-encoded continuation cookie from a previous page. */
cookie?: string;
}
export interface Result {
users: Array<{ uin: number }>;
/** Base64 cookie for next page (empty when on last page). */
cookie: string;
isLast: boolean;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): Oidb0x9083Req => ({
groupId: BigInt(p.groupId),
sequence: BigInt(p.sequence),
emojiId: p.emojiId,
emojiType: p.emojiType ?? 1,
cookie: p.cookie ? Buffer.from(p.cookie, 'base64') : new Uint8Array(0),
field7: 0,
count: p.count ?? 10,
field12: 1,
});
export const deserialize = (_ctx: Deps, body: Oidb0x9083Resp): Result => {
const users: Array<{ uin: number }> = (body.inner?.userInfo ?? [])
.map(u => ({ uin: Number(u?.uin ?? 0) }))
.filter(u => u.uin > 0);
const cookie = body.cookie ? Buffer.from(body.cookie).toString('base64') : '';
return { users, cookie, isLast: !cookie };
};
export const encode = (env: OidbBase<Oidb0x9083Req>): Uint8Array =>
protobuf_encode<OidbBase<Oidb0x9083Req>>(env);
export const decode = (bytes: Uint8Array): OidbBase<Oidb0x9083Resp> =>
protobuf_decode<OidbBase<Oidb0x9083Resp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<Result> =>
invokeOidb(deps, GetEmojiLikes, params);
}
@@ -0,0 +1,54 @@
// 0x9082 — set / unset emoji reaction on a group message.
// subCommand 1 = set, 2 = unset
//
// Cross-checked against LagrangeV2
// `Internal/Packets/Service/SetGroupReaction.cs`:
// field 2 groupUin (long)
// field 3 sequence (ulong)
// field 4 code (string) ← emoji id
// field 5 type (ulong) ← 1 for QQ-face short id, 2 for unicode codepoint
// (Heuristic on `code.length > 3` matches Lagrange's
// `GroupAddReactionEvent.IsEmoji` discriminator.)
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { OidbGroupReaction } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace SetReaction {
export const command = 0x9082;
export interface Params {
groupId: number;
sequence: number;
/** Emoji code. 1–3 digits → QQ face (type=1); longer → unicode (type=2). */
code: string;
/** true = set reaction (subCommand 1), false = unset (subCommand 2). */
isSet: boolean;
}
/** Only the wire-send capability is needed. */
export type Deps = OidbSender;
export const resolveSubCommand = (p: Params): number => p.isSet ? 1 : 2;
export const serialize = (_ctx: Deps, p: Params): OidbGroupReaction => ({
groupUin: p.groupId,
sequence: p.sequence,
code: p.code,
type: p.code.length > 3 ? 2 : 1,
field6: false,
field7: false,
});
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
export const encode = (env: OidbBase<OidbGroupReaction>): Uint8Array =>
protobuf_encode<OidbBase<OidbGroupReaction>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SetReaction, params);
}
@@ -0,0 +1,28 @@
// Tiny helpers shared between OIDB namespaces — kept here instead of
// `@snowluma/core/bridge/apis/shared` to avoid a circular dep
// (services live in @snowluma/protocol, facades in @snowluma/core).
/** Coerce numbers, strings, and bigints to a plain integer. */
export function toInt(value: unknown): number {
if (typeof value === 'number' && Number.isFinite(value)) return Math.trunc(value);
if (typeof value === 'bigint') {
const n = Number(value);
return Number.isFinite(n) ? Math.trunc(n) : 0;
}
if (typeof value === 'string' && value.trim()) {
const n = Number(value);
return Number.isFinite(n) ? Math.trunc(n) : 0;
}
return 0;
}
/** Standard OIDB sub-response check: throw a typed Error if retCode != 0.
* Prefers `wording` over `msg` for the human-facing message. */
export function ensureRetCodeZero(
operation: string, code: unknown, msg: unknown, wording: unknown,
): void {
const retCode = toInt(code);
if (retCode === 0) return;
const text = (typeof wording === 'string' && wording) || (typeof msg === 'string' && msg) || 'unknown error';
throw new Error(`${operation} failed: code=${retCode} msg=${text}`);
}
@@ -0,0 +1,43 @@
// 0x102A_1 — fetch a fresh `clientKey` (consumed by the ptlogin2 jump
// URL flow that swaps it for cookie-jar entries on qq.com subdomains).
//
// The server's `keyIndex` field is occasionally empty in the wild;
// every NapCat-derived implementation falls back to the literal "19"
// in that case — origin unknown but the value works.
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { OidbClientKeyReq, OidbClientKeyResp } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export interface ClientKeyInfo {
clientKey: string;
keyIndex: string;
expireTime: string;
}
export namespace ForceFetchClientKey {
export const command = 0x102A;
export const subCommand = 1;
export interface Params {}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, _: Params): OidbClientKeyReq => ({});
export const deserialize = (_ctx: Deps, body: OidbClientKeyResp): ClientKeyInfo => ({
clientKey: body.clientKey || '',
keyIndex: String(body.keyIndex || '19'),
expireTime: String(body.expireTime || '1800'),
});
export const encode = (env: OidbBase<OidbClientKeyReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbClientKeyReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbClientKeyResp> =>
protobuf_decode<OidbBase<OidbClientKeyResp>>(bytes);
export const invoke = (deps: Deps): Promise<ClientKeyInfo> =>
invokeOidb(deps, ForceFetchClientKey, {});
}
@@ -0,0 +1,48 @@
// 0x102A_0 — request p_skey cookies for a list of qq.com subdomains.
// Used as the fallback when ptlogin2 jump doesn't emit a p_skey on
// the cookie set (intermittent server behaviour).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { OidbBase } from '@snowluma/proto-defs/oidb';
import type { OidbGetPskeyReq, OidbGetPskeyResp } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
export namespace GetPskey {
export const command = 0x102A;
export const subCommand = 0;
export interface Params {
domainList: string[];
}
export interface Result {
domainPskeyMap: Map<string, string>;
}
export type Deps = OidbSender;
export const serialize = (_ctx: Deps, p: Params): OidbGetPskeyReq => ({
domainList: p.domainList,
});
export const deserialize = (_ctx: Deps, body: OidbGetPskeyResp): Result => {
const domainPskeyMap = new Map<string, string>();
if (body.pskeyItems && Array.isArray(body.pskeyItems)) {
for (const item of body.pskeyItems) {
if (item.domain && item.pskey) {
domainPskeyMap.set(item.domain, item.pskey);
}
}
}
return { domainPskeyMap };
};
export const encode = (env: OidbBase<OidbGetPskeyReq>): Uint8Array =>
protobuf_encode<OidbBase<OidbGetPskeyReq>>(env);
export const decode = (bytes: Uint8Array): OidbBase<OidbGetPskeyResp> =>
protobuf_decode<OidbBase<OidbGetPskeyResp>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<Result> =>
invokeOidb(deps, GetPskey, params);
}