mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
fix: get_stranger_info
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { ModifyProfileParams, SelfInfo, User, UserDetailInfoByUin } from '@/core/entities';
|
import { ModifyProfileParams, SelfInfo, User, UserDetailInfoByUin, UserDetailInfoByUinV2 } from '@/core/entities';
|
||||||
import { friends, groupMembers, selfInfo } from '@/core/data';
|
import { friends, groupMembers, selfInfo } from '@/core/data';
|
||||||
import { CacheClassFuncAsync, CacheClassFuncAsyncExtend } from '@/common/utils/helper';
|
import { CacheClassFuncAsync, CacheClassFuncAsyncExtend } from '@/common/utils/helper';
|
||||||
import { napCatCore, NTQQFriendApi } from '@/core';
|
import { napCatCore, NTQQFriendApi } from '@/core';
|
||||||
@@ -211,7 +211,7 @@ export class NTQQUserApi {
|
|||||||
})
|
})
|
||||||
static async getUidByUin(Uin: string) {
|
static async getUidByUin(Uin: string) {
|
||||||
//此代码仅临时使用,后期会被废弃
|
//此代码仅临时使用,后期会被废弃
|
||||||
if (!requireMinNTQQBuild('26702')) {
|
if (requireMinNTQQBuild('26702')) {
|
||||||
return await NTQQUserApi.getUidByUinV2(Uin);
|
return await NTQQUserApi.getUidByUinV2(Uin);
|
||||||
}
|
}
|
||||||
return await NTQQUserApi.getUidByUinV1(Uin);
|
return await NTQQUserApi.getUidByUinV1(Uin);
|
||||||
@@ -225,7 +225,7 @@ export class NTQQUserApi {
|
|||||||
})
|
})
|
||||||
static async getUinByUid(Uid: string) {
|
static async getUinByUid(Uid: string) {
|
||||||
//此代码仅临时使用,后期会被废弃
|
//此代码仅临时使用,后期会被废弃
|
||||||
if (!requireMinNTQQBuild('26702')) {
|
if (requireMinNTQQBuild('26702')) {
|
||||||
return await NTQQUserApi.getUinByUidV2(Uid);
|
return await NTQQUserApi.getUinByUidV2(Uid);
|
||||||
}
|
}
|
||||||
return await NTQQUserApi.getUinByUidV1(Uid);
|
return await NTQQUserApi.getUinByUidV1(Uid);
|
||||||
@@ -243,10 +243,11 @@ export class NTQQUserApi {
|
|||||||
if (uid) return uid;
|
if (uid) return uid;
|
||||||
uid = (await NTQQFriendApi.getBuddyIdMap(true)).getValue(Uin);
|
uid = (await NTQQFriendApi.getBuddyIdMap(true)).getValue(Uin);
|
||||||
if (uid) return uid;
|
if (uid) return uid;
|
||||||
let unveifyUid = (await NTQQUserApi.getUserDetailInfoByUin(Uin)).info.uid;//从QQ Native 特殊转换
|
// let unveifyUid = (await NTQQUserApi.getUserDetailInfoByUin(Uin)).info.uid;//从QQ Native 特殊转换
|
||||||
if (unveifyUid.indexOf("*") == -1) uid = unveifyUid;
|
// if (unveifyUid.indexOf("*") == -1) uid = unveifyUid;
|
||||||
|
|
||||||
if (uid) return uid; return uid;
|
//if (uid) return uid;
|
||||||
|
return uid;
|
||||||
}
|
}
|
||||||
//后期改成流水线处理
|
//后期改成流水线处理
|
||||||
static async getUinByUidV2(Uid: string) {
|
static async getUinByUidV2(Uid: string) {
|
||||||
@@ -333,6 +334,14 @@ export class NTQQUserApi {
|
|||||||
static async getRecentContactList() {
|
static async getRecentContactList() {
|
||||||
return await napCatCore.session.getRecentContactService().getRecentContactList();
|
return await napCatCore.session.getRecentContactService().getRecentContactList();
|
||||||
}
|
}
|
||||||
|
static async getUserDetailInfoByUinV2(Uin: string) {
|
||||||
|
return await NTEventDispatch.CallNoListenerEvent
|
||||||
|
<(Uin: string) => Promise<UserDetailInfoByUinV2>>(
|
||||||
|
'NodeIKernelProfileService/getUserDetailInfoByUin',
|
||||||
|
5000,
|
||||||
|
Uin
|
||||||
|
);
|
||||||
|
}
|
||||||
static async getUserDetailInfoByUin(Uin: string) {
|
static async getUserDetailInfoByUin(Uin: string) {
|
||||||
return NTEventDispatch.CallNoListenerEvent
|
return NTEventDispatch.CallNoListenerEvent
|
||||||
<(Uin: string) => Promise<UserDetailInfoByUin>>(
|
<(Uin: string) => Promise<UserDetailInfoByUin>>(
|
||||||
|
@@ -276,6 +276,17 @@ export enum BizKey {
|
|||||||
KPRIVILEGEICON,
|
KPRIVILEGEICON,
|
||||||
KPHOTOWALL
|
KPHOTOWALL
|
||||||
}
|
}
|
||||||
|
export interface UserDetailInfoByUinV2 {
|
||||||
|
result: number,
|
||||||
|
errMsg: string,
|
||||||
|
detail: {
|
||||||
|
uid: string,
|
||||||
|
uin: string,
|
||||||
|
simpleInfo: SimpleInfo,
|
||||||
|
commonExt: CommonExt,
|
||||||
|
photoWall: null
|
||||||
|
}
|
||||||
|
}
|
||||||
export interface UserDetailInfoByUin {
|
export interface UserDetailInfoByUin {
|
||||||
result: number,
|
result: number,
|
||||||
errMsg: string,
|
errMsg: string,
|
||||||
|
@@ -5,6 +5,7 @@ import { ActionName } from '../types';
|
|||||||
import { NTQQUserApi } from '@/core/apis/user';
|
import { NTQQUserApi } from '@/core/apis/user';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import { calcQQLevel } from '@/common/utils/qqlevel';
|
import { calcQQLevel } from '@/common/utils/qqlevel';
|
||||||
|
import { requireMinNTQQBuild } from '@/common/utils/QQBasicInfo';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@@ -20,24 +21,46 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11Use
|
|||||||
actionName = ActionName.GoCQHTTP_GetStrangerInfo;
|
actionName = ActionName.GoCQHTTP_GetStrangerInfo;
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<OB11User> {
|
protected async _handle(payload: Payload): Promise<OB11User> {
|
||||||
const user_id = payload.user_id.toString();
|
if (!requireMinNTQQBuild('26702')) {
|
||||||
const extendData = await NTQQUserApi.getUserDetailInfoByUin(user_id);
|
const user_id = payload.user_id.toString();
|
||||||
const uid = (await NTQQUserApi.getUidByUin(user_id))!;
|
const extendData = await NTQQUserApi.getUserDetailInfoByUin(user_id);
|
||||||
if (!uid || uid.indexOf('*') != -1) {
|
const uid = (await NTQQUserApi.getUidByUin(user_id))!;
|
||||||
const ret = {
|
if (!uid || uid.indexOf('*') != -1) {
|
||||||
...extendData,
|
const ret = {
|
||||||
user_id: parseInt(extendData.info.uin) || 0,
|
...extendData,
|
||||||
nickname: extendData.info.nick,
|
user_id: parseInt(extendData.info.uin) || 0,
|
||||||
sex: OB11UserSex.unknown,
|
nickname: extendData.info.nick,
|
||||||
age: (extendData.info.birthday_year == 0) ? 0 : new Date().getFullYear() - extendData.info.birthday_year,
|
sex: OB11UserSex.unknown,
|
||||||
qid: extendData.info.qid,
|
age: (extendData.info.birthday_year == 0) ? 0 : new Date().getFullYear() - extendData.info.birthday_year,
|
||||||
level: extendData.info.qqLevel && calcQQLevel(extendData.info.qqLevel) || 0,
|
qid: extendData.info.qid,
|
||||||
login_days: 0,
|
level: extendData.info.qqLevel && calcQQLevel(extendData.info.qqLevel) || 0,
|
||||||
uid: ''
|
login_days: 0,
|
||||||
};
|
uid: ''
|
||||||
return ret;
|
};
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
const data = { ...extendData, ...(await NTQQUserApi.getUserDetailInfo(uid)) };
|
||||||
|
return OB11Constructor.stranger(data);
|
||||||
|
} else {
|
||||||
|
const user_id = payload.user_id.toString();
|
||||||
|
const extendData = await NTQQUserApi.getUserDetailInfoByUinV2(user_id);
|
||||||
|
//console.log(extendData);
|
||||||
|
const uid = (await NTQQUserApi.getUidByUin(user_id))!;
|
||||||
|
if (!uid || uid.indexOf('*') != -1) {
|
||||||
|
const ret = {
|
||||||
|
...extendData,
|
||||||
|
user_id: parseInt(extendData.detail.uin) || 0,
|
||||||
|
nickname: extendData.detail.simpleInfo.coreInfo.nick,
|
||||||
|
sex: OB11UserSex.unknown,
|
||||||
|
age: 0,
|
||||||
|
level: extendData.detail.commonExt.qqLevel && calcQQLevel(extendData.detail.commonExt.qqLevel) || 0,
|
||||||
|
login_days: 0,
|
||||||
|
uid: ''
|
||||||
|
};
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
const data = { ...extendData, ...(await NTQQUserApi.getUserDetailInfo(uid)) };
|
||||||
|
return OB11Constructor.stranger(data);
|
||||||
}
|
}
|
||||||
const data = { ...extendData, ...(await NTQQUserApi.getUserDetailInfo(uid)) };
|
|
||||||
return OB11Constructor.stranger(data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -92,8 +92,9 @@ export class OB11Constructor {
|
|||||||
}
|
}
|
||||||
else if (msg.chatType == ChatType.friend) {
|
else if (msg.chatType == ChatType.friend) {
|
||||||
resMsg.sub_type = 'friend';
|
resMsg.sub_type = 'friend';
|
||||||
const user = await NTQQUserApi.getUserDetailInfoByUin(msg.senderUin!);
|
resMsg.sender.nickname = (await NTQQUserApi.getUserDetailInfo(msg.senderUid)).nick;
|
||||||
resMsg.sender.nickname = user.info.nick;
|
//const user = await NTQQUserApi.getUserDetailInfoByUin(msg.senderUin!);
|
||||||
|
//resMsg.sender.nickname = user.info.nick;
|
||||||
}
|
}
|
||||||
else if (msg.chatType == ChatType.temp) {
|
else if (msg.chatType == ChatType.temp) {
|
||||||
resMsg.sub_type = 'group';
|
resMsg.sub_type = 'group';
|
||||||
|
Reference in New Issue
Block a user