Compare commits

...

16 Commits

Author SHA1 Message Date
手瓜一十雪
2256d67e2b release: 2.0.12 2024-08-13 19:34:33 +08:00
手瓜一十雪
0af0bdede6 build: 2.0.12 test 2024-08-13 19:33:29 +08:00
手瓜一十雪
379f31b9de Merge branch 'main' of https://github.com/NapNeko/NapCatQQ 2024-08-13 16:22:24 +08:00
手瓜一十雪
771a524734 add log 2024-08-13 16:21:59 +08:00
Wesley F. Young
560e18a610 fix: no longer require admin when running after initialization 2024-08-13 16:09:15 +08:00
手瓜一十雪
147bdfab95 Revert "fix: 框架启动概率性失败"
This reverts commit 9d92270931.
2024-08-13 15:14:42 +08:00
手瓜一十雪
36b1b0f663 release: 2.0.11 2024-08-13 14:53:18 +08:00
手瓜一十雪
91511e4c3f fix: 某个笨蛋弄错的地方 2024-08-13 14:52:51 +08:00
手瓜一十雪
6a72056b25 release: 2.0.10 2024-08-13 13:58:53 +08:00
手瓜一十雪
62e0c57a50 Merge pull request #243 from cnxysoft/upmain
fix: 框架启动概率性失败
2024-08-13 13:50:08 +08:00
Alen
9d92270931 fix: 框架启动概率性失败
修复框架启动有概率失败的问题
2024-08-13 13:37:19 +08:00
手瓜一十雪
f61321d5a6 Merge branch 'main' of https://github.com/NapNeko/NapCatQQ 2024-08-13 13:09:16 +08:00
手瓜一十雪
08ab2f8649 chore: 切换为缓存实现 2024-08-13 13:09:14 +08:00
Wesley F. Young
82962c4b42 docs: copyright 2024-08-13 09:06:46 +08:00
Wesley F. Young
bd24e8a4ad docs: plugin description 2024-08-13 09:02:50 +08:00
手瓜一十雪
6224d9a292 fix: 不合格类型 2024-08-13 00:59:26 +08:00
16 changed files with 123 additions and 23 deletions

View File

