Compare commits

...
37 Commits
Author SHA1 Message Date
手瓜一十雪 5407392f08 Update appid, packet, and napi2native configs for 41785
Build Action / Build-LiteLoader (push) Canceled after 0s
Build Action / Build-Shell (push) Canceled after 0s
Build Release / check-version (push) Canceled after 0s
Build Release / Build-LiteLoader (push) Canceled after 0s
Build Release / Build-Shell (push) Canceled after 0s
Build Release / release-napcat (push) Canceled after 0s
Build Release / build-docker (push) Canceled after 0s
Added new entries for version 41785 in appid.json, napi2native.json, and packet.json to support updated app and protocol versions. Also updated the napi2native.darwin.arm64.node binary to match the new version.
2025-11-02 11:29:45 +08:00
Mlikiowa 3359c5ded9 release: v4.9.19 2025-11-01 15:23:54 +00:00
手瓜一十雪 caaf8be3b2 Refactor PCM conversion to return result and sample rate
Build Action / Build-LiteLoader (push) Canceled after 0s
Build Action / Build-Shell (push) Canceled after 0s
Build Release / check-version (push) Canceled after 0s
Build Release / Build-LiteLoader (push) Canceled after 0s
Build Release / Build-Shell (push) Canceled after 0s
Build Release / release-napcat (push) Canceled after 0s
Build Release / build-docker (push) Canceled after 0s
Updated the FFmpeg adapter interfaces and implementations so that PCM conversion methods now return an object containing the conversion result and sample rate, instead of a Buffer. Adjusted audio processing logic to accommodate this change and improved error logging. Updated native ffmpeg addon binaries.
2025-11-01 23:23:15 +08:00
手瓜一十雪 28ce5d3cb4 Add storeID and otherBusinessInfo to PttElement
Extended the PttElement interface and related code to include storeID and otherBusinessInfo fields, supporting additional metadata for PTT elements. Also fixed minor formatting issues in function parameter spacing.
2025-11-01 22:49:21 +08:00
手瓜一十雪 3dd56c711e Throw original error in sendMsg method
Replaces the re-throwing of a new Error with the original error object in the sendMsg method, preserving the original error stack and type for better debugging.
2025-11-01 22:32:26 +08:00
Mlikiowa 511fb82ce0 release: v4.9.18 2025-11-01 13:54:19 +00:00
手瓜一十雪 1e5524a009 Add message sequence support for emoji like events
Build Action / Build-LiteLoader (push) Canceled after 0s
Build Action / Build-Shell (push) Canceled after 0s
Build Release / check-version (push) Canceled after 0s
Build Release / Build-LiteLoader (push) Canceled after 0s
Build Release / Build-Shell (push) Canceled after 0s
Build Release / release-napcat (push) Canceled after 0s
Build Release / build-docker (push) Canceled after 0s
Updated group API and OB11GroupMsgEmojiLikeEvent to include an optional message sequence (msgSeq/messageSeq) parameter. This allows more precise identification of messages when handling emoji like events in group chats.
2025-11-01 21:53:53 +08:00
手瓜一十雪 d5e6afc7b9 feat: 支持不是自己的表情回应 2025-11-01 21:00:34 +08:00
Mlikiowa 91e633b0fb release: v4.9.17 2025-11-01 10:43:55 +00:00
手瓜一十雪 397b9880b9 feat: arm64 enable neon
Build Action / Build-LiteLoader (push) Canceled after 0s
Build Action / Build-Shell (push) Canceled after 0s
Build Release / check-version (push) Canceled after 0s
Build Release / Build-LiteLoader (push) Canceled after 0s
Build Release / Build-Shell (push) Canceled after 0s
Build Release / release-napcat (push) Canceled after 0s
Build Release / build-docker (push) Canceled after 0s
2025-11-01 18:43:30 +08:00
Mlikiowa 54eb26ba67 release: v4.9.16 2025-11-01 08:19:18 +00:00
手瓜一十雪 355f7fb4a0 Update napi2native mappings for new and existing versions
Build Action / Build-LiteLoader (push) Canceled after 0s
Build Action / Build-Shell (push) Canceled after 0s
Build Release / check-version (push) Canceled after 0s
Build Release / Build-LiteLoader (push) Canceled after 0s
Build Release / Build-Shell (push) Canceled after 0s
Build Release / release-napcat (push) Canceled after 0s
Build Release / build-docker (push) Canceled after 0s
Added mappings for versions 6.9.82-40824-arm64 and 6.9.82-40768-arm64. Updated 'send' addresses for versions 6.9.82-40990-arm64 and 6.9.83-41679-arm64 to reflect new offsets.
2025-11-01 16:18:51 +08:00
手瓜一十雪 325c455e38 Update native Linux ARM64 binary
Replaced the napi2native.linux.arm64.node binary with a new version. This may include bug fixes, performance improvements, or compatibility updates for ARM64 Linux systems.
2025-11-01 16:14:18 +08:00
Mlikiowa a7a9792efe release: v4.9.15 2025-11-01 06:08:11 +00:00
时瑾 4bab93e545 fix: close #1334
Build Action / Build-LiteLoader (push) Canceled after 0s
Build Action / Build-Shell (push) Canceled after 0s
Build Release / check-version (push) Canceled after 0s
Build Release / Build-LiteLoader (push) Canceled after 0s
Build Release / Build-Shell (push) Canceled after 0s
Build Release / release-napcat (push) Canceled after 0s
Build Release / build-docker (push) Canceled after 0s
2025-11-01 14:07:41 +08:00
手瓜一十雪 3c60997b1c Improve error handling in NCoreInitShell session creation
Refactored session creation logic to add nested try-catch blocks. Now logs specific errors for both StartupSession and Session creation failures, and throws if session creation fails.
2025-11-01 11:11:10 +08:00
Mlikiowa bf684d9166 release: v4.9.14 2025-10-31 08:53:45 +00:00
手瓜一十雪 5c4ee30f37 Update ffmpeg native binaries for Linux
Build Release / check-version (push) Canceled after 0s
Build Release / Build-LiteLoader (push) Canceled after 0s
Build Release / Build-Shell (push) Canceled after 0s
Build Release / release-napcat (push) Canceled after 0s
Build Release / build-docker (push) Canceled after 0s
Build Action / Build-LiteLoader (push) Canceled after 0s
Build Action / Build-Shell (push) Canceled after 0s
Replaced ffmpegAddon.linux.arm64.node and ffmpegAddon.linux.x64.node with new versions. This likely includes bug fixes, performance improvements, or compatibility updates for the native ffmpeg bindings.
2025-10-31 16:53:11 +08:00
Mlikiowa 346374b442 release: v4.9.13 2025-10-31 07:15:49 +00:00
手瓜一十雪 cc8a387bde re: glibc
Build Action / Build-LiteLoader (push) Canceled after 0s
Build Action / Build-Shell (push) Canceled after 0s
Build Release / check-version (push) Canceled after 0s
Build Release / Build-LiteLoader (push) Canceled after 0s
Build Release / Build-Shell (push) Canceled after 0s
Build Release / release-napcat (push) Canceled after 0s
Build Release / build-docker (push) Canceled after 0s
2025-10-31 15:12:46 +08:00
Mlikiowa 962685ade6 release: v4.9.11 2025-10-31 06:43:40 +00:00
手瓜一十雪 36fdaac406 feat: 适配41697
Build Action / Build-LiteLoader (push) Canceled after 0s
Build Action / Build-Shell (push) Canceled after 0s
Build Release / check-version (push) Canceled after 0s
Build Release / Build-LiteLoader (push) Canceled after 0s
Build Release / Build-Shell (push) Canceled after 0s
Build Release / release-napcat (push) Canceled after 0s
Build Release / build-docker (push) Canceled after 0s
2025-10-31 14:42:46 +08:00
Mlikiowa db16db911b release: v4.9.10 2025-10-31 04:38:12 +00:00
手瓜一十雪 bb84dfcc27 Add new version mappings to external JSON configs
Build Release / check-version (push) Canceled after 0s
Build Release / Build-LiteLoader (push) Canceled after 0s
Build Release / Build-Shell (push) Canceled after 0s
Build Release / release-napcat (push) Canceled after 0s
Build Release / build-docker (push) Canceled after 0s
Build Action / Build-LiteLoader (push) Canceled after 0s
Build Action / Build-Shell (push) Canceled after 0s
Updated appid.json, napi2native.json, and packet.json to include new version entries for 6.8.83-41679, 6.9.82-40990-arm64, and 6.9.83-41679-arm64. These changes add support for additional client versions and architectures.
2025-10-31 12:37:42 +08:00
手瓜一十雪 3e71e541e6 Update qqnt.json to version 9.9.22-40990
Bumped version, verHash, linuxVersion, linuxVerHash, and buildVersion fields in qqnt.json to reflect the new release 9.9.22-40990.
2025-10-31 00:11:28 +08:00
Mlikiowa bcc856d583 release: v4.9.9 2025-10-30 16:08:57 +00:00
手瓜一十雪 1eaf480a7d Add napi2native mapping for 9.9.23-41679-x64
Build Release / check-version (push) Canceled after 0s
Build Release / Build-LiteLoader (push) Canceled after 0s
Build Release / Build-Shell (push) Canceled after 0s
Build Release / release-napcat (push) Canceled after 0s
Build Release / build-docker (push) Canceled after 0s
Build Action / Build-LiteLoader (push) Canceled after 0s
Build Action / Build-Shell (push) Canceled after 0s
Introduced new send and recv address mappings for version 9.9.23-41679-x64 in napi2native.json.
2025-10-31 00:08:26 +08:00
手瓜一十雪 86123af7fc Update session instantiation and appid format
Changed session creation to use the constructor instead of the create() method in base.ts. Updated the appid.json key format from '9.9.23.41679' to '9.9.23-41679'. Added a constructor signature to NodeIQQNTWrapperSession interface. Updated NapCatWinBootHook.dll binary.
2025-10-31 00:06:31 +08:00
Mlikiowa c3cd2aaf89 release: v4.9.8 2025-10-30 14:28:31 +00:00
手瓜一十雪 599afdc7ba Add entries for version 9.9.23.41679 in appid and packet
Build Release / check-version (push) Canceled after 0s
Build Release / Build-LiteLoader (push) Canceled after 0s
Build Release / Build-Shell (push) Canceled after 0s
Build Release / release-napcat (push) Canceled after 0s
Build Release / build-docker (push) Canceled after 0s
Build Action / Build-LiteLoader (push) Canceled after 0s
Build Action / Build-Shell (push) Canceled after 0s
Updated appid.json and packet.json to include new entries for version 9.9.23.41679, specifying appid, qua, and packet send/recv values for the new version.
2025-10-30 22:24:05 +08:00
手瓜一十雪 ffe54af8d9 Fix addon path resolution and error handling
Corrects the construction of the ffmpeg addon filename and improves error handling when the addon is not found. Also simplifies the isAvailable method by removing redundant existence checks.
2025-10-30 22:13:57 +08:00
Mlikiowa a7b30ef844 release: v4.9.7 2025-10-30 13:56:19 +00:00
手瓜一十雪 50b8cb14dc Comment out packet logging in initialization
Build Action / Build-LiteLoader (push) Canceled after 0s
Build Action / Build-Shell (push) Canceled after 0s
Build Release / check-version (push) Canceled after 0s
Build Release / Build-LiteLoader (push) Canceled after 0s
Build Release / Build-Shell (push) Canceled after 0s
Build Release / release-napcat (push) Canceled after 0s
Build Release / build-docker (push) Canceled after 0s
Disabled the console logging of all packets in both NCoreInitFramework and NCoreInitShell by commenting out the nativePacketHandler.onAll debug statements. This reduces console noise during normal operation.
2025-10-30 21:55:50 +08:00
Mlikiowa 0b18f868bc release: v4.9.6 2025-10-30 13:49:11 +00:00
手瓜一十雪 c9acb9ae28 Merge branch 'main' of https://github.com/NapNeko/NapCatQQ
Build Release / check-version (push) Canceled after 0s
Build Release / Build-LiteLoader (push) Canceled after 0s
Build Release / Build-Shell (push) Canceled after 0s
Build Release / release-napcat (push) Canceled after 0s
Build Release / build-docker (push) Canceled after 0s
Build Action / Build-LiteLoader (push) Canceled after 0s
Build Action / Build-Shell (push) Canceled after 0s
2025-10-30 21:44:59 +08:00
手瓜一十雪 2e1506a05d Update native binaries for all major platforms
Rebuilt and replaced the napi2native.node binaries for Darwin ARM64, Linux ARM64, Linux x64, and Windows x64. This likely includes bug fixes, performance improvements, or compatibility updates in the native module.
2025-10-30 21:44:43 +08:00
Mlikiowa b35283f970 release: v4.9.4 2025-10-30 13:40:21 +00:00
33 changed files with 270 additions and 86 deletions

