mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
feat: 好友等级
This commit is contained in:
@@ -93,8 +93,8 @@ export class NTQQUserApi {
|
|||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUserDetailInfo(uid: string): Promise<User> {
|
async getUserDetailInfo(uid: string, no_cache: boolean = false): Promise<User> {
|
||||||
let profile = await solveAsyncProblem(async (uid) => this.fetchUserDetailInfo(uid, UserDetailSource.KDB), uid);
|
let profile = await solveAsyncProblem(async (uid) => this.fetchUserDetailInfo(uid, no_cache ? UserDetailSource.KSERVER : UserDetailSource.KDB), uid);
|
||||||
if (profile && profile.uin !== '0' && profile.commonExt) {
|
if (profile && profile.uin !== '0' && profile.commonExt) {
|
||||||
return {
|
return {
|
||||||
...profile.simpleInfo.status,
|
...profile.simpleInfo.status,
|
||||||
|
@@ -207,6 +207,7 @@ interface PhotoWall {
|
|||||||
|
|
||||||
// 简单信息
|
// 简单信息
|
||||||
export interface SimpleInfo {
|
export interface SimpleInfo {
|
||||||
|
qqLevel?: QQLevel;//临时添加
|
||||||
uid?: string;
|
uid?: string;
|
||||||
uin?: string;
|
uin?: string;
|
||||||
coreInfo: CoreInfo;
|
coreInfo: CoreInfo;
|
||||||
|
@@ -15,7 +15,21 @@ export default class GetFriendList extends OneBotAction<Payload, OB11User[]> {
|
|||||||
override payloadSchema = SchemaData;
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(_payload: Payload) {
|
async _handle(_payload: Payload) {
|
||||||
//全新逻辑
|
const buddyMap = await this.core.apis.FriendApi.getBuddyV2SimpleInfoMap();
|
||||||
return OB11Construct.friends(await this.core.apis.FriendApi.getBuddy());
|
|
||||||
|
await Promise.all(
|
||||||
|
Array.from(buddyMap.values()).map(async (buddyInfo) => {
|
||||||
|
try {
|
||||||
|
const userDetail = await this.core.apis.UserApi.getUserDetailInfo(buddyInfo.coreInfo.uid);
|
||||||
|
const data = buddyMap.get(buddyInfo.coreInfo.uid);
|
||||||
|
if (data) {
|
||||||
|
data.qqLevel = userDetail.qqLevel;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
this.core.context.logger.logError('获取好友详细信息失败', error);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
return OB11Construct.friends(Array.from(buddyMap.values()));
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -31,10 +31,25 @@ export class OB11Construct {
|
|||||||
nickname: rawFriend.coreInfo.nick ?? '',
|
nickname: rawFriend.coreInfo.nick ?? '',
|
||||||
remark: rawFriend.coreInfo.remark ?? rawFriend.coreInfo.nick,
|
remark: rawFriend.coreInfo.remark ?? rawFriend.coreInfo.nick,
|
||||||
sex: this.sex(rawFriend.baseInfo.sex),
|
sex: this.sex(rawFriend.baseInfo.sex),
|
||||||
level: 0,
|
level: rawFriend.qqLevel && calcQQLevel(rawFriend.qqLevel) || 0,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
static friend(friends: FriendV2): OB11User {
|
||||||
|
return {
|
||||||
|
birthday_year: friends.baseInfo.birthday_year,
|
||||||
|
birthday_month: friends.baseInfo.birthday_month,
|
||||||
|
birthday_day: friends.baseInfo.birthday_day,
|
||||||
|
user_id: parseInt(friends.coreInfo.uin),
|
||||||
|
age: friends.baseInfo.age,
|
||||||
|
phone_num: friends.baseInfo.phoneNum,
|
||||||
|
email: friends.baseInfo.eMail,
|
||||||
|
category_id: friends.baseInfo.categoryId,
|
||||||
|
nickname: friends.coreInfo.nick ?? '',
|
||||||
|
remark: friends.coreInfo.remark ?? friends.coreInfo.nick,
|
||||||
|
sex: this.sex(friends.baseInfo.sex),
|
||||||
|
level: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
static groupMemberRole(role: number): OB11GroupMemberRole | undefined {
|
static groupMemberRole(role: number): OB11GroupMemberRole | undefined {
|
||||||
return {
|
return {
|
||||||
4: OB11GroupMemberRole.owner,
|
4: OB11GroupMemberRole.owner,
|
||||||
|
@@ -1,4 +1,10 @@
|
|||||||
export interface OB11User {
|
export interface OB11User {
|
||||||
|
birthday_year?: number; // 生日
|
||||||
|
birthday_month?: number; // 生日
|
||||||
|
birthday_day?: number; // 生日
|
||||||
|
phone_num?: string; // 手机号
|
||||||
|
email?: string; // 邮箱
|
||||||
|
category_id?: number; // 分组ID
|
||||||
user_id: number; // 用户ID
|
user_id: number; // 用户ID
|
||||||
nickname: string; // 昵称
|
nickname: string; // 昵称
|
||||||
remark?: string; // 备注
|
remark?: string; // 备注
|
||||||
|
Reference in New Issue
Block a user