From 4591c1b659c9b4301facf8558f32d3dc06a3e1f1 Mon Sep 17 00:00:00 2001 From: linyuchen Date: Wed, 27 Mar 2024 23:17:56 +0800 Subject: [PATCH 1/2] fix: some audio can't play --- manifest.json | 4 ++-- src/version.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index bb001e2..ddaf7d2 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { "manifest_version": 4, "type": "extension", - "name": "LLOneBot v3.20.0", + "name": "LLOneBot v3.20.1", "slug": "LLOneBot", "description": "使你的NTQQ支持OneBot11协议进行QQ机器人开发, 不支持商店在线更新", - "version": "3.20.0", + "version": "3.20.1", "icon": "./icon.jpg", "authors": [ { diff --git a/src/version.ts b/src/version.ts index 60980c1..4b9f790 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const version = "3.20.0" \ No newline at end of file +export const version = "3.20.1" \ No newline at end of file From 0116f8d38475bcc63aa318eb8136f2e0b0089077 Mon Sep 17 00:00:00 2001 From: linyuchen Date: Thu, 28 Mar 2024 23:35:52 +0800 Subject: [PATCH 2/2] fix: user info level --- src/common/data.ts | 6 ++--- src/main/main.ts | 12 ++------- src/ntqqapi/api/user.ts | 52 +++++++++++++++++++++++-------------- src/ntqqapi/ntcall.ts | 1 + src/ntqqapi/types/msg.ts | 4 ++- src/onebot11/constructor.ts | 19 ++++++++++---- 6 files changed, 56 insertions(+), 38 deletions(-) diff --git a/src/common/data.ts b/src/common/data.ts index b006762..0f52f60 100644 --- a/src/common/data.ts +++ b/src/common/data.ts @@ -94,9 +94,9 @@ export async function refreshGroupMembers(groupQQ: string) { export const uidMaps: Record = {} // 一串加密的字符串(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 } } } diff --git a/src/main/main.ts b/src/main/main.ts index 869d95a..c40061c 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -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) diff --git a/src/ntqqapi/api/user.ts b/src/ntqqapi/api/user.ts index d484a2c..123d0cc 100644 --- a/src/ntqqapi/api/user.ts +++ b/src/ntqqapi/api/user.ts @@ -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 = {}; // 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() { diff --git a/src/ntqqapi/ntcall.ts b/src/ntqqapi/ntcall.ts index f4d9895..623eea7 100644 --- a/src/ntqqapi/ntcall.ts +++ b/src/ntqqapi/ntcall.ts @@ -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", diff --git a/src/ntqqapi/types/msg.ts b/src/ntqqapi/types/msg.ts index 9529a92..a6edc14 100644 --- a/src/ntqqapi/types/msg.ts +++ b/src/ntqqapi/types/msg.ts @@ -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, 没有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; // 图片本地路径 thumbPath: Map; picWidth: number; diff --git a/src/onebot11/constructor.ts b/src/onebot11/constructor.ts index 9a1591e..fec75a6 100644 --- a/src/onebot11/constructor.ts +++ b/src/onebot11/constructor.ts @@ -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),