mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-03-01 08:10:25 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64beeba2d0 | ||
|
|
b3b946e91d | ||
|
|
7e9d852617 | ||
|
|
5da1586811 | ||
|
|
743de940df | ||
|
|
e37fa59b8c | ||
|
|
18d0f11320 |
Binary file not shown.
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "qq-chat",
|
"name": "qq-chat",
|
||||||
"verHash": "2c9d3f6c",
|
"verHash": "c50d6326",
|
||||||
"version": "9.9.22-40990",
|
"version": "9.9.22-40768",
|
||||||
"linuxVersion": "3.2.20-40990",
|
"linuxVersion": "3.2.20-40768",
|
||||||
"linuxVerHash": "ec800879",
|
"linuxVerHash": "ab90fdfa",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "QQ",
|
"description": "QQ",
|
||||||
"productName": "QQ",
|
"productName": "QQ",
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
"qd": "externals/devtools/cli/index.js"
|
"qd": "externals/devtools/cli/index.js"
|
||||||
},
|
},
|
||||||
"main": "./loadNapCat.js",
|
"main": "./loadNapCat.js",
|
||||||
"buildVersion": "40990",
|
"buildVersion": "40768",
|
||||||
"isPureShell": true,
|
"isPureShell": true,
|
||||||
"isByteCodeShell": true,
|
"isByteCodeShell": true,
|
||||||
"platform": "win32",
|
"platform": "win32",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"name": "NapCatQQ",
|
"name": "NapCatQQ",
|
||||||
"slug": "NapCat.Framework",
|
"slug": "NapCat.Framework",
|
||||||
"description": "高性能的 OneBot 11 协议实现",
|
"description": "高性能的 OneBot 11 协议实现",
|
||||||
"version": "4.9.20",
|
"version": "4.9.0",
|
||||||
"icon": "./logo.png",
|
"icon": "./logo.png",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "napcat",
|
"name": "napcat",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "4.9.20",
|
"version": "4.9.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:universal": "npm run build:webui && vite build --mode universal || exit 1",
|
"build:universal": "npm run build:webui && vite build --mode universal || exit 1",
|
||||||
"build:framework": "npm run build:webui && vite build --mode framework || exit 1",
|
"build:framework": "npm run build:webui && vite build --mode framework || exit 1",
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ async function handleWavFile(
|
|||||||
): Promise<{ input: Buffer; sampleRate: number }> {
|
): Promise<{ input: Buffer; sampleRate: number }> {
|
||||||
const { fmt } = getWavFileInfo(file);
|
const { fmt } = getWavFileInfo(file);
|
||||||
if (!ALLOW_SAMPLE_RATE.includes(fmt.sampleRate)) {
|
if (!ALLOW_SAMPLE_RATE.includes(fmt.sampleRate)) {
|
||||||
const result = await FFmpegService.convert(filePath, pcmPath);
|
return { input: await FFmpegService.convert(filePath, pcmPath), sampleRate: 24000 };
|
||||||
return { input: await fsPromise.readFile(pcmPath), sampleRate: result.sampleRate };
|
|
||||||
}
|
}
|
||||||
return { input: file, sampleRate: fmt.sampleRate };
|
return { input: file, sampleRate: fmt.sampleRate };
|
||||||
}
|
}
|
||||||
@@ -43,18 +42,9 @@ export async function encodeSilk(filePath: string, TEMP_DIR: string, logger: Log
|
|||||||
if (!isSilk(file)) {
|
if (!isSilk(file)) {
|
||||||
logger.log(`语音文件${filePath}需要转换成silk`);
|
logger.log(`语音文件${filePath}需要转换成silk`);
|
||||||
const pcmPath = `${pttPath}.pcm`;
|
const pcmPath = `${pttPath}.pcm`;
|
||||||
// const { input, sampleRate } = isWav(file) ? await handleWavFile(file, filePath, pcmPath): { input: await FFmpegService.convert(filePath, pcmPath) ? await fsPromise.readFile(pcmPath) : Buffer.alloc(0), sampleRate: 24000 };
|
const { input, sampleRate } = isWav(file)
|
||||||
let input: Buffer;
|
? await handleWavFile(file, filePath, pcmPath)
|
||||||
let sampleRate: number;
|
: { input: await FFmpegService.convert(filePath, pcmPath), sampleRate: 24000 };
|
||||||
if (isWav(file)) {
|
|
||||||
const result = await handleWavFile(file, filePath, pcmPath);
|
|
||||||
input = result.input;
|
|
||||||
sampleRate = result.sampleRate;
|
|
||||||
} else {
|
|
||||||
const result = await FFmpegService.convert(filePath, pcmPath);
|
|
||||||
input = await fsPromise.readFile(pcmPath);
|
|
||||||
sampleRate = result.sampleRate;
|
|
||||||
}
|
|
||||||
const silk = await runTask<EncodeArgs, EncodeResult>(getWorkerPath(), { input: input, sampleRate: sampleRate });
|
const silk = await runTask<EncodeArgs, EncodeResult>(getWorkerPath(), { input: input, sampleRate: sampleRate });
|
||||||
fsPromise.unlink(pcmPath).catch((e) => logger.logError('删除临时文件失败', pcmPath, e));
|
fsPromise.unlink(pcmPath).catch((e) => logger.logError('删除临时文件失败', pcmPath, e));
|
||||||
await fsPromise.writeFile(pttPath, Buffer.from(silk.data));
|
await fsPromise.writeFile(pttPath, Buffer.from(silk.data));
|
||||||
@@ -79,7 +69,7 @@ export async function encodeSilk(filePath: string, TEMP_DIR: string, logger: Log
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.logError('convert silk failed', error);
|
logger.logError('convert silk failed', (error as Error).stack);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export interface IFFmpegAdapter {
|
|||||||
* @param pcmPath 输出 PCM 文件路径
|
* @param pcmPath 输出 PCM 文件路径
|
||||||
* @returns PCM 数据 Buffer
|
* @returns PCM 数据 Buffer
|
||||||
*/
|
*/
|
||||||
convertToPCM(filePath: string, pcmPath: string): Promise<{ result: boolean, sampleRate: number }>;
|
convertToPCM(filePath: string, pcmPath: string): Promise<Buffer>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换音频文件
|
* 转换音频文件
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ function getAddonPath(binaryPath: string): string {
|
|||||||
const archName = arch();
|
const archName = arch();
|
||||||
|
|
||||||
let addonFileName: string = process.platform + '.' + process.arch;
|
let addonFileName: string = process.platform + '.' + process.arch;
|
||||||
let addonPath = path.join(binaryPath, "./native/ffmpeg/", `ffmpegAddon.${addonFileName}.node`);
|
let addonPath = path.join(binaryPath, "./native/ffmpeg/", `${addonFileName}.node`);
|
||||||
if (!existsSync(addonPath)) {
|
if (existsSync(addonPath)) {
|
||||||
throw new Error(`Unsupported platform: ${platformName} ${archName} - Addon not found at ${addonPath}`);
|
throw new Error(`Unsupported platform: ${platformName} ${archName}`);
|
||||||
}
|
}
|
||||||
return addonPath;
|
return addonPath;
|
||||||
}
|
}
|
||||||
@@ -44,12 +44,16 @@ export class FFmpegAddonAdapter implements IFFmpegAdapter {
|
|||||||
*/
|
*/
|
||||||
async isAvailable(): Promise<boolean> {
|
async isAvailable(): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
|
const addonPath = getAddonPath(this.binaryPath);
|
||||||
|
if (!existsSync(addonPath)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
let temp_addon = { exports: {} };
|
let temp_addon = { exports: {} };
|
||||||
dlopen(temp_addon, getAddonPath(this.binaryPath));
|
dlopen(temp_addon, addonPath);
|
||||||
this.addon = temp_addon.exports as FFmpeg;
|
this.addon = temp_addon.exports as FFmpeg;
|
||||||
return this.addon !== null;
|
return this.addon !== null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('[FFmpegAddonAdapter] Failed to load addon:', error);
|
console.error('[FFmpegAddonAdapter] Failed to load addon:', error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,11 +92,14 @@ export class FFmpegAddonAdapter implements IFFmpegAdapter {
|
|||||||
/**
|
/**
|
||||||
* 转换为 PCM
|
* 转换为 PCM
|
||||||
*/
|
*/
|
||||||
async convertToPCM(filePath: string, pcmPath: string): Promise<{ result: boolean, sampleRate: number }> {
|
async convertToPCM(filePath: string, pcmPath: string): Promise<Buffer> {
|
||||||
const addon = this.ensureAddon();
|
const addon = this.ensureAddon();
|
||||||
const result = await addon.decodeAudioToPCM(filePath, pcmPath, 24000);
|
const result = await addon.decodeAudioToPCM(filePath);
|
||||||
|
|
||||||
return result;
|
// 写入文件
|
||||||
|
await writeFile(pcmPath, result.pcm);
|
||||||
|
|
||||||
|
return result.pcm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -67,5 +67,5 @@ export interface FFmpeg {
|
|||||||
/**
|
/**
|
||||||
* Decode audio file to raw PCM data
|
* Decode audio file to raw PCM data
|
||||||
*/
|
*/
|
||||||
decodeAudioToPCM(filePath: string, pcmPath: string, sampleRate?: number): Promise<{ result: boolean, sampleRate: number }>;
|
decodeAudioToPCM(filePath: string): Promise<AudioPCMResult>;
|
||||||
}
|
}
|
||||||
@@ -157,7 +157,7 @@ export class FFmpegExecAdapter implements IFFmpegAdapter {
|
|||||||
/**
|
/**
|
||||||
* 转换为 PCM
|
* 转换为 PCM
|
||||||
*/
|
*/
|
||||||
async convertToPCM(filePath: string, pcmPath: string): Promise<{ result: boolean, sampleRate: number }> {
|
async convertToPCM(filePath: string, pcmPath: string): Promise<Buffer> {
|
||||||
try {
|
try {
|
||||||
ensureDirExists(pcmPath);
|
ensureDirExists(pcmPath);
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ export class FFmpegExecAdapter implements IFFmpegAdapter {
|
|||||||
throw new Error('转换PCM失败,输出文件不存在');
|
throw new Error('转换PCM失败,输出文件不存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
return { result: true, sampleRate: 24000 };
|
return readFileSync(pcmPath);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
throw new Error(`FFmpeg处理转换出错: ${error.message}`);
|
throw new Error(`FFmpeg处理转换出错: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export class FFmpegService {
|
|||||||
/**
|
/**
|
||||||
* 转换为 PCM 格式
|
* 转换为 PCM 格式
|
||||||
*/
|
*/
|
||||||
public static async convert(filePath: string, pcmPath: string): Promise<{ result: boolean, sampleRate: number }> {
|
public static async convert(filePath: string, pcmPath: string): Promise<Buffer> {
|
||||||
const adapter = await this.getAdapter();
|
const adapter = await this.getAdapter();
|
||||||
return adapter.convertToPCM(filePath, pcmPath);
|
return adapter.convertToPCM(filePath, pcmPath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export const napCatVersion = '4.9.20';
|
export const napCatVersion = '4.9.0';
|
||||||
|
|||||||
@@ -333,10 +333,6 @@ export class NTQQFileApi {
|
|||||||
fileSubId: '',
|
fileSubId: '',
|
||||||
playState: 1,
|
playState: 1,
|
||||||
autoConvertText: 0,
|
autoConvertText: 0,
|
||||||
storeID: 0,
|
|
||||||
otherBusinessInfo: {
|
|
||||||
aiVoiceType: 0
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/core/external/appid.json
vendored
16
src/core/external/appid.json
vendored
@@ -426,21 +426,5 @@
|
|||||||
"3.2.20-40990": {
|
"3.2.20-40990": {
|
||||||
"appid": 537319891,
|
"appid": 537319891,
|
||||||
"qua": "V1_LNX_NQ_3.2.20_40990_GW_B"
|
"qua": "V1_LNX_NQ_3.2.20_40990_GW_B"
|
||||||
},
|
|
||||||
"9.9.23-41679": {
|
|
||||||
"appid": 537320110,
|
|
||||||
"qua": "V1_WIN_NQ_9.9.23_41679_GW_B"
|
|
||||||
},
|
|
||||||
"6.8.83-41679": {
|
|
||||||
"appid": 537320135,
|
|
||||||
"qua": "V1_MAC_NQ_6.9.83_41679_GW_B"
|
|
||||||
},
|
|
||||||
"9.9.23-41785": {
|
|
||||||
"appid": 537320110,
|
|
||||||
"qua": "V1_WIN_NQ_9.9.23_41785_GW_B"
|
|
||||||
},
|
|
||||||
"6.8.83-41785": {
|
|
||||||
"appid": 537320135,
|
|
||||||
"qua": "V1_MAC_NQ_6.9.83_41785_GW_B"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
34
src/core/external/napi2native.json
vendored
34
src/core/external/napi2native.json
vendored
@@ -12,15 +12,15 @@
|
|||||||
"recv": "1D8CA9D"
|
"recv": "1D8CA9D"
|
||||||
},
|
},
|
||||||
"3.2.20-40768-x64": {
|
"3.2.20-40768-x64": {
|
||||||
"send": "2A1B840",
|
"send": "2CC8120",
|
||||||
"recv": "2D28F20"
|
"recv": "2D28F20"
|
||||||
},
|
},
|
||||||
"3.2.20-40824-x64": {
|
"3.2.20-40824-x64": {
|
||||||
"send": "2A1B840",
|
"send": "2CC8120",
|
||||||
"recv": "2D28F20"
|
"recv": "2D28F20"
|
||||||
},
|
},
|
||||||
"3.2.20-40990-x64": {
|
"3.2.20-40990-x64": {
|
||||||
"send": "2A1B840",
|
"send": "2CC8120",
|
||||||
"recv": "2D28F20"
|
"recv": "2D28F20"
|
||||||
},
|
},
|
||||||
"3.2.20-40990-arm64": {
|
"3.2.20-40990-arm64": {
|
||||||
@@ -34,33 +34,5 @@
|
|||||||
"3.2.20-40768-arm64": {
|
"3.2.20-40768-arm64": {
|
||||||
"send": "157C0E8",
|
"send": "157C0E8",
|
||||||
"recv": "1546658"
|
"recv": "1546658"
|
||||||
},
|
|
||||||
"9.9.23-41679-x64": {
|
|
||||||
"send": "09FF0F4",
|
|
||||||
"recv": "1D1A039"
|
|
||||||
},
|
|
||||||
"6.9.82-40824-arm64": {
|
|
||||||
"send": "05FA930",
|
|
||||||
"recv": "0B41B90"
|
|
||||||
},
|
|
||||||
"6.9.82-40768-arm64": {
|
|
||||||
"send": "05FA930",
|
|
||||||
"recv": "0B41B90"
|
|
||||||
},
|
|
||||||
"6.9.82-40990-arm64": {
|
|
||||||
"send": "05FA930",
|
|
||||||
"recv": "0B41B90"
|
|
||||||
},
|
|
||||||
"6.9.83-41679-arm64": {
|
|
||||||
"send": "237D114",
|
|
||||||
"recv": "0957648"
|
|
||||||
},
|
|
||||||
"6.9.83-41785-arm64": {
|
|
||||||
"send": "23B0BF0",
|
|
||||||
"recv": "095567C"
|
|
||||||
},
|
|
||||||
"9.9.23-41785-x64": {
|
|
||||||
"send": "09FF0A4",
|
|
||||||
"recv": "1D19FF9"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
16
src/core/external/packet.json
vendored
16
src/core/external/packet.json
vendored
@@ -558,21 +558,5 @@
|
|||||||
"6.9.82-40990-arm64": {
|
"6.9.82-40990-arm64": {
|
||||||
"send": "202A198",
|
"send": "202A198",
|
||||||
"recv": "202B718"
|
"recv": "202B718"
|
||||||
},
|
|
||||||
"9.9.23-41679-x64": {
|
|
||||||
"send": "2C94520",
|
|
||||||
"recv": "2C97AA0"
|
|
||||||
},
|
|
||||||
"6.9.83-41679-arm64": {
|
|
||||||
"send": "3D718F8",
|
|
||||||
"recv": "3D74208"
|
|
||||||
},
|
|
||||||
"9.9.23-41785-x64": {
|
|
||||||
"send": "2C944A0",
|
|
||||||
"recv": "2C97A20"
|
|
||||||
},
|
|
||||||
"6.8.83-41785-arm64": {
|
|
||||||
"send": "3D6DA28",
|
|
||||||
"recv": "3D70338"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,36 +74,6 @@ export const GroupChange = {
|
|||||||
field7: ProtoField(7, ScalarType.BYTES, true),
|
field7: ProtoField(7, ScalarType.BYTES, true),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Group Reaction Related
|
|
||||||
export const GroupReactionDataInnerDataTarget = {
|
|
||||||
seq: ProtoField(1, ScalarType.UINT64, true),
|
|
||||||
};
|
|
||||||
|
|
||||||
export const GroupReactionDataContent = {
|
|
||||||
code: ProtoField(1, ScalarType.STRING, true),
|
|
||||||
count: ProtoField(3, ScalarType.UINT32, true),
|
|
||||||
operatorUid: ProtoField(4, ScalarType.STRING, true),
|
|
||||||
type: ProtoField(5, ScalarType.UINT32, true),
|
|
||||||
};
|
|
||||||
|
|
||||||
export const GroupReactionDataInnerData = {
|
|
||||||
groupReactionTarget: ProtoField(2, () => GroupReactionDataInnerDataTarget, true),
|
|
||||||
groupReactionDataContent: ProtoField(3, () => GroupReactionDataContent, true),
|
|
||||||
};
|
|
||||||
export const GroupReactionDataInner = {
|
|
||||||
data: ProtoField(1, () => GroupReactionDataInnerData, true),
|
|
||||||
};
|
|
||||||
export const GroupReactionData = {
|
|
||||||
data: ProtoField(1, () => GroupReactionDataInner, true),
|
|
||||||
};
|
|
||||||
|
|
||||||
export const GroupReactNotify = {
|
|
||||||
groupUin: ProtoField(4, ScalarType.UINT64, true),
|
|
||||||
field13: ProtoField(13, ScalarType.UINT32, true),
|
|
||||||
groupReactionData: ProtoField(44, () => GroupReactionData, true),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Group Invite Related
|
|
||||||
export const GroupInvite = {
|
export const GroupInvite = {
|
||||||
groupUin: ProtoField(1, ScalarType.UINT32),
|
groupUin: ProtoField(1, ScalarType.UINT32),
|
||||||
field2: ProtoField(2, ScalarType.UINT32),
|
field2: ProtoField(2, ScalarType.UINT32),
|
||||||
|
|||||||
@@ -311,10 +311,6 @@ export interface PttElement {
|
|||||||
voiceType: number;
|
voiceType: number;
|
||||||
waveAmplitudes: number[];
|
waveAmplitudes: number[];
|
||||||
autoConvertText: number;
|
autoConvertText: number;
|
||||||
storeID: number;
|
|
||||||
otherBusinessInfo: {
|
|
||||||
aiVoiceType: number;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SendRecommendedMsgElement = SendElementBase<ElementType.RECOMMENDEDMSG> & ElementBase<'recommendedMsgElement'>;
|
export type SendRecommendedMsgElement = SendElementBase<ElementType.RECOMMENDEDMSG> & ElementBase<'recommendedMsgElement'>;
|
||||||
@@ -353,7 +349,7 @@ export type SendPicElement = SendElementBase<ElementType.PIC> & ElementBase<'pic
|
|||||||
|
|
||||||
export type SendPttElement = SendElementBase<ElementType.PTT> & ElementBase<'pttElement', {
|
export type SendPttElement = SendElementBase<ElementType.PTT> & ElementBase<'pttElement', {
|
||||||
pttElement: ['fileName', 'filePath', 'md5HexStr', 'fileSize', 'duration', 'formatType', 'voiceType',
|
pttElement: ['fileName', 'filePath', 'md5HexStr', 'fileSize', 'duration', 'formatType', 'voiceType',
|
||||||
'voiceChangeType', 'canConvert2Text', 'waveAmplitudes', 'fileSubId', 'playState', 'autoConvertText', 'storeID', 'otherBusinessInfo']
|
'voiceChangeType', 'canConvert2Text', 'waveAmplitudes', 'fileSubId', 'playState', 'autoConvertText']
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
export type SendFileElement = SendElementBase<ElementType.FILE> & ElementBase<'fileElement'>;
|
export type SendFileElement = SendElementBase<ElementType.FILE> & ElementBase<'fileElement'>;
|
||||||
|
|||||||
@@ -139,20 +139,8 @@ export interface NodeQQNTWrapperUtil {
|
|||||||
|
|
||||||
isNull(): unknown;
|
isNull(): unknown;
|
||||||
}
|
}
|
||||||
export interface NodeIQQNTStartupSessionWrapper {
|
|
||||||
create(): NodeIQQNTStartupSessionWrapper;
|
|
||||||
stop(): void;
|
|
||||||
start(): void;
|
|
||||||
createWithModuleList(uk: unknown): unknown;
|
|
||||||
getSessionIdList(): unknown;
|
|
||||||
}
|
|
||||||
export interface NodeIQQNTWrapperSession {
|
export interface NodeIQQNTWrapperSession {
|
||||||
getNTWrapperSession(str: string): NodeIQQNTWrapperSession;
|
|
||||||
|
|
||||||
get(): NodeIQQNTWrapperSession;
|
|
||||||
|
|
||||||
new(): NodeIQQNTWrapperSession;
|
|
||||||
|
|
||||||
create(): NodeIQQNTWrapperSession;
|
create(): NodeIQQNTWrapperSession;
|
||||||
|
|
||||||
init(
|
init(
|
||||||
@@ -281,7 +269,6 @@ export interface WrapperNodeApi {
|
|||||||
NodeIO3MiscService: NodeIO3MiscService;
|
NodeIO3MiscService: NodeIO3MiscService;
|
||||||
NodeQQNTWrapperUtil: NodeQQNTWrapperUtil;
|
NodeQQNTWrapperUtil: NodeQQNTWrapperUtil;
|
||||||
NodeIQQNTWrapperSession: NodeIQQNTWrapperSession;
|
NodeIQQNTWrapperSession: NodeIQQNTWrapperSession;
|
||||||
NodeIQQNTStartupSessionWrapper: NodeIQQNTStartupSessionWrapper
|
|
||||||
NodeIQQNTWrapperEngine: NodeIQQNTWrapperEngine;
|
NodeIQQNTWrapperEngine: NodeIQQNTWrapperEngine;
|
||||||
NodeIKernelLoginService: NodeIKernelLoginService;
|
NodeIKernelLoginService: NodeIKernelLoginService;
|
||||||
|
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ export async function NCoreInitFramework(
|
|||||||
const basicInfoWrapper = new QQBasicInfoWrapper({ logger });
|
const basicInfoWrapper = new QQBasicInfoWrapper({ logger });
|
||||||
const wrapper = loadQQWrapper(basicInfoWrapper.getFullQQVersion());
|
const wrapper = loadQQWrapper(basicInfoWrapper.getFullQQVersion());
|
||||||
const nativePacketHandler = new NativePacketHandler({ logger }); // 初始化 NativePacketHandler 用于后续使用
|
const nativePacketHandler = new NativePacketHandler({ logger }); // 初始化 NativePacketHandler 用于后续使用
|
||||||
// nativePacketHandler.onAll((packet) => {
|
nativePacketHandler.onAll((packet) => {
|
||||||
// console.log('[Packet]', packet.uin, packet.cmd, packet.hex_data);
|
console.log('[Packet]', packet.uin, packet.cmd, packet.hex_data);
|
||||||
// });
|
});
|
||||||
await nativePacketHandler.init(basicInfoWrapper.getFullQQVersion());
|
await nativePacketHandler.init(basicInfoWrapper.getFullQQVersion());
|
||||||
// 在 init 之后注册监听器
|
// 在 init 之后注册监听器
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -28,10 +28,7 @@ export class GetGroupEssence extends OneBotAction<Payload, unknown> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _handle(payload: Payload, _adapter: string, config: NetworkAdapterConfig) {
|
async _handle(payload: Payload, _adapter: string, config: NetworkAdapterConfig) {
|
||||||
const msglist = (await this.core.apis.WebApi.getGroupEssenceMsgAll(payload.group_id.toString()))
|
const msglist = (await this.core.apis.WebApi.getGroupEssenceMsgAll(payload.group_id.toString())).flatMap((e) => e.data.msg_list);
|
||||||
.flatMap((e) => e?.data?.msg_list)
|
|
||||||
// 在群精华回空的时候会出现[null]的情况~ https://github.com/NapNeko/NapCatQQ/issues/1334
|
|
||||||
.filter(Boolean);
|
|
||||||
if (!msglist) {
|
if (!msglist) {
|
||||||
throw new Error('获取失败');
|
throw new Error('获取失败');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,6 @@ import { OB11GroupUploadNoticeEvent } from '../event/notice/OB11GroupUploadNotic
|
|||||||
import { OB11GroupNameEvent } from '../event/notice/OB11GroupNameEvent';
|
import { OB11GroupNameEvent } from '../event/notice/OB11GroupNameEvent';
|
||||||
import { FileNapCatOneBotUUID } from '@/common/file-uuid';
|
import { FileNapCatOneBotUUID } from '@/common/file-uuid';
|
||||||
import { OB11GroupIncreaseEvent } from '../event/notice/OB11GroupIncreaseEvent';
|
import { OB11GroupIncreaseEvent } from '../event/notice/OB11GroupIncreaseEvent';
|
||||||
import { NapProtoMsg } from '@napneko/nap-proto-core';
|
|
||||||
import { GroupReactNotify, PushMsg } from '@/core/packet/transformer/proto';
|
|
||||||
|
|
||||||
export class OneBotGroupApi {
|
export class OneBotGroupApi {
|
||||||
obContext: NapCatOneBot11Adapter;
|
obContext: NapCatOneBot11Adapter;
|
||||||
@@ -70,10 +68,6 @@ export class OneBotGroupApi {
|
|||||||
groupCode: string,
|
groupCode: string,
|
||||||
grayTipElement: GrayTipElement
|
grayTipElement: GrayTipElement
|
||||||
) {
|
) {
|
||||||
if (this.core.apis.PacketApi.packetStatus === true) {
|
|
||||||
return;
|
|
||||||
//Raw包解析支持时禁用NT解析
|
|
||||||
}
|
|
||||||
const emojiLikeData = new fastXmlParser.XMLParser({
|
const emojiLikeData = new fastXmlParser.XMLParser({
|
||||||
ignoreAttributes: false,
|
ignoreAttributes: false,
|
||||||
attributeNamePrefix: '',
|
attributeNamePrefix: '',
|
||||||
@@ -82,7 +76,7 @@ export class OneBotGroupApi {
|
|||||||
const senderUin = emojiLikeData.gtip.qq.jp;
|
const senderUin = emojiLikeData.gtip.qq.jp;
|
||||||
const msgSeq = emojiLikeData.gtip.url.msgseq;
|
const msgSeq = emojiLikeData.gtip.url.msgseq;
|
||||||
const emojiId = emojiLikeData.gtip.face.id;
|
const emojiId = emojiLikeData.gtip.face.id;
|
||||||
return await this.createGroupEmojiLikeEvent(groupCode, senderUin, msgSeq, emojiId, true, 1);
|
return await this.createGroupEmojiLikeEvent(groupCode, senderUin, msgSeq, emojiId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async createGroupEmojiLikeEvent(
|
async createGroupEmojiLikeEvent(
|
||||||
@@ -90,8 +84,6 @@ export class OneBotGroupApi {
|
|||||||
senderUin: string,
|
senderUin: string,
|
||||||
msgSeq: string,
|
msgSeq: string,
|
||||||
emojiId: string,
|
emojiId: string,
|
||||||
isAdd: boolean = true,
|
|
||||||
count: number = 1,
|
|
||||||
) {
|
) {
|
||||||
const peer = {
|
const peer = {
|
||||||
chatType: ChatType.KCHATTYPEGROUP,
|
chatType: ChatType.KCHATTYPEGROUP,
|
||||||
@@ -111,13 +103,11 @@ export class OneBotGroupApi {
|
|||||||
this.core,
|
this.core,
|
||||||
parseInt(groupCode),
|
parseInt(groupCode),
|
||||||
parseInt(senderUin),
|
parseInt(senderUin),
|
||||||
MessageUnique.createUniqueMsgId({ chatType: ChatType.KCHATTYPEGROUP, guildId: '', peerUid: groupCode }, replyMsg.msgId),
|
MessageUnique.getShortIdByMsgId(replyMsg.msgId)!,
|
||||||
[{
|
[{
|
||||||
emoji_id: emojiId,
|
emoji_id: emojiId,
|
||||||
count: count,
|
count: 1,
|
||||||
}],
|
}],
|
||||||
isAdd,
|
|
||||||
msgSeq
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,40 +126,7 @@ export class OneBotGroupApi {
|
|||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
async registerParseGroupReactEvent() {
|
|
||||||
this.obContext.core.context.packetHandler.onCmd('trpc.msg.olpush.OlPushService.MsgPush', async (packet) => {
|
|
||||||
let data = new NapProtoMsg(PushMsg).decode(Buffer.from(packet.hex_data, 'hex'));
|
|
||||||
if (data.message.contentHead.type === 732 && data.message.contentHead.subType === 16) {
|
|
||||||
let pbNotify = data.message.body?.msgContent?.slice(7);
|
|
||||||
if (!pbNotify) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 开始解析Notify
|
|
||||||
const notify = new NapProtoMsg(GroupReactNotify).decode(pbNotify);
|
|
||||||
if ((notify.field13 ?? 0) === 35) {
|
|
||||||
// Group React Notify
|
|
||||||
const groupCode = notify.groupUin?.toString() ?? '';
|
|
||||||
const operatorUid = notify.groupReactionData?.data?.data?.groupReactionDataContent?.operatorUid ?? '';
|
|
||||||
const type = notify.groupReactionData?.data?.data?.groupReactionDataContent?.type ?? 0;
|
|
||||||
const seq = notify.groupReactionData?.data?.data?.groupReactionTarget?.seq?.toString() ?? '';
|
|
||||||
const code = notify.groupReactionData?.data?.data?.groupReactionDataContent?.code ?? '';
|
|
||||||
//const count = notify.groupReactionData?.data?.data?.groupReactionDataContent?.count ?? 0;
|
|
||||||
const senderUin = await this.core.apis.UserApi.getUinByUidV2(operatorUid);
|
|
||||||
const event = await this.createGroupEmojiLikeEvent(
|
|
||||||
groupCode,
|
|
||||||
senderUin,
|
|
||||||
seq,
|
|
||||||
code,
|
|
||||||
type === 1,
|
|
||||||
1
|
|
||||||
);
|
|
||||||
if (event) {
|
|
||||||
this.obContext.networkManager.emitEvent(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async parsePaiYiPai(msg: RawMessage, jsonStr: string) {
|
async parsePaiYiPai(msg: RawMessage, jsonStr: string) {
|
||||||
const json = JSON.parse(jsonStr);
|
const json = JSON.parse(jsonStr);
|
||||||
//判断业务类型
|
//判断业务类型
|
||||||
|
|||||||
@@ -1182,7 +1182,7 @@ export class OneBotMsgApi {
|
|||||||
}, returnMsg.msgId);
|
}, returnMsg.msgId);
|
||||||
return returnMsg;
|
return returnMsg;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw new Error((error as Error).message);
|
||||||
} finally {
|
} finally {
|
||||||
cleanTaskQueue.addFiles(deleteAfterSentFiles, timeout);
|
cleanTaskQueue.addFiles(deleteAfterSentFiles, timeout);
|
||||||
// setTimeout(async () => {
|
// setTimeout(async () => {
|
||||||
|
|||||||
@@ -10,15 +10,12 @@ export class OB11GroupMsgEmojiLikeEvent extends OB11GroupNoticeEvent {
|
|||||||
notice_type = 'group_msg_emoji_like';
|
notice_type = 'group_msg_emoji_like';
|
||||||
message_id: number;
|
message_id: number;
|
||||||
likes: MsgEmojiLike[];
|
likes: MsgEmojiLike[];
|
||||||
is_add: boolean;
|
|
||||||
message_seq?: string;
|
|
||||||
|
|
||||||
constructor(core: NapCatCore, groupId: number, userId: number, messageId: number, likes: MsgEmojiLike[], isAdd: boolean, messageSeq?: string) {
|
constructor(core: NapCatCore, groupId: number, userId: number, messageId: number, likes: MsgEmojiLike[]) {
|
||||||
super(core, groupId, userId);
|
super(core, groupId, userId);
|
||||||
this.group_id = groupId;
|
this.group_id = groupId;
|
||||||
this.user_id = userId; // 可为空,表示是对别人的消息操作,如果是对bot自己的消息则不为空
|
this.user_id = userId; // 可为空,表示是对别人的消息操作,如果是对bot自己的消息则不为空
|
||||||
this.message_id = messageId;
|
this.message_id = messageId;
|
||||||
this.likes = likes;
|
this.likes = likes;
|
||||||
this.is_add = isAdd;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,9 +216,6 @@ export class NapCatOneBot11Adapter {
|
|||||||
//this.context.logger.log(`OneBot11 配置更改:${JSON.stringify(prev)} -> ${JSON.stringify(newConfig)}`);
|
//this.context.logger.log(`OneBot11 配置更改:${JSON.stringify(prev)} -> ${JSON.stringify(newConfig)}`);
|
||||||
await this.reloadNetwork(prev, newConfig);
|
await this.reloadNetwork(prev, newConfig);
|
||||||
});
|
});
|
||||||
this.apis.GroupApi.registerParseGroupReactEvent().catch(e =>
|
|
||||||
this.context.logger.logError('注册群消息反应表情失败', e)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
loadQQWrapper,
|
loadQQWrapper,
|
||||||
NapCatCore,
|
NapCatCore,
|
||||||
NapCatCoreWorkingEnv,
|
NapCatCoreWorkingEnv,
|
||||||
NodeIQQNTStartupSessionWrapper,
|
|
||||||
NodeIQQNTWrapperEngine,
|
NodeIQQNTWrapperEngine,
|
||||||
NodeIQQNTWrapperSession,
|
NodeIQQNTWrapperSession,
|
||||||
PlatformType,
|
PlatformType,
|
||||||
@@ -243,8 +242,7 @@ async function handleLoginInner(context: { isLogined: boolean }, logger: LogWrap
|
|||||||
|
|
||||||
async function initializeSession(
|
async function initializeSession(
|
||||||
session: NodeIQQNTWrapperSession,
|
session: NodeIQQNTWrapperSession,
|
||||||
sessionConfig: WrapperSessionInitConfig,
|
sessionConfig: WrapperSessionInitConfig
|
||||||
startupSession: NodeIQQNTStartupSessionWrapper | null
|
|
||||||
) {
|
) {
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
const sessionListener = new NodeIKernelSessionListener();
|
const sessionListener = new NodeIKernelSessionListener();
|
||||||
@@ -261,9 +259,6 @@ async function initializeSession(
|
|||||||
new NodeIDispatcherAdapter(),
|
new NodeIDispatcherAdapter(),
|
||||||
sessionListener,
|
sessionListener,
|
||||||
);
|
);
|
||||||
if (startupSession) {
|
|
||||||
startupSession.start();
|
|
||||||
} else {
|
|
||||||
try {
|
try {
|
||||||
session.startNT(0);
|
session.startNT(0);
|
||||||
} catch {
|
} catch {
|
||||||
@@ -273,7 +268,6 @@ async function initializeSession(
|
|||||||
reject(new Error('init failed ' + (e as Error).message));
|
reject(new Error('init failed ' + (e as Error).message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async function handleProxy(session: NodeIQQNTWrapperSession, logger: LogWrapper) {
|
async function handleProxy(session: NodeIQQNTWrapperSession, logger: LogWrapper) {
|
||||||
@@ -328,9 +322,9 @@ export async function NCoreInitShell() {
|
|||||||
const wrapper = loadQQWrapper(basicInfoWrapper.getFullQQVersion());
|
const wrapper = loadQQWrapper(basicInfoWrapper.getFullQQVersion());
|
||||||
const nativePacketHandler = new NativePacketHandler({ logger }); // 初始化 NativePacketHandler 用于后续使用
|
const nativePacketHandler = new NativePacketHandler({ logger }); // 初始化 NativePacketHandler 用于后续使用
|
||||||
|
|
||||||
// nativePacketHandler.onAll((packet) => {
|
nativePacketHandler.onAll((packet) => {
|
||||||
// console.log('[Packet]', packet.uin, packet.cmd, packet.hex_data);
|
console.log('[Packet]', packet.uin, packet.cmd, packet.hex_data);
|
||||||
// });
|
});
|
||||||
await nativePacketHandler.init(basicInfoWrapper.getFullQQVersion());
|
await nativePacketHandler.init(basicInfoWrapper.getFullQQVersion());
|
||||||
|
|
||||||
const o3Service = wrapper.NodeIO3MiscService.get();
|
const o3Service = wrapper.NodeIO3MiscService.get();
|
||||||
@@ -341,20 +335,8 @@ export async function NCoreInitShell() {
|
|||||||
|
|
||||||
const engine = wrapper.NodeIQQNTWrapperEngine.get();
|
const engine = wrapper.NodeIQQNTWrapperEngine.get();
|
||||||
const loginService = wrapper.NodeIKernelLoginService.get();
|
const loginService = wrapper.NodeIKernelLoginService.get();
|
||||||
let session: NodeIQQNTWrapperSession;
|
const session = wrapper.NodeIQQNTWrapperSession.create();
|
||||||
let startupSession: NodeIQQNTStartupSessionWrapper | null = null;
|
|
||||||
try {
|
|
||||||
startupSession = wrapper.NodeIQQNTStartupSessionWrapper.create();
|
|
||||||
session = wrapper.NodeIQQNTWrapperSession.getNTWrapperSession('nt_1');
|
|
||||||
} catch (e: unknown) {
|
|
||||||
try {
|
|
||||||
session = wrapper.NodeIQQNTWrapperSession.create();
|
|
||||||
} catch (error) {
|
|
||||||
logger.logError('创建 StartupSession 失败', e);
|
|
||||||
logger.logError('创建 Session 失败', error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const [dataPath, dataPathGlobal] = getDataPaths(wrapper);
|
const [dataPath, dataPathGlobal] = getDataPaths(wrapper);
|
||||||
const systemPlatform = getPlatformType();
|
const systemPlatform = getPlatformType();
|
||||||
|
|
||||||
@@ -388,7 +370,7 @@ export async function NCoreInitShell() {
|
|||||||
dataPath,
|
dataPath,
|
||||||
);
|
);
|
||||||
|
|
||||||
await initializeSession(session, sessionConfig, startupSession);
|
await initializeSession(session, sessionConfig);
|
||||||
|
|
||||||
const accountDataPath = path.resolve(dataPath, './NapCat/data');
|
const accountDataPath = path.resolve(dataPath, './NapCat/data');
|
||||||
//判断dataPath是否为根目录 或者 D:/ 之类的盘目录
|
//判断dataPath是否为根目录 或者 D:/ 之类的盘目录
|
||||||
|
|||||||
Reference in New Issue
Block a user