fix: user info level

This commit is contained in:
linyuchen
2024-03-28 23:35:52 +08:00
parent 4591c1b659
commit 0116f8d384
6 changed files with 56 additions and 38 deletions

View File

@@ -94,9 +94,9 @@ export async function refreshGroupMembers(groupQQ: string) {
export const uidMaps: Record<string, string> = {} // 一串加密的字符串(uid) -> qq号
export function getUidByUin(uin: string) {
for (const key in uidMaps) {
if (uidMaps[key] === uin) {
return key
for (const uid in uidMaps) {
if (uidMaps[uid] === uin) {
return uid
}
}
}

View File

@@ -18,7 +18,7 @@ import {
friendRequests,
getFriend,
getGroup,
getGroupMember,
getGroupMember, groups,
llonebotError,
refreshGroupMembers,
selfInfo,
@@ -54,7 +54,6 @@ import {log} from "../common/utils/log";
import {getConfigUtil} from "../common/config";
import {checkFfmpeg} from "../common/utils/video";
let running = false;
let mainWindow: BrowserWindow | null = null;
@@ -63,7 +62,6 @@ let mainWindow: BrowserWindow | null = null;
function onLoad() {
log("llonebot main onLoad");
ipcMain.handle(CHANNEL_CHECK_VERSION, async (event, arg) => {
return checkNewVersion();
});
ipcMain.handle(CHANNEL_UPDATE, async (event, arg) => {
@@ -373,13 +371,7 @@ function onLoad() {
}
})
startReceiveHook().then();
// NTQQGroupApi.getGroups(true).then(_groups => {
// _groups.map(group => {
// if (!groups.find(g => g.groupCode == group.groupCode)) {
// groups.push(group)
// }
// })
// })
NTQQGroupApi.getGroups(true).then()
const config = getConfigUtil().getConfig()
if (config.ob11.enableHttp) {
ob11HTTPServer.start(config.ob11.httpPort)

View File

@@ -3,7 +3,9 @@ import {SelfInfo, User} from "../types";
import {ReceiveCmdS} from "../hook";
import {uidMaps} from "../../common/data";
import {NTQQWindowApi, NTQQWindows} from "./window";
import {isQQ998, sleep} from "../../common/utils";
let userInfoCache: Record<string, User> = {}; // uid: User
export class NTQQUserApi{
static async setQQAvatar(filePath: string) {
@@ -31,27 +33,39 @@ export class NTQQUserApi{
return result.profiles.get(uid)
}
static async getUserDetailInfo(uid: string) {
const result = await callNTQQApi<{ info: User }>({
methodName: NTQQApiMethod.USER_DETAIL_INFO,
cbCmd: ReceiveCmdS.USER_DETAIL_INFO,
afterFirstCmd: false,
cmdCB: (payload) => {
const success = payload.info.uid == uid
// log("get user detail info", success, uid, payload)
return success
},
args: [
{
uid
// this.getUserInfo(uid);
let methodName = !isQQ998 ? NTQQApiMethod.USER_DETAIL_INFO : NTQQApiMethod.USER_DETAIL_INFO_WITH_BIZ_INFO
const fetchInfo = async ()=>{
const result = await callNTQQApi<{ info: User }>({
methodName,
cbCmd: ReceiveCmdS.USER_DETAIL_INFO,
afterFirstCmd: false,
cmdCB: (payload) => {
const success = payload.info.uid == uid
// log("get user detail info", success, uid, payload)
return success
},
null
]
})
const info = result.info
if (info?.uin) {
uidMaps[info.uid] = info.uin
args: [
{
uid
},
null
]
})
const info = result.info
if (info?.uin) {
uidMaps[info.uid] = info.uin
}
return info
}
return info
// 首次请求两次才能拿到的等级信息
if (!userInfoCache[uid]) {
await fetchInfo()
}
await sleep(1000);
let userInfo = await fetchInfo()
userInfoCache[uid] = userInfo
return userInfo
}
static async getPSkey() {

View File

@@ -35,6 +35,7 @@ export enum NTQQApiMethod {
GROUP_MEMBERS = "nodeIKernelGroupService/getNextMemberList",
USER_INFO = "nodeIKernelProfileService/getUserSimpleInfo",
USER_DETAIL_INFO = "nodeIKernelProfileService/getUserDetailInfo",
USER_DETAIL_INFO_WITH_BIZ_INFO = "nodeIKernelProfileService/getUserDetailInfoWithBizInfo",
FILE_TYPE = "getFileType",
FILE_MD5 = "getFileMd5",
FILE_COPY = "copyFile",

View File

@@ -172,9 +172,11 @@ export interface ArkElement {
}
export const IMAGE_HTTP_HOST = "https://gchat.qpic.cn"
export const IMAGE_HTTP_HOST_NEW = "https://multimedia.nt.qq.com.cn"
export interface PicElement {
originImageUrl: string; // http url, 没有hosthost是https://gchat.qpic.cn/
originImageUrl: string; // http url, 没有hosthost是https://gchat.qpic.cn/, 带download参数的是https://multimedia.nt.qq.com.cn
originImageMd5?: string;
sourcePath: string; // 图片本地路径
thumbPath: Map<number, string>;
picWidth: number;

View File

@@ -14,7 +14,7 @@ import {
GrayTipElementSubType,
Group,
GroupMember,
IMAGE_HTTP_HOST,
IMAGE_HTTP_HOST, IMAGE_HTTP_HOST_NEW,
RawMessage,
SelfInfo,
Sex,
@@ -139,11 +139,19 @@ export class OB11Constructor {
message_data["data"]["file"] = element.picElement.fileName
// message_data["data"]["path"] = element.picElement.sourcePath
const url = element.picElement.originImageUrl
const fileMd5 = element.picElement.md5HexStr
const md5HexStr = element.picElement.md5HexStr
const originalMd5 = element.picElement.originImageMd5
if (url) {
message_data["data"]["url"] = IMAGE_HTTP_HOST + url
} else if (fileMd5 && element.picElement.fileUuid.indexOf("_") === -1) { // fileuuid有下划线的是Linux发送的这个url是另外的格式目前尚未得知如何组装
message_data["data"]["url"] = `${IMAGE_HTTP_HOST}/gchatpic_new/0/0-0-${fileMd5.toUpperCase()}/0`
if (url.startsWith("/download") && url.includes("&rkey")){
message_data["data"]["url"] = IMAGE_HTTP_HOST_NEW + url
}
else if (!url.startsWith("/download")){
message_data["data"]["url"] = IMAGE_HTTP_HOST + url
}
}
if (!message_data["data"]["url"]){
message_data["data"]["url"] = `${IMAGE_HTTP_HOST}/gchatpic_new/0/0-0-${md5HexStr.toUpperCase()}/0`
}
// message_data["data"]["file_id"] = element.picElement.fileUuid
message_data["data"]["file_size"] = element.picElement.fileSize
@@ -414,6 +422,7 @@ export class OB11Constructor {
}
static stranger(user: User): OB11User {
log("construct ob11 stranger", user)
return {
...user,
user_id: parseInt(user.uin),