@@ -22,13 +22,13 @@ NapCatQQ 是现代化的基于 NTQQ 的 Bot 协议端实现。
[Telegram Link](https://t.me/+nLZEnpne-pQ1OWFl)
## 附加协议
禁止未授权任何项目使用Core部分代码用于二次开发与分发
## 鸣谢名单
感谢 [LLOneBot](https://github.com/LLOneBot/LLOneBot) 提供初始版本基础
感谢 [Lagrange](https://github.com/LagrangeDev/Lagrange.Core) 对本项目的大力支持
---
**任何使用本仓库代码的地方,都应当严格遵守[本仓库开源许可](./LICENSE)。**
## 使用许可
任何使用本仓库代码的地方,都应当严格遵守[本仓库开源许可](./LICENSE)。**此外,禁止任何项目未经授权二次分发或基于 [core](./src/core) 部分代码开发。**

View File

@@ -3,8 +3,8 @@
"type": "extension",
"name": "NapCat",
"slug": "NapCat",
"description": "OneBot v11 protocol implementation with NapCat logic",
"version": "2.0.9",
"description": "现代化的 OneBot 11 协议实现",
"version": "2.0.12",
"icon": "./logo.png",
"authors": [
{
@@ -30,4 +30,4 @@
"main": "./liteloader.cjs",
"preload": "./preload.cjs"
}
}
}

View File

@@ -2,7 +2,7 @@
"name": "napcat",
"private": true,
"type": "module",
"version": "2.0.9",
"version": "2.0.12",
"scripts": {
"build:framework": "vite build --mode framework",
"build:shell": "vite build --mode shell",

77
script/BootWay05_init.bat Normal file
View File

@@ -0,0 +1,77 @@
@echo off
REM Check if the script is running as administrator
openfiles >nul 2>&1
if %errorlevel% neq 0 (
REM If not, restart the script in administrator mode
echo Requesting administrator privileges...
powershell -Command "Start-Process cmd -ArgumentList '/c %~f0 %*' -Verb RunAs"
exit /b
)
cd /d %~dp0
set currentPath=%cd%
set currentPath=%currentPath:\=/%
REM Generate JavaScript code
set "jsCode=(async () =^>await import('file:///%currentPath%/napcat.mjs'))();"
REM Save JavaScript code to a file
echo %jsCode% > loadScript.js
echo JavaScript code has been generated and saved to loadScript.js
REM Set NAPCAT_PATH environment variable to the address of loadScript.js in the current directory
set NAPCAT_PATH=%cd%\loadScript.js
REM Get QQ path and cache it
:loop_read
for /f "tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ" /v "UninstallString"') do (
set "RetString=%%b"
)
set "pathWithoutUninstall=%RetString:Uninstall.exe=%"
SET QQPath=%pathWithoutUninstall%QQ.exe
echo %QQPath%>qq_path_cache.txt
echo QQ path %QQPath% has been cached to qq_path_cache.txt
REM Exit if QQ path is invalid
if not exist "%QQpath%" (
echo provided QQ path is invalid: %QQpath%
pause
exit /b
)
REM Collect dbghelp.dll path and HASH information
set QQdir=%~dp0
set oldDllPath=%QQdir%dbghelp.dll
set newDllPath=%currentPath%\dbghelp.dll
for /f "tokens=*" %%A in ('certutil -hashfile "%oldDllPath%" MD5') do (
if not defined oldDllHash set oldDllHash=%%A
)
for /f "tokens=*" %%A in ('certutil -hashfile "%newDllPath%" MD5') do (
if not defined newDllHash set newDllHash=%%A
)
REM Compare the HASH of the old and new dbghelp.dll, and replace the old one if they are different
if "%oldDllHash%" neq "%newDllHash%" (
tasklist /fi "imagename eq QQ.exe" 2>nul | find /i "QQ.exe" >nul
if %errorlevel% equ 0 (
REM If the file is in use, prompt the user to close QQ
echo dbghelp.dll is in use, please close QQ first.
) else (
copy /y "%newDllPath%" "%oldDllPath%"
if %errorlevel% neq 0 (
echo Copy dbghelp.dll failed, please check and try again.
pause
exit /b
) else (
echo dbghelp.dll has been updated.
echo Please run BootWay05_run.bat to start QQ.
echo If you update QQ in the future, please run BootWay05_init.bat again.
pause
exit /b
)
)
)

10
script/BootWay05_run.bat Normal file
View File

@@ -0,0 +1,10 @@
@echo off
set /p QQPath=<qq_path_cache.txt
echo QQ path %QQPath% has been read from qq_path_cache.txt
echo If failed to start QQ, please try running this script in administrator mode.
set NAPCAT_PATH=%cd%\loadScript.js
REM Launch QQ.exe with params provided
"%QQPath%" --enable-logging %*

View File

@@ -0,0 +1,13 @@
@echo off
chcp 65001
set /p QQPath=<qq_path_cache.txt
echo QQ path %QQPath% has been read from qq_path_cache.txt
echo If failed to start QQ, please try running this script in administrator mode.
set NAPCAT_PATH=%cd%\loadScript.js
REM Launch QQ.exe with params provided
"%QQPath%" --enable-logging %*

View File

@@ -2,7 +2,7 @@ import path, { dirname } from 'path';
import { fileURLToPath } from 'url';
import fs from 'fs';
export const napcat_version = '2.0.9';
export const napcat_version = '2.0.12';
export class NapCatPathWrapper {
binaryPath: string;

View File

@@ -296,7 +296,7 @@ export class NTQQMsgApi {
if (!arkElement) {
continue;
}
const forwardData: any = JSON.parse(arkElement.arkElement.bytesData);
const forwardData: any = JSON.parse(arkElement.arkElement?.bytesData || "");
if (forwardData.app != 'com.tencent.multimsg') {
continue;
}

View File

@@ -87,13 +87,12 @@ function pollForNTInitializationCheck() {
try {
if (ntIsInitialized_Internal()) {
isSolve = true;
clearInterval(intervalRef);
resolve(true);
}
} catch (error) {
reject(error);
} finally {
clearInterval(intervalRef);
}
}
}, 500);
});
}
@@ -113,7 +112,7 @@ async function fetchServices(timeout = 10000) {
}),
]).then(result => result ?
{ wrapperSession, wrapperNodeApi, wrapperLoginService } :
Promise.reject(),
Promise.reject("fetchServices Timeout!"),
);
}
let getWebUiUrlFunc = undefined;

