mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2256d67e2b | ||
![]() |
0af0bdede6 | ||
![]() |
379f31b9de | ||
![]() |
771a524734 | ||
![]() |
560e18a610 | ||
![]() |
147bdfab95 | ||
![]() |
36b1b0f663 | ||
![]() |
91511e4c3f | ||
![]() |
6a72056b25 | ||
![]() |
62e0c57a50 | ||
![]() |
9d92270931 | ||
![]() |
f61321d5a6 | ||
![]() |
08ab2f8649 | ||
![]() |
82962c4b42 | ||
![]() |
bd24e8a4ad | ||
![]() |
6224d9a292 |
@@ -22,13 +22,13 @@ NapCatQQ 是现代化的基于 NTQQ 的 Bot 协议端实现。
|
|||||||
|
|
||||||
[Telegram Link](https://t.me/+nLZEnpne-pQ1OWFl)
|
[Telegram Link](https://t.me/+nLZEnpne-pQ1OWFl)
|
||||||
|
|
||||||
## 附加协议
|
|
||||||
禁止未授权任何项目使用Core部分代码用于二次开发与分发
|
|
||||||
|
|
||||||
## 鸣谢名单
|
## 鸣谢名单
|
||||||
感谢 [LLOneBot](https://github.com/LLOneBot/LLOneBot) 提供初始版本基础
|
感谢 [LLOneBot](https://github.com/LLOneBot/LLOneBot) 提供初始版本基础
|
||||||
|
|
||||||
感谢 [Lagrange](https://github.com/LagrangeDev/Lagrange.Core) 对本项目的大力支持
|
感谢 [Lagrange](https://github.com/LagrangeDev/Lagrange.Core) 对本项目的大力支持
|
||||||
|
|
||||||
---
|
---
|
||||||
**任何使用本仓库代码的地方,都应当严格遵守[本仓库开源许可](./LICENSE)。**
|
|
||||||
|
## 使用许可
|
||||||
|
|
||||||
|
任何使用本仓库代码的地方,都应当严格遵守[本仓库开源许可](./LICENSE)。**此外,禁止任何项目未经授权二次分发或基于 [core](./src/core) 部分代码开发。**
|
||||||
|
@@ -3,8 +3,8 @@
|
|||||||
"type": "extension",
|
"type": "extension",
|
||||||
"name": "NapCat",
|
"name": "NapCat",
|
||||||
"slug": "NapCat",
|
"slug": "NapCat",
|
||||||
"description": "OneBot v11 protocol implementation with NapCat logic",
|
"description": "现代化的 OneBot 11 协议实现",
|
||||||
"version": "2.0.9",
|
"version": "2.0.12",
|
||||||
"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": "2.0.9",
|
"version": "2.0.12",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:framework": "vite build --mode framework",
|
"build:framework": "vite build --mode framework",
|
||||||
"build:shell": "vite build --mode shell",
|
"build:shell": "vite build --mode shell",
|
||||||
|
77
script/BootWay05_init.bat
Normal file
77
script/BootWay05_init.bat
Normal 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
10
script/BootWay05_run.bat
Normal 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 %*
|
13
script/BootWay05_run.utf8.bat
Normal file
13
script/BootWay05_run.utf8.bat
Normal 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 %*
|
@@ -2,7 +2,7 @@ import path, { dirname } from 'path';
|
|||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
export const napcat_version = '2.0.9';
|
export const napcat_version = '2.0.12';
|
||||||
|
|
||||||
export class NapCatPathWrapper {
|
export class NapCatPathWrapper {
|
||||||
binaryPath: string;
|
binaryPath: string;
|
||||||
|
@@ -296,7 +296,7 @@ export class NTQQMsgApi {
|
|||||||
if (!arkElement) {
|
if (!arkElement) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const forwardData: any = JSON.parse(arkElement.arkElement.bytesData);
|
const forwardData: any = JSON.parse(arkElement.arkElement?.bytesData || "");
|
||||||
if (forwardData.app != 'com.tencent.multimsg') {
|
if (forwardData.app != 'com.tencent.multimsg') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -87,12 +87,11 @@ function pollForNTInitializationCheck() {
|
|||||||
try {
|
try {
|
||||||
if (ntIsInitialized_Internal()) {
|
if (ntIsInitialized_Internal()) {
|
||||||
isSolve = true;
|
isSolve = true;
|
||||||
|
clearInterval(intervalRef);
|
||||||
resolve(true);
|
resolve(true);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject(error);
|
reject(error);
|
||||||
} finally {
|
|
||||||
clearInterval(intervalRef);
|
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
@@ -113,7 +112,7 @@ async function fetchServices(timeout = 10000) {
|
|||||||
}),
|
}),
|
||||||
]).then(result => result ?
|
]).then(result => result ?
|
||||||
{ wrapperSession, wrapperNodeApi, wrapperLoginService } :
|
{ wrapperSession, wrapperNodeApi, wrapperLoginService } :
|
||||||
Promise.reject(),
|
Promise.reject("fetchServices Timeout!"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let getWebUiUrlFunc = undefined;
|
let getWebUiUrlFunc = undefined;
|
||||||
|
@@ -69,7 +69,7 @@ class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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.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());
|
// retMember.join_time = parseInt((await getGroupMember(payload.group_id.toString(), retMember.user_id))?.joinTime || date.toString());
|
||||||
}
|
}
|
||||||
|
@@ -83,7 +83,7 @@ class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Mlikiowa V2.0.9 Refactor Todo
|
// Mlikiowa V2.0.12 Refactor Todo
|
||||||
// _groupMembers.forEach(async item => {
|
// _groupMembers.forEach(async item => {
|
||||||
// item.last_sent_time = parseInt((await getGroupMember(payload.group_id.toString(), item.user_id))?.lastSpeakTime || date.toString());
|
// 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());
|
// item.join_time = parseInt((await getGroupMember(payload.group_id.toString(), item.user_id))?.joinTime || date.toString());
|
||||||
|
@@ -56,7 +56,7 @@ const _handlers: {
|
|||||||
if (atQQ === 'all') return SendMsgElementConstructor.at(coreContext, atQQ, atQQ, AtType.atAll, '全体成员');
|
if (atQQ === 'all') return SendMsgElementConstructor.at(coreContext, atQQ, atQQ, AtType.atAll, '全体成员');
|
||||||
|
|
||||||
// then the qq is a group member
|
// 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);
|
const uid = await coreContext.apis.UserApi.getUidByUinV2(atQQ);
|
||||||
if (!uid) throw new Error('Get Uid Error');
|
if (!uid) throw new Error('Get Uid Error');
|
||||||
return SendMsgElementConstructor.at(coreContext, atQQ, uid, AtType.atUser, '');
|
return SendMsgElementConstructor.at(coreContext, atQQ, uid, AtType.atUser, '');
|
||||||
@@ -161,7 +161,7 @@ const _handlers: {
|
|||||||
} else {
|
} else {
|
||||||
postData = data;
|
postData = data;
|
||||||
}
|
}
|
||||||
// Mlikiowa V2.0.9 Refactor Todo
|
// Mlikiowa V2.0.12 Refactor Todo
|
||||||
const signUrl = obContext.configLoader.configData.musicSignUrl;
|
const signUrl = obContext.configLoader.configData.musicSignUrl;
|
||||||
if (!signUrl) {
|
if (!signUrl) {
|
||||||
if (data.type === 'qq') {
|
if (data.type === 'qq') {
|
||||||
|
@@ -105,6 +105,7 @@ async function createContext(coreContext: NapCatCore, payload: OB11PostSendMsg,
|
|||||||
return {
|
return {
|
||||||
chatType: isBuddy ? ChatType.friend : ChatType.temp,
|
chatType: isBuddy ? ChatType.friend : ChatType.temp,
|
||||||
peerUid: Uid!,
|
peerUid: Uid!,
|
||||||
|
guildId: payload.group_id?.toString() || '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
throw '请指定 group_id 或 user_id';
|
throw '请指定 group_id 或 user_id';
|
||||||
|
@@ -77,8 +77,8 @@ export class OB11Constructor {
|
|||||||
resMsg.sub_type = 'normal'; // 这里go-cqhttp是group,而onebot11标准是normal, 蛋疼
|
resMsg.sub_type = 'normal'; // 这里go-cqhttp是group,而onebot11标准是normal, 蛋疼
|
||||||
resMsg.group_id = parseInt(msg.peerUin);
|
resMsg.group_id = parseInt(msg.peerUin);
|
||||||
//直接去QQNative取
|
//直接去QQNative取
|
||||||
const memberList = await NTQQGroupApi.getGroupMembers(msg.peerUin);
|
let member = await NTQQGroupApi.getGroupMember(msg.peerUin, msg.senderUin);
|
||||||
const member = memberList.get(msg.senderUin!);
|
if (!member) member = await NTQQGroupApi.getGroupMember(msg.peerUin, msg.senderUin);
|
||||||
if (member) {
|
if (member) {
|
||||||
resMsg.sender.role = OB11Constructor.groupMemberRole(member.role);
|
resMsg.sender.role = OB11Constructor.groupMemberRole(member.role);
|
||||||
resMsg.sender.nickname = member.nick;
|
resMsg.sender.nickname = member.nick;
|
||||||
@@ -411,7 +411,7 @@ export class OB11Constructor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//log("group msg", msg);
|
//log("group msg", msg);
|
||||||
// Mlikiowa V2.0.9 Refactor Todo
|
// Mlikiowa V2.0.12 Refactor Todo
|
||||||
// if (msg.senderUin && msg.senderUin !== '0') {
|
// if (msg.senderUin && msg.senderUin !== '0') {
|
||||||
// const member = await getGroupMember(msg.peerUid, msg.senderUin);
|
// const member = await getGroupMember(msg.peerUid, msg.senderUin);
|
||||||
// if (member && member.cardName !== msg.sendMemberName) {
|
// if (member && member.cardName !== msg.sendMemberName) {
|
||||||
|
@@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) {
|
|||||||
SettingItem(
|
SettingItem(
|
||||||
'<span id="napcat-update-title">Napcat</span>',
|
'<span id="napcat-update-title">Napcat</span>',
|
||||||
undefined,
|
undefined,
|
||||||
SettingButton('V2.0.9', 'napcat-update-button', 'secondary'),
|
SettingButton('V2.0.12', 'napcat-update-button', 'secondary'),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
@@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) {
|
|||||||
SettingItem(
|
SettingItem(
|
||||||
'<span id="napcat-update-title">Napcat</span>',
|
'<span id="napcat-update-title">Napcat</span>',
|
||||||
void 0,
|
void 0,
|
||||||
SettingButton("V2.0.9", "napcat-update-button", "secondary")
|
SettingButton("V2.0.12", "napcat-update-button", "secondary")
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
Reference in New Issue
Block a user