No files matched your search

Binary file not shown.
+5 -5
View File
@@ -1,9 +1,9 @@
{
"name": "qq-chat",
"verHash": "c50d6326",
"version": "9.9.22-40768",
"linuxVersion": "3.2.20-40768",
"linuxVerHash": "ab90fdfa",
"verHash": "2c9d3f6c",
"version": "9.9.22-40990",
"linuxVersion": "3.2.20-40990",
"linuxVerHash": "ec800879",
"private": true,
"description": "QQ",
"productName": "QQ",
@@ -17,7 +17,7 @@
"qd": "externals/devtools/cli/index.js"
},
"main": "./loadNapCat.js",
"buildVersion": "40768",
"buildVersion": "40990",
"isPureShell": true,
"isByteCodeShell": true,
"platform": "win32",
+1 -1
View File
@@ -4,7 +4,7 @@
"name": "NapCatQQ",
"slug": "NapCat.Framework",
"description": "高性能的 OneBot 11 协议实现",
"version": "4.8.124",
"version": "4.9.19",
"icon": "./logo.png",
"authors": [
{
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "napcat",
"private": true,
"type": "module",
"version": "4.8.124",
"version": "4.9.19",
"scripts": {
"build:universal": "npm run build:webui && vite build --mode universal || exit 1",
"build:framework": "npm run build:webui && vite build --mode framework || exit 1",
+15 -5
View File
@@ -30,7 +30,8 @@ async function handleWavFile(
): Promise<{ input: Buffer; sampleRate: number }> {
const { fmt } = getWavFileInfo(file);
if (!ALLOW_SAMPLE_RATE.includes(fmt.sampleRate)) {
return { input: await FFmpegService.convert(filePath, pcmPath), sampleRate: 24000 };
const result = await FFmpegService.convert(filePath, pcmPath);
return { input: await fsPromise.readFile(pcmPath), sampleRate: result.sampleRate };
}
return { input: file, sampleRate: fmt.sampleRate };
}
@@ -42,9 +43,18 @@ export async function encodeSilk(filePath: string, TEMP_DIR: string, logger: Log
if (!isSilk(file)) {
logger.log(`语音文件${filePath}需要转换成silk`);
const pcmPath = `${pttPath}.pcm`;
const { input, sampleRate } = isWav(file)
? await handleWavFile(file, filePath, pcmPath)
: { input: await FFmpegService.convert(filePath, pcmPath), sampleRate: 24000 };
// 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 };
let input: Buffer;
let sampleRate: number;
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 });
fsPromise.unlink(pcmPath).catch((e) => logger.logError('删除临时文件失败', pcmPath, e));
await fsPromise.writeFile(pttPath, Buffer.from(silk.data));
@@ -69,7 +79,7 @@ export async function encodeSilk(filePath: string, TEMP_DIR: string, logger: Log
};
}
} catch (error: unknown) {
logger.logError('convert silk failed', (error as Error).stack);
logger.logError('convert silk failed', error);
return {};
}
}
+1 -1
View File
@@ -49,7 +49,7 @@ export interface IFFmpegAdapter {
* @param pcmPath 输出 PCM 文件路径
* @returns PCM 数据 Buffer
*/
convertToPCM(filePath: string, pcmPath: string): Promise<Buffer>;
convertToPCM(filePath: string, pcmPath: string): Promise<{ result: boolean, sampleRate: number }>;
/**
* 转换音频文件
+7 -14
View File
@@ -20,9 +20,9 @@ function getAddonPath(binaryPath: string): string {
const archName = arch();
let addonFileName: string = process.platform + '.' + process.arch;
let addonPath = path.join(binaryPath, "./native/ffmpeg/", `${addonFileName}.node`);
if (existsSync(addonPath)) {
throw new Error(`Unsupported platform: ${platformName} ${archName}`);
let addonPath = path.join(binaryPath, "./native/ffmpeg/", `ffmpegAddon.${addonFileName}.node`);
if (!existsSync(addonPath)) {
throw new Error(`Unsupported platform: ${platformName} ${archName} - Addon not found at ${addonPath}`);
}
return addonPath;
}
@@ -44,12 +44,8 @@ export class FFmpegAddonAdapter implements IFFmpegAdapter {
*/
async isAvailable(): Promise<boolean> {
try {
const addonPath = getAddonPath(this.binaryPath);
if (!existsSync(addonPath)) {
return false;
}
let temp_addon = { exports: {} };
dlopen(temp_addon, addonPath);
dlopen(temp_addon, getAddonPath(this.binaryPath));
this.addon = temp_addon.exports as FFmpeg;
return this.addon !== null;
} catch (error) {
@@ -92,14 +88,11 @@ export class FFmpegAddonAdapter implements IFFmpegAdapter {
/**
* 转换为 PCM
*/
async convertToPCM(filePath: string, pcmPath: string): Promise<Buffer> {
async convertToPCM(filePath: string, pcmPath: string): Promise<{ result: boolean, sampleRate: number }> {
const addon = this.ensureAddon();
const result = await addon.decodeAudioToPCM(filePath);
const result = await addon.decodeAudioToPCM(filePath, pcmPath, 24000);
// 写入文件
await writeFile(pcmPath, result.pcm);
return result.pcm;
return result;
}
/**
+1 -1
View File
@@ -67,5 +67,5 @@ export interface FFmpeg {
/**
* Decode audio file to raw PCM data
*/
decodeAudioToPCM(filePath: string): Promise<AudioPCMResult>;
decodeAudioToPCM(filePath: string, pcmPath: string, sampleRate?: number): Promise<{ result: boolean, sampleRate: number }>;
}
+2 -2
View File
@@ -157,7 +157,7 @@ export class FFmpegExecAdapter implements IFFmpegAdapter {
/**
* 转换为 PCM
*/
async convertToPCM(filePath: string, pcmPath: string): Promise<Buffer> {
async convertToPCM(filePath: string, pcmPath: string): Promise<{ result: boolean, sampleRate: number }> {
try {
ensureDirExists(pcmPath);
@@ -174,7 +174,7 @@ export class FFmpegExecAdapter implements IFFmpegAdapter {
throw new Error('转换PCM失败,输出文件不存在');
}
return readFileSync(pcmPath);
return { result: true, sampleRate: 24000 };
} catch (error: any) {
throw new Error(`FFmpeg处理转换出错: ${error.message}`);
}
+1 -1
View File
@@ -93,7 +93,7 @@ export class FFmpegService {
/**
* 转换为 PCM 格式
*/
public static async convert(filePath: string, pcmPath: string): Promise<Buffer> {
public static async convert(filePath: string, pcmPath: string): Promise<{ result: boolean, sampleRate: number }> {
const adapter = await this.getAdapter();
return adapter.convertToPCM(filePath, pcmPath);
}
+1 -1
View File
@@ -1 +1 @@
export const napCatVersion = '4.8.124';
export const napCatVersion = '4.9.19';
+7 -3
View File
@@ -64,7 +64,7 @@ export class NTQQFileApi {
}
}
async getFileUrl(chatType: ChatType, peer: string, fileUUID?: string, file10MMd5?: string | undefined,timeout: number = 5000) {
async getFileUrl(chatType: ChatType, peer: string, fileUUID?: string, file10MMd5?: string | undefined, timeout: number = 5000) {
if (this.core.apis.PacketApi.packetStatus) {
try {
if (chatType === ChatType.KCHATTYPEGROUP && fileUUID) {
@@ -79,7 +79,7 @@ export class NTQQFileApi {
throw new Error('fileUUID or file10MMd5 is undefined');
}
async getPttUrl(peer: string, fileUUID?: string,timeout: number = 5000) {
async getPttUrl(peer: string, fileUUID?: string, timeout: number = 5000) {
if (this.core.apis.PacketApi.packetStatus && fileUUID) {
let appid = new NapProtoMsg(FileId).decode(Buffer.from(fileUUID.replaceAll('-', '+').replaceAll('_', '/'), 'base64')).appid;
try {
@@ -107,7 +107,7 @@ export class NTQQFileApi {
throw new Error('packet cant get ptt url');
}
async getVideoUrlPacket(peer: string, fileUUID?: string,timeout: number = 5000) {
async getVideoUrlPacket(peer: string, fileUUID?: string, timeout: number = 5000) {
if (this.core.apis.PacketApi.packetStatus && fileUUID) {
let appid = new NapProtoMsg(FileId).decode(Buffer.from(fileUUID.replaceAll('-', '+').replaceAll('_', '/'), 'base64')).appid;
try {
@@ -333,6 +333,10 @@ export class NTQQFileApi {
fileSubId: '',
playState: 1,
autoConvertText: 0,
storeID: 0,
otherBusinessInfo: {
aiVoiceType: 0
}
},
};
}
+16
View File
@@ -426,5 +426,21 @@
"3.2.20-40990": {
"appid": 537319891,
"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"
}
}
+29 -1
View File
@@ -34,5 +34,33 @@
"3.2.20-40768-arm64": {
"send": "157C0E8",
"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
View File
@@ -558,5 +558,21 @@
"6.9.82-40990-arm64": {
"send": "202A198",
"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,6 +74,36 @@ export const GroupChange = {
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 = {
groupUin: ProtoField(1, ScalarType.UINT32),
field2: ProtoField(2, ScalarType.UINT32),
+5 -1
View File
@@ -311,6 +311,10 @@ export interface PttElement {
voiceType: number;
waveAmplitudes: number[];
autoConvertText: number;
storeID: number;
otherBusinessInfo: {
aiVoiceType: number;
};
}
export type SendRecommendedMsgElement = SendElementBase<ElementType.RECOMMENDEDMSG> & ElementBase<'recommendedMsgElement'>;
@@ -349,7 +353,7 @@ export type SendPicElement = SendElementBase<ElementType.PIC> & ElementBase<'pic
export type SendPttElement = SendElementBase<ElementType.PTT> & ElementBase<'pttElement', {
pttElement: ['fileName', 'filePath', 'md5HexStr', 'fileSize', 'duration', 'formatType', 'voiceType',
'voiceChangeType', 'canConvert2Text', 'waveAmplitudes', 'fileSubId', 'playState', 'autoConvertText']
'voiceChangeType', 'canConvert2Text', 'waveAmplitudes', 'fileSubId', 'playState', 'autoConvertText', 'storeID', 'otherBusinessInfo']
}>;
export type SendFileElement = SendElementBase<ElementType.FILE> & ElementBase<'fileElement'>;
+14 -1
View File
@@ -139,8 +139,20 @@ export interface NodeQQNTWrapperUtil {
isNull(): unknown;
}
export interface NodeIQQNTStartupSessionWrapper {
create(): NodeIQQNTStartupSessionWrapper;
stop(): void;
start(): void;
createWithModuleList(uk: unknown): unknown;
getSessionIdList(): unknown;
}
export interface NodeIQQNTWrapperSession {
getNTWrapperSession(str: string): NodeIQQNTWrapperSession;
get(): NodeIQQNTWrapperSession;
new(): NodeIQQNTWrapperSession;
create(): NodeIQQNTWrapperSession;
init(
@@ -269,6 +281,7 @@ export interface WrapperNodeApi {
NodeIO3MiscService: NodeIO3MiscService;
NodeQQNTWrapperUtil: NodeQQNTWrapperUtil;
NodeIQQNTWrapperSession: NodeIQQNTWrapperSession;
NodeIQQNTStartupSessionWrapper: NodeIQQNTStartupSessionWrapper
NodeIQQNTWrapperEngine: NodeIQQNTWrapperEngine;
NodeIKernelLoginService: NodeIKernelLoginService;
+3 -3
View File
@@ -39,9 +39,9 @@ export async function NCoreInitFramework(
const basicInfoWrapper = new QQBasicInfoWrapper({ logger });
const wrapper = loadQQWrapper(basicInfoWrapper.getFullQQVersion());
const nativePacketHandler = new NativePacketHandler({ logger }); // 初始化 NativePacketHandler 用于后续使用
nativePacketHandler.onAll((packet) => {
console.log('[Packet]', packet.uin, packet.cmd, packet.hex_data);
});
// nativePacketHandler.onAll((packet) => {
// console.log('[Packet]', packet.uin, packet.cmd, packet.hex_data);
// });
await nativePacketHandler.init(basicInfoWrapper.getFullQQVersion());
// 在 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.
+4 -1
View File
@@ -28,7 +28,10 @@ export class GetGroupEssence extends OneBotAction<Payload, unknown> {
}
async _handle(payload: Payload, _adapter: string, config: NetworkAdapterConfig) {
const msglist = (await this.core.apis.WebApi.getGroupEssenceMsgAll(payload.group_id.toString())).flatMap((e) => e.data.msg_list);
const msglist = (await this.core.apis.WebApi.getGroupEssenceMsgAll(payload.group_id.toString()))
.flatMap((e) => e?.data?.msg_list)
// 在群精华回空的时候会出现[null]的情况~ https://github.com/NapNeko/NapCatQQ/issues/1334
.filter(Boolean);
if (!msglist) {
throw new Error('获取失败');
}
+47 -4
View File
@@ -24,6 +24,8 @@ import { OB11GroupUploadNoticeEvent } from '../event/notice/OB11GroupUploadNotic
import { OB11GroupNameEvent } from '../event/notice/OB11GroupNameEvent';
import { FileNapCatOneBotUUID } from '@/common/file-uuid';
import { OB11GroupIncreaseEvent } from '../event/notice/OB11GroupIncreaseEvent';
import { NapProtoMsg } from '@napneko/nap-proto-core';
import { GroupReactNotify, PushMsg } from '@/core/packet/transformer/proto';
export class OneBotGroupApi {
obContext: NapCatOneBot11Adapter;
@@ -68,6 +70,10 @@ export class OneBotGroupApi {
groupCode: string,
grayTipElement: GrayTipElement
) {
if (this.core.apis.PacketApi.packetStatus === true) {
return;
//Raw包解析支持时禁用NT解析
}
const emojiLikeData = new fastXmlParser.XMLParser({
ignoreAttributes: false,
attributeNamePrefix: '',
@@ -76,7 +82,7 @@ export class OneBotGroupApi {
const senderUin = emojiLikeData.gtip.qq.jp;
const msgSeq = emojiLikeData.gtip.url.msgseq;
const emojiId = emojiLikeData.gtip.face.id;
return await this.createGroupEmojiLikeEvent(groupCode, senderUin, msgSeq, emojiId);
return await this.createGroupEmojiLikeEvent(groupCode, senderUin, msgSeq, emojiId, true, 1);
}
async createGroupEmojiLikeEvent(
@@ -84,6 +90,8 @@ export class OneBotGroupApi {
senderUin: string,
msgSeq: string,
emojiId: string,
isAdd: boolean = true,
count: number = 1,
) {
const peer = {
chatType: ChatType.KCHATTYPEGROUP,
@@ -103,11 +111,13 @@ export class OneBotGroupApi {
this.core,
parseInt(groupCode),
parseInt(senderUin),
MessageUnique.getShortIdByMsgId(replyMsg.msgId)!,
MessageUnique.createUniqueMsgId({ chatType: ChatType.KCHATTYPEGROUP, guildId: '', peerUid: groupCode }, replyMsg.msgId),
[{
emoji_id: emojiId,
count: 1,
count: count,
}],
isAdd,
msgSeq
);
}
@@ -126,7 +136,40 @@ export class OneBotGroupApi {
}
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) {
const json = JSON.parse(jsonStr);
//判断业务类型
+1 -1
View File
@@ -1182,7 +1182,7 @@ export class OneBotMsgApi {
}, returnMsg.msgId);
return returnMsg;
} catch (error) {
throw new Error((error as Error).message);
throw error;
} finally {
cleanTaskQueue.addFiles(deleteAfterSentFiles, timeout);
// setTimeout(async () => {
@@ -10,12 +10,15 @@ export class OB11GroupMsgEmojiLikeEvent extends OB11GroupNoticeEvent {
notice_type = 'group_msg_emoji_like';
message_id: number;
likes: MsgEmojiLike[];
is_add: boolean;
message_seq?: string;
constructor(core: NapCatCore, groupId: number, userId: number, messageId: number, likes: MsgEmojiLike[]) {
constructor(core: NapCatCore, groupId: number, userId: number, messageId: number, likes: MsgEmojiLike[], isAdd: boolean, messageSeq?: string) {
super(core, groupId, userId);
this.group_id = groupId;
this.user_id = userId; // 可为空,表示是对别人的消息操作,如果是对bot自己的消息则不为空
this.message_id = messageId;
this.likes = likes;
this.is_add = isAdd;
}
}
+28 -25
View File
@@ -66,7 +66,7 @@ export class NapCatOneBot11Adapter {
actions: ActionMap;
private readonly bootTime = Date.now() / 1000;
recallEventCache = new Map<string, NodeJS.Timeout>();
constructor (core: NapCatCore, context: InstanceContext, pathWrapper: NapCatPathWrapper) {
constructor(core: NapCatCore, context: InstanceContext, pathWrapper: NapCatPathWrapper) {
this.core = core;
this.context = context;
this.configLoader = new OB11ConfigLoader(core, pathWrapper.configPath, OneBotConfigSchema);
@@ -80,7 +80,7 @@ export class NapCatOneBot11Adapter {
this.actions = createActionMap(this, core);
this.networkManager = new OB11NetworkManager();
}
async creatOneBotLog (ob11Config: OneBotConfig) {
async creatOneBotLog(ob11Config: OneBotConfig) {
let log = '[network] 配置加载\n';
for (const key of ob11Config.network.httpServers) {
log += `HTTP服务: ${key.host}:${key.port}, : ${key.enable ? '已启动' : '未启动'}\n`;
@@ -99,14 +99,14 @@ export class NapCatOneBot11Adapter {
}
return log;
}
async InitOneBot () {
async InitOneBot() {
const selfInfo = this.core.selfInfo;
const ob11Config = this.configLoader.configData;
this.core.apis.UserApi.getUserDetailInfo(selfInfo.uid, false)
.then(async (user) => {
selfInfo.nick = user.nick;
this.context.logger.setLogSelfInfo(selfInfo);
// 检查是否有待发送的token
if (pendingTokenToSend) {
this.context.logger.log('[NapCat] [OneBot] 🔐 检测到待发送的WebUI Token,开始发送');
@@ -117,10 +117,10 @@ export class NapCatOneBot11Adapter {
elementType: ElementType.TEXT,
elementId: '',
textElement: {
content:
'[NapCat] 温馨提示:\n'+
'WebUI密码为默认密码,已进行强制修改\n'+
'新密码: ' +pendingTokenToSend,
content:
'[NapCat] 温馨提示:\n' +
'WebUI密码为默认密码,已进行强制修改\n' +
'新密码: ' + pendingTokenToSend,
atType: NTMsgAtType.ATTYPEUNKNOWN,
atUid: '',
atTinyId: '',
@@ -134,7 +134,7 @@ export class NapCatOneBot11Adapter {
this.context.logger.logError('[NapCat] [OneBot] ❌ WebUI Token 消息发送失败:', error);
}
}
WebUiDataRuntime.getQQLoginCallback()(true);
})
.catch(e => this.context.logger.logError(e));
@@ -216,10 +216,13 @@ export class NapCatOneBot11Adapter {
//this.context.logger.log(`OneBot11 配置更改:${JSON.stringify(prev)} -> ${JSON.stringify(newConfig)}`);
await this.reloadNetwork(prev, newConfig);
});
this.apis.GroupApi.registerParseGroupReactEvent().catch(e =>
this.context.logger.logError('注册群消息反应表情失败', e)
);
}
private async reloadNetwork (prev: OneBotConfig, now: OneBotConfig): Promise<void> {
private async reloadNetwork(prev: OneBotConfig, now: OneBotConfig): Promise<void> {
const prevLog = await this.creatOneBotLog(prev);
const newLog = await this.creatOneBotLog(now);
this.context.logger.log(`[Notice] [OneBot11] 配置变更前:\n${prevLog}`);
@@ -232,7 +235,7 @@ export class NapCatOneBot11Adapter {
await this.handleConfigChange(prev.network.websocketClients, now.network.websocketClients, OB11WebSocketClientAdapter);
}
private async handleConfigChange<CT extends NetworkAdapterConfig> (
private async handleConfigChange<CT extends NetworkAdapterConfig>(
prevConfig: NetworkAdapterConfig[],
nowConfig: NetworkAdapterConfig[],
adapterClass: new (
@@ -264,7 +267,7 @@ export class NapCatOneBot11Adapter {
}
}
private initMsgListener () {
private initMsgListener() {
const msgListener = new NodeIKernelMsgListener();
msgListener.onRecvSysMsg = (msg) => {
this.apis.MsgApi.parseSysMessage(msg)
@@ -378,7 +381,7 @@ export class NapCatOneBot11Adapter {
this.context.session.getMsgService().addKernelMsgListener(proxiedListenerOf(msgListener, this.context.logger));
}
private initBuddyListener () {
private initBuddyListener() {
const buddyListener = new NodeIKernelBuddyListener();
buddyListener.onBuddyReqChange = async (reqs) => {
@@ -409,7 +412,7 @@ export class NapCatOneBot11Adapter {
.addKernelBuddyListener(proxiedListenerOf(buddyListener, this.context.logger));
}
private initGroupListener () {
private initGroupListener() {
const groupListener = new NodeIKernelGroupListener();
groupListener.onGroupNotifiesUpdated = async (_, notifies) => {
@@ -502,7 +505,7 @@ export class NapCatOneBot11Adapter {
.addKernelGroupListener(proxiedListenerOf(groupListener, this.context.logger));
}
private async emitMsg (message: RawMessage) {
private async emitMsg(message: RawMessage) {
const network = await this.networkManager.getAllConfig();
this.context.logger.logDebug('收到新消息 RawMessage', message);
await Promise.allSettled([
@@ -511,7 +514,7 @@ export class NapCatOneBot11Adapter {
]);
}
private async handleMsg (message: RawMessage, network: Array<NetworkAdapterConfig>) {
private async handleMsg(message: RawMessage, network: Array<NetworkAdapterConfig>) {
// 过滤无效消息
if (message.msgType === NTMsgType.KMSGTYPENULL) {
return;
@@ -532,7 +535,7 @@ export class NapCatOneBot11Adapter {
}
}
private isSelfMessage (ob11Msg: {
private isSelfMessage(ob11Msg: {
stringMsg: OB11Message
arrayMsg: OB11Message
}): boolean {
@@ -540,7 +543,7 @@ export class NapCatOneBot11Adapter {
ob11Msg.arrayMsg.user_id.toString() == this.core.selfInfo.uin;
}
private createMsgMap (network: Array<NetworkAdapterConfig>, ob11Msg: {
private createMsgMap(network: Array<NetworkAdapterConfig>, ob11Msg: {
stringMsg: OB11Message
arrayMsg: OB11Message
}, isSelfMsg: boolean, message: RawMessage): Map<string, OB11Message> {
@@ -560,7 +563,7 @@ export class NapCatOneBot11Adapter {
return msgMap;
}
private handleDebugNetwork (network: Array<NetworkAdapterConfig>, msgMap: Map<string, OB11Message>, message: RawMessage) {
private handleDebugNetwork(network: Array<NetworkAdapterConfig>, msgMap: Map<string, OB11Message>, message: RawMessage) {
const debugNetwork = network.filter(e => e.enable && e.debug);
if (debugNetwork.length > 0) {
debugNetwork.forEach(adapter => {
@@ -574,7 +577,7 @@ export class NapCatOneBot11Adapter {
}
}
private handleNotReportSelfNetwork (network: Array<NetworkAdapterConfig>, msgMap: Map<string, OB11Message>, isSelfMsg: boolean) {
private handleNotReportSelfNetwork(network: Array<NetworkAdapterConfig>, msgMap: Map<string, OB11Message>, isSelfMsg: boolean) {
if (isSelfMsg) {
const notReportSelfNetwork = network.filter(e => e.enable && (('reportSelfMessage' in e && !e.reportSelfMessage) || !('reportSelfMessage' in e)));
notReportSelfNetwork.forEach(adapter => {
@@ -583,7 +586,7 @@ export class NapCatOneBot11Adapter {
}
}
private async handleGroupEvent (message: RawMessage) {
private async handleGroupEvent(message: RawMessage) {
try {
// 群名片修改事件解析 任何都该判断
if (message.senderUin && message.senderUin !== '0') {
@@ -616,7 +619,7 @@ export class NapCatOneBot11Adapter {
}
}
private async handlePrivateMsgEvent (message: RawMessage) {
private async handlePrivateMsgEvent(message: RawMessage) {
try {
if (message.msgType === NTMsgType.KMSGTYPEGRAYTIPS) {
// 灰条为单元素消息
@@ -634,7 +637,7 @@ export class NapCatOneBot11Adapter {
}
}
private async emitRecallMsg (message: RawMessage, element: MessageElement) {
private async emitRecallMsg(message: RawMessage, element: MessageElement) {
const peer: Peer = { chatType: message.chatType, peerUid: message.peerUid, guildId: '' };
const oriMessageId = MessageUnique.getShortIdByMsgId(message.msgId) ?? MessageUnique.createUniqueMsgId(peer, message.msgId);
if (message.chatType == ChatType.KCHATTYPEC2C) {
@@ -645,7 +648,7 @@ export class NapCatOneBot11Adapter {
return;
}
private async emitFriendRecallMsg (message: RawMessage, oriMessageId: number, element: MessageElement) {
private async emitFriendRecallMsg(message: RawMessage, oriMessageId: number, element: MessageElement) {
const operatorUid = element.grayTipElement?.revokeElement.operatorUid;
if (!operatorUid) return undefined;
return new OB11FriendRecallNoticeEvent(
@@ -655,7 +658,7 @@ export class NapCatOneBot11Adapter {
);
}
private async emitGroupRecallMsg (message: RawMessage, oriMessageId: number, element: MessageElement) {
private async emitGroupRecallMsg(message: RawMessage, oriMessageId: number, element: MessageElement) {
const operatorUid = element.grayTipElement?.revokeElement.operatorUid;
if (!operatorUid) return undefined;
const operatorId = await this.core.apis.UserApi.getUinByUidV2(operatorUid);
+31 -13
View File
@@ -10,6 +10,7 @@ import {
loadQQWrapper,
NapCatCore,
NapCatCoreWorkingEnv,
NodeIQQNTStartupSessionWrapper,
NodeIQQNTWrapperEngine,
NodeIQQNTWrapperSession,
PlatformType,
@@ -242,7 +243,8 @@ async function handleLoginInner(context: { isLogined: boolean }, logger: LogWrap
async function initializeSession(
session: NodeIQQNTWrapperSession,
sessionConfig: WrapperSessionInitConfig
sessionConfig: WrapperSessionInitConfig,
startupSession: NodeIQQNTStartupSessionWrapper | null
) {
return new Promise<void>((resolve, reject) => {
const sessionListener = new NodeIKernelSessionListener();
@@ -259,13 +261,17 @@ async function initializeSession(
new NodeIDispatcherAdapter(),
sessionListener,
);
try {
session.startNT(0);
} catch {
if (startupSession) {
startupSession.start();
} else {
try {
session.startNT();
} catch (e: unknown) {
reject(new Error('init failed ' + (e as Error).message));
session.startNT(0);
} catch {
try {
session.startNT();
} catch (e: unknown) {
reject(new Error('init failed ' + (e as Error).message));
}
}
}
});
@@ -322,9 +328,9 @@ export async function NCoreInitShell() {
const wrapper = loadQQWrapper(basicInfoWrapper.getFullQQVersion());
const nativePacketHandler = new NativePacketHandler({ logger }); // 初始化 NativePacketHandler 用于后续使用
nativePacketHandler.onAll((packet) => {
console.log('[Packet]', packet.uin, packet.cmd, packet.hex_data);
});
// nativePacketHandler.onAll((packet) => {
// console.log('[Packet]', packet.uin, packet.cmd, packet.hex_data);
// });
await nativePacketHandler.init(basicInfoWrapper.getFullQQVersion());
const o3Service = wrapper.NodeIO3MiscService.get();
@@ -335,8 +341,20 @@ export async function NCoreInitShell() {
const engine = wrapper.NodeIQQNTWrapperEngine.get();
const loginService = wrapper.NodeIKernelLoginService.get();
const session = wrapper.NodeIQQNTWrapperSession.create();
let session: NodeIQQNTWrapperSession;
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 systemPlatform = getPlatformType();
@@ -370,7 +388,7 @@ export async function NCoreInitShell() {
dataPath,
);
await initializeSession(session, sessionConfig);
await initializeSession(session, sessionConfig, startupSession);
const accountDataPath = path.resolve(dataPath, './NapCat/data');
//判断dataPath是否为根目录 或者 D:/ 之类的盘目录