feat(onebot): expose birthdays in stranger profiles (#594)

Include available birthday information in stranger profiles and preserve hidden birth years.
This commit is contained in:
C₂₂H₂₅NO₆ authored and GitHub committed 2026-10-31 18:01:16 +08:00
1 parent 6b8362e049
commit 947af4b22c
10 files changed
+192 -6

No files matched your search

@@ -22,7 +22,7 @@ import type {
OidbUserInfoResponse,
} from '@snowluma/proto-defs/oidb-actions/base';
import type { UserProfileInfo } from '../../qq-info';
import { applyOnlineStatus, applyProfileDetails } from './fetch-user-profile';
import { applyBirthday, applyOnlineStatus, applyProfileDetails } from './fetch-user-profile';
import { invokeOidb, type OidbSender } from '../../oidb-service';
const REQUESTED_KEYS = [
@@ -109,6 +109,7 @@ export namespace FetchUserProfileByUid {
info.level = numMap.get(105) ?? 0;
applyOnlineStatus(info, bytesMap, numMap);
applyProfileDetails(info, numMap);
applyBirthday(info, bytesMap);
// 企点标志:40410 / 42031,服务器仅在返回时才出现(普通账号缺省 → 0)
info.qidianMasterFlag = numMap.get(42031) ?? 0;
info.qidianCrewFlag = numMap.get(40410) ?? 0;
@@ -14,6 +14,7 @@
// 105 — QQ level (numeric)
// 20002 — nickname
// 20009 — gender (1 male / 2 female / 255 unknown)
// 20031 — birthday (4 bytes: uint16 BE year, month, day)
// 20037 — age
// 27394 — QID
@@ -85,6 +86,35 @@ export function applyProfileDetails(info: UserProfileInfo, numMap: Map<number, n
}
}
/**
* 生日(bytes-property 20031):年 uint16 大端 + 月 + 日,与 Lagrange.Core
* `FetchStrangerService.cs` 的解析一致。月或日为 0 表示未设置生日;
* 年份为 0 表示未公开出生年份,此时只省略年份。
*/
export function applyBirthday(info: UserProfileInfo, bytesMap: Map<number, Uint8Array>): void {
const raw = bytesMap.get(20031);
if (!raw || raw.length < 4) {
return;
}
const bytes = Buffer.from(raw);
const year = bytes.readUInt16BE(0);
const month = bytes.readUInt8(2);
const day = bytes.readUInt8(3);
if (month < 1 || month > 12 || day < 1 || day > 31) {
return;
}
if (year > 0) {
info.birthdayYear = year;
}
info.birthdayMonth = month;
info.birthdayDay = day;
}
const REQUESTED_KEYS = [
20002, 27394, 20009, 20031, 101, 103, 102, 20020, 20003, 20026, 105, 27372, 27406, 20037, 41756,
41757, 42241,
@@ -174,6 +204,7 @@ export namespace FetchUserProfile {
info.level = numMap.get(105) ?? 0;
applyOnlineStatus(info, bytesMap, numMap);
applyProfileDetails(info, numMap);
applyBirthday(info, bytesMap);
// 企点标志:40410 / 42031,服务器仅在返回时才出现(普通账号缺省 → 0)
info.qidianMasterFlag = numMap.get(42031) ?? 0;
info.qidianCrewFlag = numMap.get(40410) ?? 0;
+7
View File
@@ -13,6 +13,13 @@ export interface UserProfileInfo {
* `FetchStrangerService.cs` confirms `// Level`. */
level: number;
regTime?: number;
/**
* 生日 — OIDB 0xFE1_2 bytes-property key 20031。
* 月日未设置时三项均缺省;出生年份未公开(年份为 0)时仅缺省 birthdayYear。
*/
birthdayYear?: number;
birthdayMonth?: number;
birthdayDay?: number;
vipFlag?: boolean;
yearVipFlag?: boolean;
svipFlag?: boolean;