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 const uidMaps: Record<string, string> = {} // 一串加密的字符串(uid) -> qq号
export function getUidByUin(uin: string) { export function getUidByUin(uin: string) {
for (const key in uidMaps) { for (const uid in uidMaps) {
if (uidMaps[key] === uin) { if (uidMaps[uid] === uin) {
return key return uid
} }
} }
} }

View File

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

View File

@@ -3,7 +3,9 @@ import {SelfInfo, User} from "../types";
import {ReceiveCmdS} from "../hook"; import {ReceiveCmdS} from "../hook";
import {uidMaps} from "../../common/data"; import {uidMaps} from "../../common/data";
import {NTQQWindowApi, NTQQWindows} from "./window"; import {NTQQWindowApi, NTQQWindows} from "./window";
import {isQQ998, sleep} from "../../common/utils";
let userInfoCache: Record<string, User> = {}; // uid: User
export class NTQQUserApi{ export class NTQQUserApi{
static async setQQAvatar(filePath: string) { static async setQQAvatar(filePath: string) {
@@ -31,8 +33,11 @@ export class NTQQUserApi{
return result.profiles.get(uid) return result.profiles.get(uid)
} }
static async getUserDetailInfo(uid: string) { static async getUserDetailInfo(uid: string) {
// 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 }>({ const result = await callNTQQApi<{ info: User }>({
methodName: NTQQApiMethod.USER_DETAIL_INFO, methodName,
cbCmd: ReceiveCmdS.USER_DETAIL_INFO, cbCmd: ReceiveCmdS.USER_DETAIL_INFO,
afterFirstCmd: false, afterFirstCmd: false,
cmdCB: (payload) => { cmdCB: (payload) => {
@@ -53,6 +58,15 @@ export class NTQQUserApi{
} }
return info return info
} }
// 首次请求两次才能拿到的等级信息
if (!userInfoCache[uid]) {
await fetchInfo()
}
await sleep(1000);
let userInfo = await fetchInfo()
userInfoCache[uid] = userInfo
return userInfo
}
static async getPSkey() { static async getPSkey() {
return await callNTQQApi<string>({ return await callNTQQApi<string>({

View File

@@ -35,6 +35,7 @@ export enum NTQQApiMethod {
GROUP_MEMBERS = "nodeIKernelGroupService/getNextMemberList", GROUP_MEMBERS = "nodeIKernelGroupService/getNextMemberList",
USER_INFO = "nodeIKernelProfileService/getUserSimpleInfo", USER_INFO = "nodeIKernelProfileService/getUserSimpleInfo",
USER_DETAIL_INFO = "nodeIKernelProfileService/getUserDetailInfo", USER_DETAIL_INFO = "nodeIKernelProfileService/getUserDetailInfo",
USER_DETAIL_INFO_WITH_BIZ_INFO = "nodeIKernelProfileService/getUserDetailInfoWithBizInfo",
FILE_TYPE = "getFileType", FILE_TYPE = "getFileType",
FILE_MD5 = "getFileMd5", FILE_MD5 = "getFileMd5",
FILE_COPY = "copyFile", 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 = "https://gchat.qpic.cn"
export const IMAGE_HTTP_HOST_NEW = "https://multimedia.nt.qq.com.cn"
export interface PicElement { 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; // 图片本地路径 sourcePath: string; // 图片本地路径
thumbPath: Map<number, string>; thumbPath: Map<number, string>;
picWidth: number; picWidth: number;

View File

@@ -14,7 +14,7 @@ import {
GrayTipElementSubType, GrayTipElementSubType,
Group, Group,
GroupMember, GroupMember,
IMAGE_HTTP_HOST, IMAGE_HTTP_HOST, IMAGE_HTTP_HOST_NEW,
RawMessage, RawMessage,
SelfInfo, SelfInfo,
Sex, Sex,
@@ -139,11 +139,19 @@ export class OB11Constructor {
message_data["data"]["file"] = element.picElement.fileName message_data["data"]["file"] = element.picElement.fileName
// message_data["data"]["path"] = element.picElement.sourcePath // message_data["data"]["path"] = element.picElement.sourcePath
const url = element.picElement.originImageUrl const url = element.picElement.originImageUrl
const fileMd5 = element.picElement.md5HexStr const md5HexStr = element.picElement.md5HexStr
const originalMd5 = element.picElement.originImageMd5
if (url) { if (url) {
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 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 (!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_id"] = element.picElement.fileUuid
message_data["data"]["file_size"] = element.picElement.fileSize message_data["data"]["file_size"] = element.picElement.fileSize
@@ -414,6 +422,7 @@ export class OB11Constructor {
} }
static stranger(user: User): OB11User { static stranger(user: User): OB11User {
log("construct ob11 stranger", user)
return { return {
...user, ...user,
user_id: parseInt(user.uin), user_id: parseInt(user.uin),