diff --git a/src/common/utils/QQBasicInfo.ts b/src/common/utils/QQBasicInfo.ts index 4ad075ea..2ee6205a 100644 --- a/src/common/utils/QQBasicInfo.ts +++ b/src/common/utils/QQBasicInfo.ts @@ -6,15 +6,15 @@ import AppidTable from '@/core/external/appid.json'; import { log } from './log'; //基础目录获取 -export let QQMainPath = process.execPath; -export let QQPackageInfoPath: string = path.join(path.dirname(QQMainPath), 'resources', 'app', 'package.json'); -export let QQVersionConfigPath: string | undefined = getQQVersionConfigPath(QQMainPath); +export const QQMainPath = process.execPath; +export const QQPackageInfoPath: string = path.join(path.dirname(QQMainPath), 'resources', 'app', 'package.json'); +export const QQVersionConfigPath: string | undefined = getQQVersionConfigPath(QQMainPath); //基础信息获取 无快更则启用默认模板填充 -export let isQuickUpdate: boolean = !!QQVersionConfigPath; -export let QQVersionConfig: QQVersionConfigType = isQuickUpdate ? JSON.parse(fs.readFileSync(QQVersionConfigPath!).toString()) : getDefaultQQVersionConfigInfo(); -export let QQPackageInfo: QQPackageInfoType = JSON.parse(fs.readFileSync(QQPackageInfoPath).toString()); -export let { appid: QQVersionAppid, qua: QQVersionQua } = getAppidV2(); +export const isQuickUpdate: boolean = !!QQVersionConfigPath; +export const QQVersionConfig: QQVersionConfigType = isQuickUpdate ? JSON.parse(fs.readFileSync(QQVersionConfigPath!).toString()) : getDefaultQQVersionConfigInfo(); +export const QQPackageInfo: QQPackageInfoType = JSON.parse(fs.readFileSync(QQPackageInfoPath).toString()); +export const { appid: QQVersionAppid, qua: QQVersionQua } = getAppidV2(); //基础函数 export function getQQBuildStr() { @@ -31,9 +31,9 @@ export function getQUAInternal() { return systemPlatform === 'linux' ? `V1_LNX_NQ_${getFullQQVesion()}_${getQQBuildStr()}_GW_B` : `V1_WIN_NQ_${getFullQQVesion()}_${getQQBuildStr()}_GW_B`; } export function getAppidV2(): { appid: string, qua: string } { - let appidTbale = AppidTable as unknown as QQAppidTableType; + const appidTbale = AppidTable as unknown as QQAppidTableType; try { - let data = appidTbale[getFullQQVesion()]; + const data = appidTbale[getFullQQVesion()]; if (data) { return data; } diff --git a/src/common/utils/file.ts b/src/common/utils/file.ts index b27f7335..fd6a4f37 100644 --- a/src/common/utils/file.ts +++ b/src/common/utils/file.ts @@ -195,7 +195,7 @@ export async function uri2local(UriOrPath: string, fileName: string | null = nul let url = null; //区分path和uri try { - if (fs.existsSync(UriOrPath)) url = new URL("file://" + UriOrPath); + if (fs.existsSync(UriOrPath)) url = new URL('file://' + UriOrPath); } catch (error: any) { } try { url = new URL(UriOrPath); diff --git a/src/common/utils/helper.ts b/src/common/utils/helper.ts index 625c3940..f311d7a2 100644 --- a/src/common/utils/helper.ts +++ b/src/common/utils/helper.ts @@ -360,12 +360,12 @@ export async function promisePipeline(promises: Promise[], callback: (resul callbackCalled = callback(result); } } catch (error) { - console.error("Error in promise pipeline:", error); + console.error('Error in promise pipeline:', error); } } } -export function getQQVersionConfigPath(exePath: string = ""): string | undefined { +export function getQQVersionConfigPath(exePath: string = ''): string | undefined { let configVersionInfoPath; if (os.platform() !== 'linux') { configVersionInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'versions', 'config.json'); diff --git a/src/core/src/external/appid.json b/src/core/src/external/appid.json index 29223226..44fd31c7 100644 --- a/src/core/src/external/appid.json +++ b/src/core/src/external/appid.json @@ -11,6 +11,10 @@ "appid": 537237950, "qua": "V1_LNX_NQ_3.2.12_26702_GW_B" }, + "3.2.12-26740": { + "appid": 537237950, + "qua": "V1_WIN_NQ_9.9.15_26740_GW_B" + }, "9.9.11-24815": { "appid": 537226656, "qua": "V1_WIN_NQ_9.9.11_24815_GW_B" @@ -38,5 +42,9 @@ "9.9.15-26702": { "appid": 537237765, "qua": "V1_WIN_NQ_9.9.15_26702_GW_B" + }, + "9.9.15-26740": { + "appid": 537237765, + "qua": "V1_WIN_NQ_9.9.15_26702_GW_B" } } \ No newline at end of file diff --git a/src/onebot11/action/extends/FetchEmojioLike.ts b/src/onebot11/action/extends/FetchEmojioLike.ts index 2ea70ad4..baf43dc4 100644 --- a/src/onebot11/action/extends/FetchEmojioLike.ts +++ b/src/onebot11/action/extends/FetchEmojioLike.ts @@ -5,28 +5,28 @@ import { ActionName } from '../types'; import { NTQQMsgApi } from '@/core/apis'; import { MessageUnique } from '@/common/utils/MessageUnique'; const SchemaData = { - type: 'object', - properties: { - user_id: { type: 'string' }, - group_id: { type: 'string' }, - emojiId: { type: 'string' }, - emojiType: { type: 'string' }, - message_id: { type: ['string', 'number'] }, - count: { type: 'number' } - }, - required: ['emojiId', 'emojiType', 'message_id'] + type: 'object', + properties: { + user_id: { type: 'string' }, + group_id: { type: 'string' }, + emojiId: { type: 'string' }, + emojiType: { type: 'string' }, + message_id: { type: ['string', 'number'] }, + count: { type: 'number' } + }, + required: ['emojiId', 'emojiType', 'message_id'] } as const satisfies JSONSchema; type Payload = FromSchema; export class FetchEmojioLike extends BaseAction { - actionName = ActionName.FetchEmojioLike; - PayloadSchema = SchemaData; - protected async _handle(payload: Payload) { - let msgIdPeer = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString())); - if(!msgIdPeer) throw new Error('消息不存在'); - let msg = (await NTQQMsgApi.getMsgsByMsgId(msgIdPeer.Peer, [msgIdPeer.MsgId])).msgList[0]; - const ret = await NTQQMsgApi.getMsgEmojiLikesList(msgIdPeer.Peer,msg.msgSeq,payload.emojiId,payload.emojiType,payload.count); - return ret; - } + actionName = ActionName.FetchEmojioLike; + PayloadSchema = SchemaData; + protected async _handle(payload: Payload) { + const msgIdPeer = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString())); + if(!msgIdPeer) throw new Error('消息不存在'); + const msg = (await NTQQMsgApi.getMsgsByMsgId(msgIdPeer.Peer, [msgIdPeer.MsgId])).msgList[0]; + const ret = await NTQQMsgApi.getMsgEmojiLikesList(msgIdPeer.Peer,msg.msgSeq,payload.emojiId,payload.emojiType,payload.count); + return ret; + } } diff --git a/src/onebot11/action/group/GetGroupList.ts b/src/onebot11/action/group/GetGroupList.ts index b28d67b7..396649ff 100644 --- a/src/onebot11/action/group/GetGroupList.ts +++ b/src/onebot11/action/group/GetGroupList.ts @@ -19,7 +19,7 @@ class GetGroupList extends BaseAction { actionName = ActionName.GetGroupList; PayloadSchema = SchemaData; protected async _handle(payload: Payload) { - let groupList: Group[] = await NTQQGroupApi.getGroups(payload?.no_cache === true || payload.no_cache === 'true'); + const groupList: Group[] = await NTQQGroupApi.getGroups(payload?.no_cache === true || payload.no_cache === 'true'); return OB11Constructor.groups(groupList); } } diff --git a/src/onebot11/action/group/GetGroupMemberInfo.ts b/src/onebot11/action/group/GetGroupMemberInfo.ts index c6d4c7a0..06b2c3f0 100644 --- a/src/onebot11/action/group/GetGroupMemberInfo.ts +++ b/src/onebot11/action/group/GetGroupMemberInfo.ts @@ -26,11 +26,11 @@ class GetGroupMemberInfo extends BaseAction { PayloadSchema = SchemaData; protected async _handle(payload: Payload) { const isNocache = payload.no_cache == true || payload.no_cache === 'true'; - let uid = await NTQQUserApi.getUidByUin(payload.user_id.toString()); + const uid = await NTQQUserApi.getUidByUin(payload.user_id.toString()); if (!uid) { throw (`Uin2Uid Error ${payload.user_id}不存在`); } - let member = await NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), uid, isNocache); + const member = await NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), uid, isNocache); if (!member) { throw (`群(${payload.group_id})成员${payload.user_id}不存在`); } @@ -44,7 +44,7 @@ class GetGroupMemberInfo extends BaseAction { const date = Math.round(Date.now() / 1000); const retMember = OB11Constructor.groupMember(payload.group_id.toString(), member); if (!requireMinNTQQBuild('26702')) { - let SelfInfoInGroup = await NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), selfInfo.uid, isNocache); + const SelfInfoInGroup = await NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), selfInfo.uid, isNocache); let isPrivilege = false; if (SelfInfoInGroup) { isPrivilege = SelfInfoInGroup.role === 3 || SelfInfoInGroup.role === 4; diff --git a/src/onebot11/action/group/GetGroupMemberInfoOld.ts b/src/onebot11/action/group/GetGroupMemberInfoOld.ts index d0afe615..7d9708ce 100644 --- a/src/onebot11/action/group/GetGroupMemberInfoOld.ts +++ b/src/onebot11/action/group/GetGroupMemberInfoOld.ts @@ -28,7 +28,7 @@ class GetGroupMemberInfo extends BaseAction { PayloadSchema = SchemaData; protected async _handle(payload: Payload) { if (requireMinNTQQBuild('26702')) { - let V2Data = await NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), payload.user_id.toString(), payload.no_cache == true || payload.no_cache === 'true'); + const V2Data = await NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), payload.user_id.toString(), payload.no_cache == true || payload.no_cache === 'true'); if (V2Data) { return OB11Constructor.groupMember(payload.group_id.toString(), V2Data); } else { diff --git a/src/onebot11/action/group/GetGroupMemberList.ts b/src/onebot11/action/group/GetGroupMemberList.ts index a28c0a22..ba1d6e4a 100644 --- a/src/onebot11/action/group/GetGroupMemberList.ts +++ b/src/onebot11/action/group/GetGroupMemberList.ts @@ -30,7 +30,7 @@ class GetGroupMemberList extends BaseAction { if (!group) { throw (`群${payload.group_id}不存在`); } - let groupMembers = await NTQQGroupApi.getGroupMembers(payload.group_id.toString()); + const groupMembers = await NTQQGroupApi.getGroupMembers(payload.group_id.toString()); let _groupMembers = Array.from(groupMembers.values()) .map(item => { return OB11Constructor.groupMember(group.groupCode, item); }); diff --git a/src/onebot11/action/types.ts b/src/onebot11/action/types.ts index 9fccaade..7925a944 100644 --- a/src/onebot11/action/types.ts +++ b/src/onebot11/action/types.ts @@ -103,5 +103,5 @@ export enum ActionName { FetchCustomFace = 'fetch_custom_face', GOCQHTTP_UploadPrivateFile = 'upload_private_file', TestApi01 = 'test_api_01', - FetchEmojioLike = "fetch_emoji_like" + FetchEmojioLike = 'fetch_emoji_like' } diff --git a/src/onebot11/action/user/GetRecentContact.ts b/src/onebot11/action/user/GetRecentContact.ts index 363c749d..9132d244 100644 --- a/src/onebot11/action/user/GetRecentContact.ts +++ b/src/onebot11/action/user/GetRecentContact.ts @@ -18,12 +18,12 @@ export default class GetRecentContact extends BaseAction { actionName = ActionName.GetRecentContact; PayloadSchema = SchemaData; protected async _handle(payload: Payload) { - let ret = await NTQQUserApi.getRecentContactListSnapShot(parseInt((payload.count || 10).toString())); - let data = await Promise.all(ret.info.changedList.map(async (t) => { - let FastMsg = await NTQQMsgApi.getMsgsByMsgId({ chatType: t.chatType, peerUid: t.peerUid }, [t.msgId]); + const ret = await NTQQUserApi.getRecentContactListSnapShot(parseInt((payload.count || 10).toString())); + const data = await Promise.all(ret.info.changedList.map(async (t) => { + const FastMsg = await NTQQMsgApi.getMsgsByMsgId({ chatType: t.chatType, peerUid: t.peerUid }, [t.msgId]); if (FastMsg.msgList.length > 0) { //扩展ret.info.changedList - let lastestMsg = await OB11Constructor.message(FastMsg.msgList[0]); + const lastestMsg = await OB11Constructor.message(FastMsg.msgList[0]); return { lastestMsg: lastestMsg, peerUin: t.peerUin, diff --git a/src/onebot11/constructor.ts b/src/onebot11/constructor.ts index 10aa1201..17f6f4d3 100644 --- a/src/onebot11/constructor.ts +++ b/src/onebot11/constructor.ts @@ -208,13 +208,13 @@ export class OB11Constructor { chatType: msg.chatType, guildId: '', }, - msg.msgId, - msg.msgSeq, - msg.senderUid, - element.elementId, - element.elementType.toString(), - FileElement.fileSize, - FileElement.fileName + msg.msgId, + msg.msgSeq, + msg.senderUid, + element.elementId, + element.elementType.toString(), + FileElement.fileSize, + FileElement.fileName ); } else if (element.videoElement) { @@ -255,13 +255,13 @@ export class OB11Constructor { chatType: msg.chatType, guildId: '', }, - msg.msgId, - msg.msgSeq, - msg.senderUid, - element.elementId, - element.elementType.toString(), - videoElement.fileSize || '0', - videoElement.fileName + msg.msgId, + msg.msgSeq, + msg.senderUid, + element.elementId, + element.elementType.toString(), + videoElement.fileSize || '0', + videoElement.fileName ); } else if (element.pttElement) { @@ -276,13 +276,13 @@ export class OB11Constructor { chatType: msg.chatType, guildId: '', }, - msg.msgId, - msg.msgSeq, - msg.senderUid, - element.elementId, - element.elementType.toString(), - element.pttElement.fileSize || '0', - element.pttElement.fileUuid || '' + msg.msgId, + msg.msgSeq, + msg.senderUid, + element.elementId, + element.elementType.toString(), + element.pttElement.fileSize || '0', + element.pttElement.fileUuid || '' ); //以uuid作为文件名 } diff --git a/src/onebot11/server/http.ts b/src/onebot11/server/http.ts index f5c06c5c..095be65d 100644 --- a/src/onebot11/server/http.ts +++ b/src/onebot11/server/http.ts @@ -11,7 +11,7 @@ class OB11HTTPServer extends HttpServerBase { name = 'OneBot V11 server'; handleFailed(res: Response, payload: any, e: Error) { - res.send(OB11Response.error(e?.stack?.toString() || e.message || "Error Handle", 200)); + res.send(OB11Response.error(e?.stack?.toString() || e.message || 'Error Handle', 200)); } protected listen(port: number, host: string) {