完善半自动真实履约链路及虎牙账号资料保存

This commit is contained in:
yml
2026-11-14 09:23:37 +08:00
parent 3ea5dd5ce4
commit 81a7721ee1
13 changed files with 662 additions and 31 deletions
@@ -421,6 +421,10 @@ function parseProfile(reader: TafReader): HuyaUserProfile {
return { uid, nick, avatar, passport }
}
function parseProfileResponse(reader: TafReader): HuyaUserProfile | null {
return parseProfile(reader)
}
function parseProfileBatch(reader: TafReader): HuyaUserProfileResponse {
const profiles =
reader.readList<HuyaUserProfile>(0, (itemReader, dataType) => {
@@ -543,6 +547,26 @@ export class HuyaRpcClient {
return response ? readWupStruct(response, parseProfileBatch) : null
}
async getUserProfile(input: {
uid: number
cookie: string
targetUid: number
}): Promise<HuyaUserProfile | null> {
const targetUid = Math.trunc(input.targetUid)
if (!(targetUid > 0)) return null
const response = await this.callRpc(
'huyauserui',
'getUserProfile',
input.uid,
input.cookie,
(writer) => {
this.writeActivityUser(writer, 0, input.cookie)
writer.writeInt64(1, targetUid)
},
)
return response ? readWupStruct(response, parseProfileResponse) : null
}
private async callRpc(
servant: string,
func: string,