mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix: user info level
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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)
|
||||||
|
@@ -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,27 +33,39 @@ export class NTQQUserApi{
|
|||||||
return result.profiles.get(uid)
|
return result.profiles.get(uid)
|
||||||
}
|
}
|
||||||
static async getUserDetailInfo(uid: string) {
|
static async getUserDetailInfo(uid: string) {
|
||||||
const result = await callNTQQApi<{ info: User }>({
|
// this.getUserInfo(uid);
|
||||||
methodName: NTQQApiMethod.USER_DETAIL_INFO,
|
let methodName = !isQQ998 ? NTQQApiMethod.USER_DETAIL_INFO : NTQQApiMethod.USER_DETAIL_INFO_WITH_BIZ_INFO
|
||||||
cbCmd: ReceiveCmdS.USER_DETAIL_INFO,
|
const fetchInfo = async ()=>{
|
||||||
afterFirstCmd: false,
|
const result = await callNTQQApi<{ info: User }>({
|
||||||
cmdCB: (payload) => {
|
methodName,
|
||||||
const success = payload.info.uid == uid
|
cbCmd: ReceiveCmdS.USER_DETAIL_INFO,
|
||||||
// log("get user detail info", success, uid, payload)
|
afterFirstCmd: false,
|
||||||
return success
|
cmdCB: (payload) => {
|
||||||
},
|
const success = payload.info.uid == uid
|
||||||
args: [
|
// log("get user detail info", success, uid, payload)
|
||||||
{
|
return success
|
||||||
uid
|
|
||||||
},
|
},
|
||||||
null
|
args: [
|
||||||
]
|
{
|
||||||
})
|
uid
|
||||||
const info = result.info
|
},
|
||||||
if (info?.uin) {
|
null
|
||||||
uidMaps[info.uid] = info.uin
|
]
|
||||||
|
})
|
||||||
|
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() {
|
static async getPSkey() {
|
||||||
|
@@ -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",
|
||||||
|
@@ -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, 没有host,host是https://gchat.qpic.cn/
|
originImageUrl: string; // http url, 没有host,host是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;
|
||||||
|
@@ -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) {
|
||||||
message_data["data"]["url"] = IMAGE_HTTP_HOST + url
|
if (url.startsWith("/download") && url.includes("&rkey")){
|
||||||
} else if (fileMd5 && element.picElement.fileUuid.indexOf("_") === -1) { // fileuuid有下划线的是Linux发送的,这个url是另外的格式,目前尚未得知如何组装
|
message_data["data"]["url"] = IMAGE_HTTP_HOST_NEW + url
|
||||||
message_data["data"]["url"] = `${IMAGE_HTTP_HOST}/gchatpic_new/0/0-0-${fileMd5.toUpperCase()}/0`
|
}
|
||||||
|
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_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),
|
||||||
|
Reference in New Issue
Block a user