Merge branch 'main' into laana

This commit is contained in:
Wesley F. Young 2024-10-05 18:49:22 +08:00
commit 28f0030653
4 changed files with 32 additions and 51 deletions

View File

@ -53,26 +53,22 @@ export class QQBasicInfoWrapper {
} }
//此方法不要直接使用 //此方法不要直接使用
getQUAInternal() { getQUAFallback() {
switch (systemPlatform) { const platformMapping: Partial<Record<NodeJS.Platform, string>> = {
case 'linux': win32: `V1_WIN_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`,
return `V1_LNX_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`; darwin: `V1_MAC_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`,
case 'darwin': linux: `V1_LNX_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`,
return `V1_MAC_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`; };
default: return platformMapping[systemPlatform] ?? (platformMapping.win32)!;
return `V1_WIN_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`;
}
} }
getAppidInternal() { getAppIdFallback() {
switch (systemPlatform) { const platformMapping: Partial<Record<NodeJS.Platform, string>> = {
case 'linux': win32: '537246092',
return '537246140'; darwin: '537246140',
case 'darwin': linux: '537246140',
return '537246140'; };
default: return platformMapping[systemPlatform] ?? '537246092';
return '537246092';
}
} }
getAppidV2(): { appid: string; qua: string } { getAppidV2(): { appid: string; qua: string } {
@ -88,6 +84,6 @@ export class QQBasicInfoWrapper {
// else // else
this.context.logger.log(`[QQ版本兼容性检测] 获取Appid异常 请检测NapCat/QQNT是否正常`); this.context.logger.log(`[QQ版本兼容性检测] 获取Appid异常 请检测NapCat/QQNT是否正常`);
this.context.logger.log(`[QQ版本兼容性检测] ${fullVersion} 版本兼容性不佳,可能会导致一些功能无法正常使用`,); this.context.logger.log(`[QQ版本兼容性检测] ${fullVersion} 版本兼容性不佳,可能会导致一些功能无法正常使用`,);
return { appid: this.getAppidInternal(), qua: this.getQUAInternal() }; return { appid: this.getAppIdFallback(), qua: this.getQUAFallback() };
} }
} }

View File

@ -20,11 +20,11 @@ import { LogLevel, LogWrapper } from '@/common/log';
import { NodeIKernelLoginService } from '@/core/services'; import { NodeIKernelLoginService } from '@/core/services';
import { QQBasicInfoWrapper } from '@/common/qq-basic-info'; import { QQBasicInfoWrapper } from '@/common/qq-basic-info';
import { NapCatPathWrapper } from '@/common/path'; import { NapCatPathWrapper } from '@/common/path';
import path, { resolve } from 'node:path'; import path from 'node:path';
import fs from 'node:fs'; import fs from 'node:fs';
import { hostname, systemName, systemVersion } from '@/common/system'; import { hostname, systemName, systemVersion } from '@/common/system';
import { NTEventWrapper } from '@/common/event'; import { NTEventWrapper } from '@/common/event';
import { ChatType, DataSource, GroupMember, KickedOffLineInfo, Peer, SelfInfo, SelfStatusInfo } from '@/core/entities'; import { DataSource, GroupMember, KickedOffLineInfo, SelfInfo, SelfStatusInfo } from '@/core/entities';
import { NapCatConfigLoader } from '@/core/helper/config'; import { NapCatConfigLoader } from '@/core/helper/config';
import os from 'node:os'; import os from 'node:os';
import { NodeIKernelGroupListener, NodeIKernelMsgListener, NodeIKernelProfileListener } from '@/core/listeners'; import { NodeIKernelGroupListener, NodeIKernelMsgListener, NodeIKernelProfileListener } from '@/core/listeners';
@ -263,19 +263,12 @@ export async function genSessionConfig(
): Promise<WrapperSessionInitConfig> { ): Promise<WrapperSessionInitConfig> {
const downloadPath = path.join(account_path, 'NapCat', 'temp'); const downloadPath = path.join(account_path, 'NapCat', 'temp');
fs.mkdirSync(downloadPath, { recursive: true }); fs.mkdirSync(downloadPath, { recursive: true });
//os.platform() const platformMapping: Partial<Record<NodeJS.Platform, PlatformType>> = {
let systemPlatform = PlatformType.KWINDOWS; win32: PlatformType.KWINDOWS,
switch (os.platform()) { darwin: PlatformType.KMAC,
case 'win32': linux: PlatformType.KLINUX,
systemPlatform = PlatformType.KWINDOWS; };
break; const systemPlatform = platformMapping[os.platform()] ?? PlatformType.KWINDOWS;
case 'darwin':
systemPlatform = PlatformType.KMAC;
break;
case 'linux':
systemPlatform = PlatformType.KLINUX;
break;
}
return { return {
selfUin, selfUin,
selfUid, selfUid,

View File

@ -139,8 +139,7 @@ export class OneBotGroupApi {
} }
if (element.grayTipElement.jsonGrayTipElement.busiId == 2407) { if (element.grayTipElement.jsonGrayTipElement.busiId == 2407) {
const type = json.items[json.items.length - 1]?.txt; const type = json.items[json.items.length - 1]?.txt;
switch (type) { if (type === "头衔") {
case "头衔": {
const memberUin = json.items[1].param[0]; const memberUin = json.items[1].param[0];
const title = json.items[3].txt; const title = json.items[3].txt;
logger.logDebug('收到群成员新头衔消息', json); logger.logDebug('收到群成员新头衔消息', json);
@ -150,11 +149,10 @@ export class OneBotGroupApi {
parseInt(memberUin), parseInt(memberUin),
title, title,
); );
} } else if (type === "移出") {
case "移出":
logger.logDebug('收到机器人被踢消息', json); logger.logDebug('收到机器人被踢消息', json);
return; return;
default: } else {
logger.logWarn('收到未知的灰条消息', json); logger.logWarn('收到未知的灰条消息', json);
} }
} }

View File

@ -70,18 +70,12 @@ export async function NCoreInitShell() {
const dataPathGlobal = path.resolve(dataPath, './nt_qq/global'); const dataPathGlobal = path.resolve(dataPath, './nt_qq/global');
return [dataPath, dataPathGlobal]; return [dataPath, dataPathGlobal];
})(); })();
let systemPlatform = PlatformType.KWINDOWS; const platformMapping: Partial<Record<NodeJS.Platform, PlatformType>> = {
switch (os.platform()) { win32: PlatformType.KWINDOWS,
case 'win32': darwin: PlatformType.KMAC,
systemPlatform = PlatformType.KWINDOWS; linux: PlatformType.KLINUX,
break; };
case 'darwin': const systemPlatform = platformMapping[os.platform()] ?? PlatformType.KWINDOWS;
systemPlatform = PlatformType.KMAC;
break;
case 'linux':
systemPlatform = PlatformType.KLINUX;
break;
}
if (!basicInfoWrapper.QQVersionAppid || !basicInfoWrapper.QQVersionQua) throw new Error('QQVersionAppid or QQVersionQua is not defined'); if (!basicInfoWrapper.QQVersionAppid || !basicInfoWrapper.QQVersionQua) throw new Error('QQVersionAppid or QQVersionQua is not defined');
// from initConfig // from initConfig
engine.initWithDeskTopConfig( engine.initWithDeskTopConfig(