feat: implement set qq profile

This commit is contained in:
H3CoF6 committed 2026-05-09 05:08:03 +08:00
1 parent 049ef2960c
commit 8b313fe088
6 files changed
+76 -2

No files matched your search

@@ -46,6 +46,7 @@ import {
SsoReadedReportReqSchema,
SetStatusReqSchema,
SetStatusRespSchema,
OidbSetProfileSchema,
} from './proto/oidb-action';
import { FileUploadExtSchema } from './proto/highway';
import {
@@ -1321,4 +1322,40 @@ export async function setOnlineStatus(
throw new Error(resp.errMsg || `set online status failed with errCode: ${resp.errCode}`);
}
}
}
export async function setProfile(
bridge: Bridge,
nickname?: string,
personalNote?: string
): Promise<void> {
const uin = BigInt(bridge.qqInfo.uin);
const stringProfiles: any[] = [];
const intProfiles: any[] = [];
if (nickname !== undefined) {
stringProfiles.push({ fieldId: 20002, value: nickname });
}
if (personalNote !== undefined) {
stringProfiles.push({ fieldId: 102, value: personalNote });
}
if (stringProfiles.length === 0 && intProfiles.length === 0) {
return;
}
const req = {
uin,
stringProfiles,
};
await sendOidbAndCheck(
bridge,
'OidbSvcTrpcTcp.0x112a_2',
0x112A,
2,
req,
OidbSetProfileSchema
);
}
+5
View File
@@ -66,6 +66,7 @@ import {
setFriendRemark as setFriendRemark_,
fetchGroupFileCount as fetchGroupFileCount_,
setOnlineStatus as setOnlineStatus_,
setProfile as setProfile_,
} from './bridge-actions';
import {
getGroupHonorInfo as getGroupHonorInfo_,
@@ -492,6 +493,10 @@ export class Bridge {
async setOnlineStatus(status: number, extStatus: number = 0, batteryStatus: number = 100): Promise<void> {
return setOnlineStatus_(this, status, extStatus, batteryStatus);
}
async setProfile(nickname?: string, personalNote?: string): Promise<void> {
return setProfile_(this, nickname, personalNote);
}
}
// --- Module-level helper functions ---
@@ -846,3 +846,20 @@ export const SetStatusRespSchema = {
errCode: { field: 1, type: 'int32' as const }, // 盲猜字段 1 是错误码(虽然成功时没下发,默认 0)
errMsg: { field: 2, type: 'string' as const }, // 返回的 "set status success"
} satisfies ProtoSchema;
export const OidbProfileStringItemSchema = {
fieldId: { field: 1, type: 'uint32' as const },
value: { field: 2, type: 'string' as const },
} satisfies ProtoSchema;
export const OidbProfileIntItemSchema = {
fieldId: { field: 1, type: 'uint32' as const },
value: { field: 2, type: 'uint64' as const },
} satisfies ProtoSchema;
export const OidbSetProfileSchema = {
uin: { field: 1, type: 'uint64' as const },
stringProfiles: { field: 2, type: 'repeated_message' as const, schema: OidbProfileStringItemSchema },
intProfiles: { field: 3, type: 'repeated_message' as const, schema: OidbProfileIntItemSchema },
} satisfies ProtoSchema;
+15 -2
View File
@@ -527,8 +527,21 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
return okResponse({ file: pathMod.resolve(filePath) });
});
h.registerAction('set_qq_profile', async () => {
return failedResponse(RETCODE.ACTION_FAILED, 'not yet implemented');
h.registerAction('set_qq_profile', async (params) => {
const nickname = params.nickname !== undefined ? asString(params.nickname) : undefined;
const personalNote = params.personal_note !== undefined ? asString(params.personal_note) : undefined;
if (!ctx.setProfile) {
return failedResponse(RETCODE.ACTION_FAILED, 'not implemented');
}
try {
await ctx.setProfile(nickname, personalNote);
return okResponse();
} catch (e) {
return failedResponse(RETCODE.ACTION_FAILED, String(e));
}
});
h.registerAction('set_online_status', async (params) => {
+1
View File
@@ -77,6 +77,7 @@ export interface ApiActionContext {
deleteEssenceMsg?: (messageId: number) => Promise<void>;
forceFetchClientKey? : () => Promise<{clientKey: string, keyIndex: string, expireTime: string}>;
setOnlineStatus?: (status: number, extStatus?: number, batteryStatus?: number) => Promise<void>;
setProfile?: (nickname?: string, personalNote?: string) => Promise<void>;
// New context methods
setGroupReaction?: (groupId: number, sequence: number, code: string, isSet: boolean) => Promise<void>;
handleDeleteFriend?: (userId: number, block?: boolean) => Promise<void>;
@@ -125,6 +125,7 @@ export function buildApiContext(ref: InstanceRef): ApiActionContext {
markGroupMsgAsRead: (groupId: number, sequence: number) => bridge.markGroupMsgAsRead(groupId, sequence),
markPrivateMsgAsRead: (userId: number, sequence: number) => bridge.markPrivateMsgAsRead(userId, sequence),
setOnlineStatus: (status: number, extStatus?: number, batteryStatus?: number) => bridge.setOnlineStatus(status, extStatus, batteryStatus),
setProfile: (nickname?: string, personalNote?: string) => bridge.setProfile(nickname, personalNote),
// web
getGroupHonorInfo: (groupId: number, type: WebHonorType | string)=> bridge.getGroupHonorInfo(groupId, type),
getGroupEssence: (groupId: number, pageStart: number = 0, pageLimit: number = 50) => bridge.getGroupEssence(groupId, pageStart, pageLimit),