From 89c102513d063504a537e27ac95c572294493dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Fri, 23 Aug 2024 10:55:19 +0800 Subject: [PATCH 1/7] release: 2.2.0 --- .github/workflows/release.yml | 82 ++++----- manifest.json | 2 +- package.json | 4 +- src/common/framework/napcat.ts | 2 +- src/framework/napcat.cjs | 158 +++++++++++------- .../msg/SendMsg/create-send-elements.ts | 2 +- src/webui/ui/NapCat.ts | 2 +- static/assets/renderer.js | 2 +- 8 files changed, 146 insertions(+), 108 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c9d98f52..2a266175 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,34 +30,34 @@ jobs: ls node ./script/checkVersion.cjs sh ./checkVersion.sh - # Build-LiteLoader: - # needs: [check-version] - # runs-on: ubuntu-latest - # steps: - # - name: Clone Main Repository - # uses: actions/checkout@v4 - # with: - # repository: 'NapNeko/NapCatQQ' - # submodules: true - # ref: main - # token: ${{ secrets.NAPCAT_BUILD }} - # - name: Use Node.js 20.X - # uses: actions/setup-node@v4 - # with: - # node-version: 20.x + Build-LiteLoader: + needs: [check-version] + runs-on: ubuntu-latest + steps: + - name: Clone Main Repository + uses: actions/checkout@v4 + with: + repository: 'NapNeko/NapCatQQ' + submodules: true + ref: main + token: ${{ secrets.NAPCAT_BUILD }} + - name: Use Node.js 20.X + uses: actions/setup-node@v4 + with: + node-version: 20.x - # - name: Build NuCat Framework - # run: | - # npm i - # npm run build:framework - # cd dist - # npm i --omit=dev - # cd .. - # - name: Upload Artifact - # uses: actions/upload-artifact@v4 - # with: - # name: NapCat.Framework - # path: dist + - name: Build NuCat Framework + run: | + npm i + npm run build:framework + cd dist + npm i --omit=dev + cd .. + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: NapCat.Framework + path: dist Build-Shell: runs-on: ubuntu-latest needs: [check-version] @@ -90,31 +90,30 @@ jobs: path: dist release-napcat: - needs: [Build-Shell] - # needs: [Build-LiteLoader,Build-Shell] + needs: [Build-LiteLoader,Build-Shell] runs-on: ubuntu-latest steps: - name: Download All Artifact uses: actions/download-artifact@v4 - - name: Compress subdirectories - run: | - cd ./NapCat.Shell/ - zip -q -r NapCat.Shell.zip * - cd .. - rm ./NapCat.Shell.zip -rf - mv ./NapCat.Shell/NapCat.Shell.zip ./ # - name: Compress subdirectories # run: | # cd ./NapCat.Shell/ # zip -q -r NapCat.Shell.zip * # cd .. - # cd ./NapCat.Framework/ - # zip -q -r NapCat.Framework.zip * - # cd .. # rm ./NapCat.Shell.zip -rf - # rm ./NapCat.Framework.zip -rf # mv ./NapCat.Shell/NapCat.Shell.zip ./ - # mv ./NapCat.Framework/NapCat.Framework.zip ./ + - name: Compress subdirectories + run: | + cd ./NapCat.Shell/ + zip -q -r NapCat.Shell.zip * + cd .. + cd ./NapCat.Framework/ + zip -q -r NapCat.Framework.zip * + cd .. + rm ./NapCat.Shell.zip -rf + rm ./NapCat.Framework.zip -rf + mv ./NapCat.Shell/NapCat.Shell.zip ./ + mv ./NapCat.Framework/NapCat.Framework.zip ./ - name: Extract version from tag run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV @@ -128,5 +127,6 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} body_path: CHANGELOG.md files: | + NapCat.Framework.zip NapCat.Shell.zip draft: true diff --git a/manifest.json b/manifest.json index 3651ede8..daa2e81c 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "NapCatQQ", "slug": "NapCat.Framework", "description": "高性能的 OneBot 11 协议实现", - "version": "2.1.0", + "version": "2.2.0", "icon": "./logo.png", "authors": [ { diff --git a/package.json b/package.json index c5703aeb..282db17c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "napcat", "private": true, "type": "module", - "version": "2.1.0", + "version": "2.2.0", "scripts": { "build:framework": "vite build --mode framework", "build:shell": "vite build --mode shell", @@ -48,7 +48,7 @@ "ajv": "^8.13.0", "async-mutex": "^0.5.0", "chalk": "^5.3.0", - "commander": "^12.1.0", + "commander": "^12.2.0", "cors": "^2.8.5", "express": "^5.0.0-beta.2", "fast-xml-parser": "^4.3.6", diff --git a/src/common/framework/napcat.ts b/src/common/framework/napcat.ts index d485050c..b4122f90 100644 --- a/src/common/framework/napcat.ts +++ b/src/common/framework/napcat.ts @@ -2,7 +2,7 @@ import path, { dirname } from 'path'; import { fileURLToPath } from 'url'; import fs from 'fs'; -export const napcat_version = '2.1.0'; +export const napcat_version = '2.2.0'; export class NapCatPathWrapper { binaryPath: string; diff --git a/src/framework/napcat.cjs b/src/framework/napcat.cjs index fa6fd273..d309ec43 100644 --- a/src/framework/napcat.cjs +++ b/src/framework/napcat.cjs @@ -1,82 +1,120 @@ -// https://github.com/NapNeko/LiteLoader-NapCatExample/blob/main/src/common/proxy.ts -// By Mlikiowa +// 用于 NapCat 对QQ流程分析 +let Process = require('process'); +let os = require('os'); +let path = require('path'); +Process.dlopenOrig = Process.dlopen; -const process = require('process'); -const os = require('os'); -const path = require('path'); +let RealWrapper; +let loginService; +//Fuck LoginService +class LoginService { + constructor() { + console.log('[NapCat] Fuck LoginService Loading...'); + } +} + +//NapCat 专有逻辑 +let initCallBack; +let wrapperSession; +let wrapperLoginService; const currentPath = path.dirname(__filename); -const dlopenOrig = process.dlopen; +function CreateFuckService(ServiceName) { + return new Proxy(() => { }, { + get: function (target, FunctionName, receiver) { + console.log("Proxy... Event:", ServiceName + '/' + FunctionName); + if (ServiceName == 'NodeIKernelLoginService' && FunctionName == 'get') { + return function () { + let ret = new Proxy(new LoginService(), { + get: function (target, ClassFunName, receiver) { + return function () { + let ret = loginService[ClassFunName](...arguments); + // if (ret instanceof Promise) { + // ret.then((data) => { + // console.log("Called ", '实例方法 NodeIKernelLoginService/' + ClassFunName, ' 参数:', ...arguments, '返回:', data); + // }); + // } else { + // console.log("Called ", '实例方法 NodeIKernelLoginService/' + ClassFunName, ' 参数:', ...arguments, '返回:', ret); + // } + return ret; + } -let wrapperSession; -let wrapperNodeApi; -let wrapperLoginService; -let initCallBack; + } + }) + return ret; + } + } -// Proxy dlopen -process.dlopen = (module, filename, flags = os.constants.dlopen.RTLD_LAZY) => { - dlopenOrig(module, filename, flags); - for (const export_name in module.exports) { - module.exports[export_name] = new Proxy(module.exports[export_name], { - construct: (target, args, _newTarget) => { - let constructed; - if (export_name === 'NodeIKernelSessionListener') { - let HookedArg = []; - for (let ArgIndex in args) { - if (args[ArgIndex] instanceof Object) { - let HookArg = {}; - for (let ListenerName in args[ArgIndex]) { - HookArg[ListenerName] = function (...ListenerData) { - try { - if (ListenerName === 'onSessionInitComplete') { - //回调成功 - initCallBack.forEach((cb) => cb(...ListenerData)); + if (ServiceName == 'NodeIQQNTWrapperSession' && FunctionName == 'create') { + return new Proxy(() => { }, { + apply: function (target, thisArg, argArray) { + let Session = RealWrapper.NodeIQQNTWrapperSession[FunctionName](...argArray); + //传递Session + wrapperSession = Session; + + let ret = new Proxy(Session, { + get: function (target, ClassFunName, receiver) { + return function () { + if (ClassFunName == 'init') { + let origin = arguments[3].onSessionInitComplete; + arguments[3].onSessionInitComplete = function () { + //console.log("Listner ", '注册方法 NodeIKernelSessionListener/onSessionInitComplete', ' 参数:', ...arguments); + origin(...arguments); + initCallBack.forEach((cb) => cb(...arguments)); clearHook(); } - //console.log("Construct-ARG-Apply", ListenerName, JSON.stringify(ListenerData, null, 2)); - } catch (error) { - // ignored } - args[ArgIndex][ListenerName](...ListenerData); - }; - HookedArg.push(HookArg); + let ret = Session[ClassFunName](...arguments); + // if (ret instanceof Promise) { + // ret.then((data) => { + // console.log("Called ", '实例方法 NodeIQQNTWrapperSession/' + ClassFunName, ' 参数:', ...arguments, '返回:', data); + // }); + // } else { + // console.log("Called ", '实例方法 NodeIQQNTWrapperSession/' + ClassFunName, ' 参数:', ...arguments, '返回:', ret); + // } + + return ret; + } + } - } else { - // 其它类型 - //console.log("Construct-ARG-NotProxy", args[keyArg]); - } - + }); + return ret; } - constructed = new target(...HookedArg); - } else { - constructed = new target(...args); - } - - if (export_name === 'NodeIQQNTWrapperSession') wrapperSession = constructed; - if (export_name === 'NodeIKernelLoginService') wrapperLoginService = constructed; - - return constructed; - }, - }); - } - if (filename.toLowerCase().includes('wrapper.node')) { - wrapperNodeApi = module.exports; + }); + } + } } + ); +} +Process.dlopen = function (module, filename, flags = os.constants.dlopen.RTLD_LAZY) { + let dlopenRet = this.dlopenOrig(module, filename, flags); + if (filename.indexOf('wrapper.node') == -1) return dlopenRet; + //仅对Wrapper.node进行处理 + RealWrapper = module.exports; + //先行获取LoginService操作权 + loginService = new RealWrapper.NodeIKernelLoginService(); + wrapperLoginService = loginService; + //开始针对性处理 + module.exports = new Proxy({}, { + get: function (target, ServiceName, receiver) { + if (ServiceName == 'NodeIKernelLoginService') return CreateFuckService(ServiceName); + if (ServiceName == 'NodeIQQNTWrapperSession') return CreateFuckService(ServiceName); + return RealWrapper[ServiceName]; + } + }); + //返回预先构造的对象 + return dlopenRet; }; -/** - * 清理 Hook - */ +//辅助函数 function clearHook() { initCallBack = []; process.dlopen = dlopenOrig; } function ntIsInitialized_Internal() { - return wrapperSession !== undefined - && wrapperNodeApi !== undefined - && wrapperLoginService !== undefined; + return wrapperSession !== undefined; } function pollForNTInitializationCheck() { @@ -111,7 +149,7 @@ async function fetchServices(timeout = 10000) { setTimeout(() => resolve(false), timeout); }), ]).then(result => result ? - { wrapperSession, wrapperNodeApi, wrapperLoginService } : + { wrapperSession, wrapperLoginService } : Promise.reject("fetchServices Timeout!"), ); } diff --git a/src/onebot/action/msg/SendMsg/create-send-elements.ts b/src/onebot/action/msg/SendMsg/create-send-elements.ts index b4c657c6..57bdeee3 100644 --- a/src/onebot/action/msg/SendMsg/create-send-elements.ts +++ b/src/onebot/action/msg/SendMsg/create-send-elements.ts @@ -171,7 +171,7 @@ const _handlers: { } else { postData = data; } - // Mlikiowa V2.1.0 Refactor Todo + // Mlikiowa V2.2.0 Refactor Todo const signUrl = obContext.configLoader.configData.musicSignUrl; if (!signUrl) { if (data.type === 'qq') { diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index 868e1dd9..662b0d10 100644 --- a/src/webui/ui/NapCat.ts +++ b/src/webui/ui/NapCat.ts @@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) { SettingItem( 'Napcat', undefined, - SettingButton('V2.1.0', 'napcat-update-button', 'secondary'), + SettingButton('V2.2.0', 'napcat-update-button', 'secondary'), ), ]), SettingList([ diff --git a/static/assets/renderer.js b/static/assets/renderer.js index 335369e1..fff53bd2 100644 --- a/static/assets/renderer.js +++ b/static/assets/renderer.js @@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) { SettingItem( 'Napcat', void 0, - SettingButton("V2.1.0", "napcat-update-button", "secondary") + SettingButton("V2.2.0", "napcat-update-button", "secondary") ) ]), SettingList([ From 9ad511a9c01825f7ec95a3f8b09f069c29c23a58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Fri, 23 Aug 2024 10:57:13 +0800 Subject: [PATCH 2/7] release: 2.2.1 --- manifest.json | 2 +- package.json | 4 ++-- src/common/framework/napcat.ts | 2 +- src/core/external/appid.json | 4 ++++ src/framework/napcat.cjs | 3 ++- src/onebot/action/msg/SendMsg/create-send-elements.ts | 2 +- src/webui/ui/NapCat.ts | 2 +- static/assets/renderer.js | 2 +- 8 files changed, 13 insertions(+), 8 deletions(-) diff --git a/manifest.json b/manifest.json index daa2e81c..23cbdb29 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "NapCatQQ", "slug": "NapCat.Framework", "description": "高性能的 OneBot 11 协议实现", - "version": "2.2.0", + "version": "2.2.1", "icon": "./logo.png", "authors": [ { diff --git a/package.json b/package.json index 282db17c..3b50c87c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "napcat", "private": true, "type": "module", - "version": "2.2.0", + "version": "2.2.1", "scripts": { "build:framework": "vite build --mode framework", "build:shell": "vite build --mode shell", @@ -48,7 +48,7 @@ "ajv": "^8.13.0", "async-mutex": "^0.5.0", "chalk": "^5.3.0", - "commander": "^12.2.0", + "commander": "^12.2.1", "cors": "^2.8.5", "express": "^5.0.0-beta.2", "fast-xml-parser": "^4.3.6", diff --git a/src/common/framework/napcat.ts b/src/common/framework/napcat.ts index b4122f90..65ce3300 100644 --- a/src/common/framework/napcat.ts +++ b/src/common/framework/napcat.ts @@ -2,7 +2,7 @@ import path, { dirname } from 'path'; import { fileURLToPath } from 'url'; import fs from 'fs'; -export const napcat_version = '2.2.0'; +export const napcat_version = '2.2.1'; export class NapCatPathWrapper { binaryPath: string; diff --git a/src/core/external/appid.json b/src/core/external/appid.json index 0cce792c..7f72b675 100644 --- a/src/core/external/appid.json +++ b/src/core/external/appid.json @@ -22,5 +22,9 @@ "9.9.15-27254":{ "appid": 537240709, "qua": "V1_WIN_NQ_9.9.15_27254_GW_B" + }, + "9.9.15-27333": { + "appid": 537240709, + "qua": "V1_WIN_NQ_9.9.15_27333_GW_B" } } \ No newline at end of file diff --git a/src/framework/napcat.cjs b/src/framework/napcat.cjs index d309ec43..fb85cafc 100644 --- a/src/framework/napcat.cjs +++ b/src/framework/napcat.cjs @@ -1,4 +1,5 @@ -// 用于 NapCat 对QQ流程分析 +// 此代码禁止除NapCat外任何地方使用 使用需获取许可 + let Process = require('process'); let os = require('os'); let path = require('path'); diff --git a/src/onebot/action/msg/SendMsg/create-send-elements.ts b/src/onebot/action/msg/SendMsg/create-send-elements.ts index 57bdeee3..226023df 100644 --- a/src/onebot/action/msg/SendMsg/create-send-elements.ts +++ b/src/onebot/action/msg/SendMsg/create-send-elements.ts @@ -171,7 +171,7 @@ const _handlers: { } else { postData = data; } - // Mlikiowa V2.2.0 Refactor Todo + // Mlikiowa V2.2.1 Refactor Todo const signUrl = obContext.configLoader.configData.musicSignUrl; if (!signUrl) { if (data.type === 'qq') { diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index 662b0d10..2c50f629 100644 --- a/src/webui/ui/NapCat.ts +++ b/src/webui/ui/NapCat.ts @@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) { SettingItem( 'Napcat', undefined, - SettingButton('V2.2.0', 'napcat-update-button', 'secondary'), + SettingButton('V2.2.1', 'napcat-update-button', 'secondary'), ), ]), SettingList([ diff --git a/static/assets/renderer.js b/static/assets/renderer.js index fff53bd2..cf18cab1 100644 --- a/static/assets/renderer.js +++ b/static/assets/renderer.js @@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) { SettingItem( 'Napcat', void 0, - SettingButton("V2.2.0", "napcat-update-button", "secondary") + SettingButton("V2.2.1", "napcat-update-button", "secondary") ) ]), SettingList([ From 509390af200cc5f9d7c4f2db29c33646965b2213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Fri, 23 Aug 2024 11:01:24 +0800 Subject: [PATCH 3/7] release: 2.2.2 --- manifest.json | 2 +- package.json | 4 ++-- src/common/framework/napcat.ts | 2 +- src/onebot/action/msg/SendMsg/create-send-elements.ts | 2 +- src/webui/ui/NapCat.ts | 2 +- static/assets/renderer.js | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/manifest.json b/manifest.json index 23cbdb29..bee47adb 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "NapCatQQ", "slug": "NapCat.Framework", "description": "高性能的 OneBot 11 协议实现", - "version": "2.2.1", + "version": "2.2.2", "icon": "./logo.png", "authors": [ { diff --git a/package.json b/package.json index 3b50c87c..6a62f2c3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "napcat", "private": true, "type": "module", - "version": "2.2.1", + "version": "2.2.2", "scripts": { "build:framework": "vite build --mode framework", "build:shell": "vite build --mode shell", @@ -48,7 +48,7 @@ "ajv": "^8.13.0", "async-mutex": "^0.5.0", "chalk": "^5.3.0", - "commander": "^12.2.1", + "commander": "^12.1.0", "cors": "^2.8.5", "express": "^5.0.0-beta.2", "fast-xml-parser": "^4.3.6", diff --git a/src/common/framework/napcat.ts b/src/common/framework/napcat.ts index 65ce3300..2a16c0f3 100644 --- a/src/common/framework/napcat.ts +++ b/src/common/framework/napcat.ts @@ -2,7 +2,7 @@ import path, { dirname } from 'path'; import { fileURLToPath } from 'url'; import fs from 'fs'; -export const napcat_version = '2.2.1'; +export const napcat_version = '2.2.2'; export class NapCatPathWrapper { binaryPath: string; diff --git a/src/onebot/action/msg/SendMsg/create-send-elements.ts b/src/onebot/action/msg/SendMsg/create-send-elements.ts index 226023df..14410e69 100644 --- a/src/onebot/action/msg/SendMsg/create-send-elements.ts +++ b/src/onebot/action/msg/SendMsg/create-send-elements.ts @@ -171,7 +171,7 @@ const _handlers: { } else { postData = data; } - // Mlikiowa V2.2.1 Refactor Todo + // Mlikiowa V2.2.2 Refactor Todo const signUrl = obContext.configLoader.configData.musicSignUrl; if (!signUrl) { if (data.type === 'qq') { diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index 2c50f629..5a4dd8a1 100644 --- a/src/webui/ui/NapCat.ts +++ b/src/webui/ui/NapCat.ts @@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) { SettingItem( 'Napcat', undefined, - SettingButton('V2.2.1', 'napcat-update-button', 'secondary'), + SettingButton('V2.2.2', 'napcat-update-button', 'secondary'), ), ]), SettingList([ diff --git a/static/assets/renderer.js b/static/assets/renderer.js index cf18cab1..30c78a57 100644 --- a/static/assets/renderer.js +++ b/static/assets/renderer.js @@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) { SettingItem( 'Napcat', void 0, - SettingButton("V2.2.1", "napcat-update-button", "secondary") + SettingButton("V2.2.2", "napcat-update-button", "secondary") ) ]), SettingList([ From 3b5e6553cd599b700af645ef501d077079cf0993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Fri, 23 Aug 2024 11:04:47 +0800 Subject: [PATCH 4/7] chore --- src/framework/napcat.cjs | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/src/framework/napcat.cjs b/src/framework/napcat.cjs index fb85cafc..fc31d5a5 100644 --- a/src/framework/napcat.cjs +++ b/src/framework/napcat.cjs @@ -1,4 +1,8 @@ -// 此代码禁止除NapCat外任何地方使用 使用需获取许可 +/** + * @description 此代码禁止除NapCat外任何地方使用 使用需获取许可 + *@author: Mlikiowa + *@date: 2024-08-23 + */ let Process = require('process'); let os = require('os'); @@ -8,14 +12,12 @@ Process.dlopenOrig = Process.dlopen; let RealWrapper; let loginService; -//Fuck LoginService class LoginService { constructor() { console.log('[NapCat] Fuck LoginService Loading...'); } } -//NapCat 专有逻辑 let initCallBack; let wrapperSession; let wrapperLoginService; @@ -31,13 +33,6 @@ function CreateFuckService(ServiceName) { get: function (target, ClassFunName, receiver) { return function () { let ret = loginService[ClassFunName](...arguments); - // if (ret instanceof Promise) { - // ret.then((data) => { - // console.log("Called ", '实例方法 NodeIKernelLoginService/' + ClassFunName, ' 参数:', ...arguments, '返回:', data); - // }); - // } else { - // console.log("Called ", '实例方法 NodeIKernelLoginService/' + ClassFunName, ' 参数:', ...arguments, '返回:', ret); - // } return ret; } @@ -60,21 +55,12 @@ function CreateFuckService(ServiceName) { if (ClassFunName == 'init') { let origin = arguments[3].onSessionInitComplete; arguments[3].onSessionInitComplete = function () { - //console.log("Listner ", '注册方法 NodeIKernelSessionListener/onSessionInitComplete', ' 参数:', ...arguments); origin(...arguments); initCallBack.forEach((cb) => cb(...arguments)); clearHook(); } } let ret = Session[ClassFunName](...arguments); - // if (ret instanceof Promise) { - // ret.then((data) => { - // console.log("Called ", '实例方法 NodeIQQNTWrapperSession/' + ClassFunName, ' 参数:', ...arguments, '返回:', data); - // }); - // } else { - // console.log("Called ", '实例方法 NodeIQQNTWrapperSession/' + ClassFunName, ' 参数:', ...arguments, '返回:', ret); - // } - return ret; } @@ -91,12 +77,9 @@ function CreateFuckService(ServiceName) { Process.dlopen = function (module, filename, flags = os.constants.dlopen.RTLD_LAZY) { let dlopenRet = this.dlopenOrig(module, filename, flags); if (filename.indexOf('wrapper.node') == -1) return dlopenRet; - //仅对Wrapper.node进行处理 RealWrapper = module.exports; - //先行获取LoginService操作权 loginService = new RealWrapper.NodeIKernelLoginService(); wrapperLoginService = loginService; - //开始针对性处理 module.exports = new Proxy({}, { get: function (target, ServiceName, receiver) { if (ServiceName == 'NodeIKernelLoginService') return CreateFuckService(ServiceName); @@ -104,11 +87,8 @@ Process.dlopen = function (module, filename, flags = os.constants.dlopen.RTLD_LA return RealWrapper[ServiceName]; } }); - //返回预先构造的对象 return dlopenRet; }; - -//辅助函数 function clearHook() { initCallBack = []; process.dlopen = dlopenOrig; From dcf0a0621790a23c3236f8a04e4db02ac7d39acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Fri, 23 Aug 2024 11:20:29 +0800 Subject: [PATCH 5/7] =?UTF-8?q?chore:=20=E6=89=A9=E5=A4=A7=E8=8C=83?= =?UTF-8?q?=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d4054baf..d8a2850e 100644 --- a/README.md +++ b/README.md @@ -35,4 +35,4 @@ NapCatQQ 是现代化的基于 NTQQ 的 Bot 协议端实现。 ## 使用许可 -任何使用本仓库代码的地方,都应当严格遵守[本仓库开源许可](./LICENSE)。**此外,禁止任何项目未经授权二次分发或基于 [core](./src/core) 部分代码开发。** +任何使用本仓库代码的地方,都应当严格遵守[本仓库开源许可](./LICENSE)。**此外,禁止任何项目未经授权二次分发或基于 NapCat 代码开发。** From 822af575c99b57fa957aa6d0e741b4a9adb48a3b Mon Sep 17 00:00:00 2001 From: Alen Date: Sun, 25 Aug 2024 02:07:39 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix:=20=E7=BE=A4=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit group_admin事件上报 群成员信息/群列表缓存 ProfileService新增事件 --- src/core/apis/group.ts | 2 +- src/core/core.ts | 4 +- .../listeners/NodeIKernelProfileListener.ts | 44 +++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/core/apis/group.ts b/src/core/apis/group.ts index 12852d5f..6d7c9c74 100644 --- a/src/core/apis/group.ts +++ b/src/core/apis/group.ts @@ -318,7 +318,7 @@ export class NTQQGroupApi { throw ('获取群成员列表出错,' + result.errMsg); } - //logDebug(`获取群(${groupQQ})成员列表结果:`, `finish: ${result.result.finish}`); //, Array.from(result.result.infos.values())); + this.context.logger.logDebug(`获取群(${groupQQ})成员列表结果:`, `members: ${result.result.infos.size}`); //, Array.from(result.result.infos.values())); return result.result.infos; /* console.log(sceneId); diff --git a/src/core/core.ts b/src/core/core.ts index 942cce96..59d9cbc7 100644 --- a/src/core/core.ts +++ b/src/core/core.ts @@ -197,12 +197,12 @@ export class NapCatCore { } }; this.context.session.getGroupService().addKernelGroupListener( - proxiedListenerOf(profileListener, this.context.logger) as any + proxiedListenerOf(groupListener, this.context.logger) as any ); } checkAdminEvent(groupCode: string, memberNew: GroupMember, memberOld: GroupMember | undefined): boolean { if (memberNew.role !== memberOld?.role) { - this.context.logger.log(`群 ${groupCode} ${memberNew.nick} 角色变更为 ${memberNew.role === 3 ? '管理员' : '群员'}`); + this.context.logger.logDebug(`群 ${groupCode} ${memberNew.nick} 角色变更为 ${memberNew.role === 3 ? '管理员' : '群员'}`); return true; } return false; diff --git a/src/core/listeners/NodeIKernelProfileListener.ts b/src/core/listeners/NodeIKernelProfileListener.ts index f11fe151..985b203a 100644 --- a/src/core/listeners/NodeIKernelProfileListener.ts +++ b/src/core/listeners/NodeIKernelProfileListener.ts @@ -43,4 +43,48 @@ export class ProfileListener implements IProfileListener { onStrangerRemarkChanged(...args: unknown[]) { } + + onMemberListChange(...args: unknown[]){ + + } + + onMemberInfoChange(...args: unknown[]){ + + } + + onGroupListUpdate(...args: unknown[]){ + + } + + onGroupAllInfoChange(...args: unknown[]){ + + } + + onGroupDetailInfoChange(...args: unknown[]){ + + } + + onGroupConfMemberChange(...args: unknown[]){ + + } + + onGroupExtListUpdate(...args: unknown[]){ + + } + + onGroupNotifiesUpdated(...args: unknown[]){ + + } + + onGroupNotifiesUnreadCountUpdated(...args: unknown[]){ + + } + + onGroupMemberLevelInfoChange(...args: unknown[]){ + + } + + onGroupBulletinChange(...args: unknown[]){ + + } } From aec4a009d1e16ced20fbabce4ee729b0ee283e8b Mon Sep 17 00:00:00 2001 From: Alen Date: Sun, 25 Aug 2024 09:44:40 +0800 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20=E6=92=A4=E5=9B=9E=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/onebot/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/onebot/index.ts b/src/onebot/index.ts index 5740bb59..5bf805d4 100644 --- a/src/onebot/index.ts +++ b/src/onebot/index.ts @@ -249,8 +249,9 @@ export class NapCatOneBot11Adapter { } }; const msgIdSend = new LRUCache(100); + const recallMsgs = new LRUCache(100); msgListener.onMsgInfoListUpdate = async msgList => { - this.emitRecallMsg(msgList) + this.emitRecallMsg(msgList, recallMsgs) .catch(e => this.context.logger.logError('处理消息失败', e)); for (const msg of msgList.filter(e => e.senderUin == this.core.selfInfo.uin)) { @@ -492,10 +493,11 @@ export class NapCatOneBot11Adapter { }).catch(e => this.context.logger.logError('constructPrivateEvent error: ', e)); } - private async emitRecallMsg(msgList: RawMessage[]) { + private async emitRecallMsg(msgList: RawMessage[], cache: LRUCache) { for (const message of msgList) { // log("message update", message.sendStatus, message.msgId, message.msgSeq) - if (message.recallTime != '0') { //todo: 这个判断方法不太好,应该使用灰色消息元素来判断? + if (message.recallTime != '0' && !cache.get(message.msgId)) { //todo: 这个判断方法不太好,应该使用灰色消息元素来判断? + cache.put(message.msgId, true) // 撤回消息上报 const oriMessageId = MessageUnique.getShortIdByMsgId(message.msgId); if (!oriMessageId) {