Merge branch 'main' into dev

# Conflicts:
#	src/onebot11/constructor.ts
This commit is contained in:
linyuchen 2024-03-28 23:37:27 +08:00
commit f30dd81455
8 changed files with 56 additions and 37 deletions

View File

@ -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": [
{

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,
@ -148,6 +148,16 @@ export class OB11Constructor {
}
} 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

View File

@ -1 +1 @@
export const version = "3.20.0"
export const version = "3.20.1"