feat(onebot): expose qidian account flags on stranger info

Return qidian master and crew flags from get_stranger_info so callers can tell a qidian account from a normal one. Ordinary accounts keep the flags at zero. Existing stranger fields are unchanged.

Refs #404
This commit is contained in:
makotowu authored and GitHub committed 2026-08-22 12:36:22 +08:00
1 parent 6782fd9cb3
commit 83f643f01b
9 files changed
+97 -3

No files matched your search

+1
View File
@@ -525,6 +525,7 @@ async function warmUpBridgeState(
uin: f.uin, uid: f.uid,
nickname: f.nickname || uin,
remark: '', qid: '', sex: 'unknown', age: 0, sign: '', avatar: '', level: 0,
qidianMasterFlag: 0, qidianCrewFlag: 0, qidianCrewFlag2: 0,
});
bridge.identity.nickname = f.nickname || uin;
log.debug('self info: UIN=%s uid=%s nickname=%s', uin, f.uid, f.nickname ?? '');
@@ -296,6 +296,9 @@ function formatStrangerInfo(p: UserProfileInfo): JsonObject {
batteryStatus: p.batteryStatus ?? 0,
customStatus: p.customStatus ?? null,
customStatusDescInfo: p.customStatusDesc ?? '',
qidian_master_flag: p.qidianMasterFlag,
qidian_crew_flag: p.qidianCrewFlag,
qidian_crew_flag_2: p.qidianCrewFlag2,
};
}
+20 -1
View File
@@ -104,7 +104,8 @@ function makeProfile(
remark = '',
): UserProfileInfo {
return {
uin, uid: `u_${uin}`, nickname, remark, qid: '', sex, age, sign, avatar: '',
uin, uid: `u_${uin}`, nickname, remark, qid: '', sex, age, sign, avatar: '', level: 0,
qidianMasterFlag: 0, qidianCrewFlag: 0, qidianCrewFlag2: 0,
};
}
@@ -547,6 +548,24 @@ describe('onebot/contact-actions / getStrangerInfo', () => {
});
});
it('passes through the qidian (企点) flags from the profile', async () => {
const bridge = fakeBridge({
fetchUserProfile: vi.fn(async () => ({
...makeProfile(55555, 'QidianWorker', 'male'),
qidianMasterFlag: 0,
qidianCrewFlag: 1,
qidianCrewFlag2: 0,
})),
});
const out = await getStrangerInfo(bridge, 55555);
expect(out).toMatchObject({
user_id: 55555,
qidian_master_flag: 0,
qidian_crew_flag: 1,
qidian_crew_flag_2: 0,
});
});
it('falls back to identity.findUserProfile when fetch fails but the profile is cached', async () => {
const bridge = fakeBridge({
fetchUserProfile: vi.fn(async () => { throw new Error('net'); }),