View File

@@ -69,7 +69,7 @@ class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
}
}
} else {
// Mlikiowa V2.0.9 Refactor Todo
// Mlikiowa V2.0.12 Refactor Todo
// retMember.last_sent_time = parseInt((await getGroupMember(payload.group_id.toString(), retMember.user_id))?.lastSpeakTime || date.toString());
// retMember.join_time = parseInt((await getGroupMember(payload.group_id.toString(), retMember.user_id))?.joinTime || date.toString());
}

View File

@@ -83,7 +83,7 @@ class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> {
}
}
} else {
// Mlikiowa V2.0.9 Refactor Todo
// Mlikiowa V2.0.12 Refactor Todo
// _groupMembers.forEach(async item => {
// item.last_sent_time = parseInt((await getGroupMember(payload.group_id.toString(), item.user_id))?.lastSpeakTime || date.toString());
// item.join_time = parseInt((await getGroupMember(payload.group_id.toString(), item.user_id))?.joinTime || date.toString());

View File

@@ -56,7 +56,7 @@ const _handlers: {
if (atQQ === 'all') return SendMsgElementConstructor.at(coreContext, atQQ, atQQ, AtType.atAll, '全体成员');
// then the qq is a group member
// Mlikiowa V2.0.9 Refactor Todo
// Mlikiowa V2.0.12 Refactor Todo
const uid = await coreContext.apis.UserApi.getUidByUinV2(atQQ);
if (!uid) throw new Error('Get Uid Error');
return SendMsgElementConstructor.at(coreContext, atQQ, uid, AtType.atUser, '');
@@ -161,7 +161,7 @@ const _handlers: {
} else {
postData = data;
}
// Mlikiowa V2.0.9 Refactor Todo
// Mlikiowa V2.0.12 Refactor Todo
const signUrl = obContext.configLoader.configData.musicSignUrl;
if (!signUrl) {
if (data.type === 'qq') {

View File

@@ -105,6 +105,7 @@ async function createContext(coreContext: NapCatCore, payload: OB11PostSendMsg,
return {
chatType: isBuddy ? ChatType.friend : ChatType.temp,
peerUid: Uid!,
guildId: payload.group_id?.toString() || '',
};
}
throw '请指定 group_id 或 user_id';

View File

@@ -77,8 +77,8 @@ export class OB11Constructor {
resMsg.sub_type = 'normal'; // 这里go-cqhttp是group而onebot11标准是normal, 蛋疼
resMsg.group_id = parseInt(msg.peerUin);
//直接去QQNative取
const memberList = await NTQQGroupApi.getGroupMembers(msg.peerUin);
const member = memberList.get(msg.senderUin!);
let member = await NTQQGroupApi.getGroupMember(msg.peerUin, msg.senderUin);
if (!member) member = await NTQQGroupApi.getGroupMember(msg.peerUin, msg.senderUin);
if (member) {
resMsg.sender.role = OB11Constructor.groupMemberRole(member.role);
resMsg.sender.nickname = member.nick;
@@ -411,7 +411,7 @@ export class OB11Constructor {
return;
}
//log("group msg", msg);
// Mlikiowa V2.0.9 Refactor Todo
// Mlikiowa V2.0.12 Refactor Todo
// if (msg.senderUin && msg.senderUin !== '0') {
// const member = await getGroupMember(msg.peerUid, msg.senderUin);
// if (member && member.cardName !== msg.sendMemberName) {

View File

@@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) {
SettingItem(
'<span id="napcat-update-title">Napcat</span>',
undefined,
SettingButton('V2.0.9', 'napcat-update-button', 'secondary'),
SettingButton('V2.0.12', 'napcat-update-button', 'secondary'),
),
]),
SettingList([

View File

@@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) {
SettingItem(
'<span id="napcat-update-title">Napcat</span>',
void 0,
SettingButton("V2.0.9", "napcat-update-button", "secondary")
SettingButton("V2.0.12", "napcat-update-button", "secondary")
)
]),
SettingList([