Compare commits

...

34 Commits

Author SHA1 Message Date
手瓜一十雪
a8a2ffc33e release: 2.0.20 2024-08-14 19:38:50 +08:00
手瓜一十雪
27c4543471 Merge pull request #254 from lgc2333/patch-1
fix at error
2024-08-14 19:13:48 +08:00
student_2333
50a02cb59e fix at error 2024-08-14 19:08:42 +08:00
手瓜一十雪
50579bb9e6 fix: 修复某个笨蛋写的 2024-08-14 10:46:59 +08:00
手瓜一十雪
50512ca63c Merge pull request #250 from cnxysoft/upmain
fix: 二维码登录
2024-08-14 10:42:46 +08:00
手瓜一十雪
8b3577b216 Merge pull request #249 from DiheChen/patch-1
🐛 generating QR code when quick login fails
2024-08-14 10:42:33 +08:00
Alen
7553aab932 fix: 二维码登录
修复在没找到登陆历史记录后不加载二维码的问题
2024-08-14 10:32:39 +08:00
DiheChen
5dacdcfe5e 🐛 generating QR code when quick login fails 2024-08-14 10:31:28 +08:00
手瓜一十雪
8645a412b7 Merge branch 'main' of https://github.com/NapNeko/NapCatQQ 2024-08-14 09:35:14 +08:00
手瓜一十雪
acad07a588 release: 2.0.18 2024-08-14 09:33:52 +08:00
手瓜一十雪
51bbb480bb Merge pull request #248 from cnxysoft/upmain
fix: GetCookie容错
2024-08-14 01:41:38 +08:00
Alen
f0306cd10a fix: GetCookie容错
修改 API提交不可用域名或不含skey返回时的容错
2024-08-14 01:32:32 +08:00
手瓜一十雪
25253ad9e7 fix: 异常 2024-08-14 01:22:08 +08:00
手瓜一十雪
51f2fb8e8b release: 2.0.17 2024-08-14 00:57:09 +08:00
手瓜一十雪
9e8d650cbd chore: 提高对trss兼容性 2024-08-14 00:56:42 +08:00
手瓜一十雪
d222ccfa58 fix: GetGuildProfile 2024-08-14 00:54:14 +08:00
手瓜一十雪
9a05aaa906 chore: 兼容guild api 2024-08-14 00:53:52 +08:00
手瓜一十雪
00fdce8876 style&&chore: lint 2024-08-14 00:47:50 +08:00
手瓜一十雪
29b51adf7d style&&chore: 逐步清退老版本代码 2024-08-14 00:47:31 +08:00
手瓜一十雪
8e14b39969 release: 2.0.16 2024-08-14 00:38:04 +08:00
手瓜一十雪
d9fb4d6c4d release: 2.0.15 2024-08-13 23:49:05 +08:00
手瓜一十雪
fcf2f4c5f2 Merge pull request #246 from cnxysoft/upmain
BUG修复
2024-08-13 23:48:19 +08:00
Alen
4e97501690 BUG修复
1.修改快速登陆提示使其更易辨别失败原因
2.修复API: Get_Cookie执行错误的问题
2024-08-13 23:46:21 +08:00
手瓜一十雪
b0402391fb chore: link 2024-08-13 23:11:34 +08:00
手瓜一十雪
f05a862cf9 fix 2024-08-13 22:18:24 +08:00
手瓜一十雪
3ea92d57c2 chore: 排除空消息 2024-08-13 22:11:28 +08:00
手瓜一十雪
254b85fbd8 release: v2.0.14 2024-08-13 22:02:56 +08:00
手瓜一十雪
16371c0cc4 fix: 统一消息格式 2024-08-13 21:00:22 +08:00
手瓜一十雪
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
42 changed files with 355 additions and 224 deletions

View File

@@ -19,6 +19,7 @@ NapCatQQ 是现代化的基于 NTQQ 的 Bot 协议端实现。
**首次使用**请务必前往[官方文档](https://napneko.github.io/)查看使用教程。
## 相关链接
[QQ Group](https://qm.qq.com/q/VfjAq5HIMS)
[Telegram Link](https://t.me/+nLZEnpne-pQ1OWFl)

View File

@@ -4,7 +4,7 @@
"name": "NapCat",
"slug": "NapCat",
"description": "现代化的 OneBot 11 协议实现",
"version": "2.0.11",
"version": "2.0.20",
"icon": "./logo.png",
"authors": [
{

View File

@@ -2,7 +2,7 @@
"name": "napcat",
"private": true,
"type": "module",
"version": "2.0.11",
"version": "2.0.20",
"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.11';
export const napcat_version = '2.0.20';
export class NapCatPathWrapper {
binaryPath: string;

View File

@@ -141,7 +141,7 @@ export class NTQQFileApi {
filePath: thumbPath,
},
);
let msg = await this.core.apis.MsgApi.getMsgsByMsgId({
const msg = await this.core.apis.MsgApi.getMsgsByMsgId({
guildId: '',
chatType: chatType,
peerUid: peerUid,
@@ -150,13 +150,13 @@ export class NTQQFileApi {
return data[1].filePath;
}
//获取原始消息
let FileElements = msg?.msgList[0]?.elements?.find(e => e.elementId === elementId);
const FileElements = msg?.msgList[0]?.elements?.find(e => e.elementId === elementId);
if (!FileElements) {
//失败则就乱来 Todo
return data[1].filePath;
}
//从原始消息获取文件路径
let filePath =
const filePath =
FileElements?.fileElement?.filePath ||
FileElements?.pttElement?.filePath ||
FileElements?.videoElement?.filePath ||

View File

@@ -186,7 +186,7 @@ export class NTQQMsgApi {
}
async PrepareTempChat(toUserUid: string, GroupCode: string, nickname: string) {
//By Jadx/Ida Mlikiowa
let TempGameSession = {
const TempGameSession = {
nickname: "",
gameAppId: "",
selfTinyId: "",
@@ -210,7 +210,7 @@ export class NTQQMsgApi {
async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
//唉? !我有个想法
if (peer.chatType === ChatType.temp && peer.guildId && peer.guildId !== '') {
let member = await this.core.apis.GroupApi.getGroupMember(peer.guildId, peer.peerUid!);
const member = await this.core.apis.GroupApi.getGroupMember(peer.guildId, peer.peerUid!);
if (member) {
await this.PrepareTempChat(peer.peerUid, peer.guildId, member.nick);
}

View File

@@ -155,16 +155,10 @@ export class NTQQUserApi {
//需要异常处理
async getCookies(domain: string) {
const ClientKeyData = await this.forceFetchClientKey();
const requestUrl = `https://ssl.ptlogin2.qq.com/jump?${
new URLSearchParams({
ptlang: '1033',
clientuin: this.core.selfInfo.uin,
clientkey: ClientKeyData.clientKey,
u1: `https://user.qzone.qq.com/${this.core.selfInfo.uin}/infocenter`,
keyindex: '19',
})
}`;
return await RequestUtil.HttpsGetCookies(requestUrl);
const requestUrl = 'https://ssl.ptlogin2.qq.com/jump?ptlang=1033&clientuin=' + this.core.selfInfo.uin +
'&clientkey=' + ClientKeyData.clientKey + '&u1=https%3A%2F%2F' + domain + '%2F' + this.core.selfInfo.uin + '%2Finfocenter&keyindex=19%27';
const cookies: { [key: string]: string; } = await RequestUtil.HttpsGetCookies(requestUrl);
return cookies;
}
async getPSkey(domainList: string[]) {

View File

@@ -106,19 +106,13 @@ function registerInitCallback(callback) {
async function fetchServices(timeout = 10000) {
return Promise.race([
new Promise((resolve) => {
setTimeout(() => {
pollForNTInitializationCheck().then(() => {
resolve(true);
});
});
}),
pollForNTInitializationCheck(),
new Promise((resolve) => {
setTimeout(() => resolve(false), timeout);
}),
]).then(result => result ?
{ wrapperSession, wrapperNodeApi, wrapperLoginService } :
Promise.reject(),
Promise.reject("fetchServices Timeout!"),
);
}
let getWebUiUrlFunc = undefined;

View File

@@ -13,7 +13,7 @@ import { NapCatOneBot11Adapter } from '@/onebot';
//Framework ES入口文件
export async function getWebUiUrl() {
let WebUiConfigData = (await WebUiConfig.GetWebUIConfig());
const WebUiConfigData = (await WebUiConfig.GetWebUIConfig());
return "http://127.0.0.1:" + WebUiConfigData.port + '/webui/?token=' + WebUiConfigData.token;
}
export async function NCoreInitFramework(

View File

@@ -1,14 +1,38 @@
export const onSettingWindowCreated = async (view) => {
view.style.width = "100%";
view.style.height = "100%";
//添加iframe
const iframe = document.createElement("iframe");
iframe.src = await window.napcat.getWebUiUrl();
iframe.width = "100%";
iframe.height = "100%";
iframe.style.border = "none";
//去掉iframe滚动条
//iframe.scrolling = "no";
//有滚动条何尝不是一种美
view.appendChild(iframe);
// view.style.width = "100%";
// view.style.height = "100%";
// //添加iframe
// const iframe = document.createElement("iframe");
// iframe.src = await window.napcat.getWebUiUrl();
// iframe.width = "100%";
// iframe.height = "100%";
// iframe.style.border = "none";
// //去掉iframe滚动条
// //iframe.scrolling = "no";
// //有滚动条何尝不是一种美
// view.appendChild(iframe);
let webui = await window.napcat.getWebUiUrl();
let panel = `
<setting-section data-title="">
<setting-panel>
<setting-list data-direction="column">
<setting-item>
<setting-button data-type="primary" class="nc_openwebui">打开配置页面</setting-button>
</setting-item>
<setting-item>
<div>
<setting-text class="nc_webui">WebUi</setting-text>
</div>
</setting-item>
</setting-list>
</setting-panel>
</setting-section>
`;
view.innerHTML = panel;
view.querySelector(".nc_openwebui").addEventListener("click", () => {
window.open(webui, "_blank");
});
view.querySelector(".nc_webui").innerText = webui;
};

View File

@@ -6,14 +6,9 @@ export class GetFriendWithCategory extends BaseAction<void, any> {
actionName = ActionName.GetFriendsWithCategory;
async _handle(payload: void) {
if (this.CoreContext.context.basicInfoWrapper.requireMinNTQQBuild('26702')) {
//全新逻辑
return (await this.CoreContext.apis.FriendApi.getBuddyV2ExWithCate(true)).map(category => ({
...category,
buddyList: OB11Constructor.friendsV2(category.buddyList),
}));
} else {
throw new Error('this ntqq version not support, must be 26702 or later');
}
}
}

View File

@@ -5,7 +5,6 @@ export class GetRobotUinRange extends BaseAction<void, Array<any>> {
actionName = ActionName.GetRobotUinRange;
async _handle(payload: void) {
// console.log(await NTQQUserApi.getRobotUinRange());
const NTQQUserApi = this.CoreContext.apis.UserApi;
return await NTQQUserApi.getRobotUinRange();
}

View File

@@ -28,19 +28,6 @@ const GetFileBase_PayloadSchema = {
export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
PayloadSchema: any = GetFileBase_PayloadSchema;
private getElement(msg: RawMessage): { id: string, element: VideoElement | FileElement } {
let element = msg.elements.find(e => e.fileElement);
if (!element) {
element = msg.elements.find(e => e.videoElement);
if (element) {
return { id: element.elementId, element: element.videoElement };
} else {
throw new Error('找不到文件');
}
}
return { id: element.elementId, element: element.fileElement };
}
async _handle(payload: GetFilePayload): Promise<GetFileResponse> {
const NTQQFriendApi = this.CoreContext.apis.FriendApi;
const NTQQUserApi = this.CoreContext.apis.UserApi;
@@ -92,7 +79,7 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
file_size: fileSize,
file_name: fileName,
};
if (true/*enableLocalFile2Url*/) {
if (true/*enableLocalFile2Url*/ && downloadPath) {
try {
res.base64 = await fs.readFile(downloadPath, 'base64');
} catch (e) {
@@ -132,7 +119,7 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
file_size: NTSearchNameResult[0].fileSize.toString(),
file_name: NTSearchNameResult[0].fileName,
};
if (true/*enableLocalFile2Url*/) {
if (true/*enableLocalFile2Url*/ && downloadPath) {
try {
res.base64 = await fs.readFile(downloadPath, 'base64');
} catch (e) {

View File

@@ -40,7 +40,7 @@ export class GoCQHTTPGetForwardMsgAction extends BaseAction<Payload, any> {
}
const msgList = data.msgList;
const messages = (await Promise.all(msgList.map(async msg => {
const resMsg = await OB11Constructor.message(this.CoreContext, msg, 'array');
const resMsg = await OB11Constructor.message(this.CoreContext, this.OneBotContext, msg);
if (!resMsg) return;
resMsg.message_id = MessageUnique.createMsg({
guildId: '',

View File

@@ -53,7 +53,7 @@ export default class GetFriendMsgHistory extends BaseAction<Payload, Response> {
msg.id = MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
}));
//转换消息
const ob11MsgList = (await Promise.all(msgList.map(msg => OB11Constructor.message(this.CoreContext, msg, 'array')))).filter(msg => !!msg);
const ob11MsgList = (await Promise.all(msgList.map(msg => OB11Constructor.message(this.CoreContext, this.OneBotContext, msg)))).filter(msg => !!msg);
return { 'messages': ob11MsgList };
}
}

View File

@@ -48,7 +48,7 @@ export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Resp
}));
//转换消息
const ob11MsgList = (await Promise.all(msgList.map(msg => OB11Constructor.message(this.CoreContext, msg, 'array')))).filter(msg => !!msg);
const ob11MsgList = (await Promise.all(msgList.map(msg => OB11Constructor.message(this.CoreContext, this.OneBotContext, msg)))).filter(msg => !!msg);
return { 'messages': ob11MsgList };
}
}

View File

@@ -0,0 +1,10 @@
import BaseAction from '../BaseAction';
import { ActionName } from '../types';
export default class SetModelShow extends BaseAction<null, null> {
actionName = ActionName.SetModelShow;
async _handle(payload: null): Promise<null> {
return null;
}
}

View File

@@ -20,9 +20,7 @@ export default class DelEssenceMsg extends BaseAction<Payload, any> {
async _handle(payload: Payload): Promise<any> {
const NTQQGroupApi = this.CoreContext.apis.GroupApi;
const msg = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString()));
if (!msg) {
throw new Error('msg not found');
}
if (!msg) throw new Error('msg not found');
return await NTQQGroupApi.removeGroupEssence(
msg.Peer.peerUid,
msg.MsgId,

View File

@@ -9,7 +9,7 @@ const SchemaData = {
group_id: { type: ['number', 'string'] },
pages: { type: 'number' },
},
required: ['group_id', 'pages'],
required: ['group_id'],
} as const satisfies JSONSchema;
type Payload = FromSchema<typeof SchemaData>;
@@ -20,7 +20,7 @@ export class GetGroupEssence extends BaseAction<Payload, GroupEssenceMsgRet> {
async _handle(payload: Payload) {
const NTQQWebApi = this.CoreContext.apis.WebApi;
const ret = await NTQQWebApi.getGroupEssenceMsg(payload.group_id.toString(), payload.pages.toString());
const ret = await NTQQWebApi.getGroupEssenceMsg(payload.group_id.toString(), (payload.pages || "0").toString());
if (!ret) {
throw new Error('获取失败');
}

View File

@@ -69,7 +69,7 @@ class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
}
}
} else {
// Mlikiowa V2.0.11 Refactor Todo
// Mlikiowa V2.0.20 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.11 Refactor Todo
// Mlikiowa V2.0.20 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

@@ -0,0 +1,10 @@
import BaseAction from '../BaseAction';
import { ActionName } from '../types';
export default class GetGuildProfile extends BaseAction<null, null> {
actionName = ActionName.GetGuildProfile;
async _handle(payload: null): Promise<null> {
return null;
}
}

View File

@@ -23,7 +23,7 @@ import GoCQHTTPGetStrangerInfo from './go-cqhttp/GetStrangerInfo';
import SendLike from './user/SendLike';
import SetGroupAddRequest from './group/SetGroupAddRequest';
import SetGroupLeave from './group/SetGroupLeave';
import GetGuildList from './group/GetGuildList';
import GetGuildList from './guild/GetGuildList';
import SetFriendAddRequest from './user/SetFriendAddRequest';
import SetGroupWholeBan from './group/SetGroupWholeBan';
import SetGroupName from './group/SetGroupName';
@@ -76,6 +76,8 @@ import { FetchEmojiLike } from './extends/FetchEmojiLike';
import { NapCatCore } from '@/core';
import { NapCatOneBot11Adapter } from '@/onebot';
import GetGuildProfile from './guild/GetGuildProfile';
import SetModelShow from './go-cqhttp/SetModelShow';
export type ActionMap = Map<string, BaseAction<any, any>>;
@@ -161,6 +163,8 @@ export function createActionMap(onebotContext: NapCatOneBot11Adapter, coreContex
new SetGroupHeader(onebotContext, coreContext),
new FetchCustomFace(onebotContext, coreContext),
new GoCQHTTPUploadPrivateFile(onebotContext, coreContext),
new GetGuildProfile(onebotContext, coreContext),
new SetModelShow(onebotContext, coreContext),
];
const actionMap = new Map();
for (const action of actionHandlers) {

View File

@@ -28,8 +28,8 @@ class GetMsg extends BaseAction<Payload, OB11Message> {
if (!payload.message_id) {
throw Error('参数message_id不能为空');
}
const MsgShortId = await MessageUnique.getShortIdByMsgId(payload.message_id.toString());
const msgIdWithPeer = await MessageUnique.getMsgIdAndPeerByShortId(MsgShortId || parseInt(payload.message_id.toString()));
const MsgShortId = MessageUnique.getShortIdByMsgId(payload.message_id.toString());
const msgIdWithPeer = MessageUnique.getMsgIdAndPeerByShortId(MsgShortId || parseInt(payload.message_id.toString()));
if (!msgIdWithPeer) {
throw ('消息不存在');
}
@@ -37,7 +37,7 @@ class GetMsg extends BaseAction<Payload, OB11Message> {
const msg = await NTQQMsgApi.getMsgsByMsgId(
peer,
[msgIdWithPeer?.MsgId || payload.message_id.toString()]);
const retMsg = await OB11Constructor.message(this.CoreContext, msg.msgList[0], 'array');
const retMsg = await OB11Constructor.message(this.CoreContext, this.OneBotContext, msg.msgList[0], 'array');
if (!retMsg) throw Error('消息为空');
try {
retMsg.message_id = MessageUnique.createMsg(peer, msg.msgList[0].msgId)!;

View File

@@ -56,8 +56,8 @@ const _handlers: {
if (atQQ === 'all') return SendMsgElementConstructor.at(coreContext, atQQ, atQQ, AtType.atAll, '全体成员');
// then the qq is a group member
// Mlikiowa V2.0.11 Refactor Todo
const uid = await coreContext.apis.UserApi.getUidByUinV2(atQQ);
// Mlikiowa V2.0.19 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.11 Refactor Todo
// Mlikiowa V2.0.19 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

@@ -104,5 +104,7 @@ export enum ActionName {
FetchCustomFace = 'fetch_custom_face',
GOCQHTTP_UploadPrivateFile = 'upload_private_file',
TestApi01 = 'test_api_01',
FetchEmojiLike = 'fetch_emoji_like'
FetchEmojiLike = 'fetch_emoji_like',
GetGuildProfile = "get_guild_service_profile",
SetModelShow = "_set_model_show"
}

View File

@@ -67,7 +67,7 @@ export class GetCookies extends BaseAction<Payload, Response> {
const cookiesObject = await NTQQUserApi.getCookies(payload.domain);
//把获取到的cookiesObject转换成 k=v; 格式字符串拼接在一起
const cookies = Object.entries(cookiesObject).map(([key, value]) => `${key}=${value}`).join('; ');
const bkn = NTQQWebApi.getBknFromCookie(cookiesObject.p_skey);
const bkn = cookiesObject?.skey ? NTQQWebApi.getBknFromCookie(cookiesObject) : '';
return { cookies, bkn };
}
}

View File

@@ -24,7 +24,7 @@ export default class GetRecentContact extends BaseAction<Payload, any> {
const FastMsg = await NTQQMsgApi.getMsgsByMsgId({ chatType: t.chatType, peerUid: t.peerUid }, [t.msgId]);
if (FastMsg.msgList.length > 0) {
//扩展ret.info.changedList
const lastestMsg = await OB11Constructor.message(this.CoreContext, FastMsg.msgList[0], 'array');
const lastestMsg = await OB11Constructor.message(this.CoreContext, this.OneBotContext,FastMsg.msgList[0], 'array');
return {
lastestMsg: lastestMsg,
peerUin: t.peerUin,

View File

@@ -42,11 +42,17 @@ import { OB11BaseNoticeEvent } from '../event/notice/OB11BaseNoticeEvent';
import { OB11GroupEssenceEvent } from '../event/notice/OB11GroupEssenceEvent';
import { MessageUnique } from '@/common/utils/MessageUnique';
import { NapCatCore } from '@/core';
import { NapCatOneBot11Adapter } from '..';
export class OB11Constructor {
static async message(core: NapCatCore, msg: RawMessage, messagePostFormat: any): Promise<OB11Message | undefined> {
if (msg.senderUin == "0") return;
if (msg.peerUin == "0") return;
static async message(
core: NapCatCore,
obcore: NapCatOneBot11Adapter,
msg: RawMessage,
messagePostFormat: string = obcore.configLoader.configData.messagePostFormat
): Promise<OB11Message | undefined> {
if (msg.senderUin == "0" || msg.senderUin == "") return;
if (msg.peerUin == "0" || msg.peerUin == "") return;
//跳过空消息
const NTQQGroupApi = core.apis.GroupApi;
const NTQQUserApi = core.apis.UserApi;
@@ -344,7 +350,7 @@ export class OB11Constructor {
MultiMsg.parentMsgPeer = ParentMsgPeer;
MultiMsg.parentMsgIdList = msg.parentMsgIdList;
MultiMsg.id = MessageUnique.createMsg(ParentMsgPeer, MultiMsg.msgId);//该ID仅用查看 无法调用
const msgList = await OB11Constructor.message(core, MultiMsg, 'array');
const msgList = await OB11Constructor.message(core, obcore, MultiMsg, messagePostFormat);
if (!msgList) continue;
message_data['data']['content'].push(msgList);
//console.log("合并消息", msgList);
@@ -411,7 +417,7 @@ export class OB11Constructor {
return;
}
//log("group msg", msg);
// Mlikiowa V2.0.11 Refactor Todo
// Mlikiowa V2.0.20 Refactor Todo
// if (msg.senderUin && msg.senderUin !== '0') {
// const member = await getGroupMember(msg.peerUid, msg.senderUin);
// if (member && member.cardName !== msg.sendMemberName) {

View File

@@ -253,7 +253,7 @@ export class NapCatOneBot11Adapter {
if (msg.sendStatus == 2 && !msgIdSend.get(msg.msgId)) {
msgIdSend.put(msg.msgId, true);
// 完成后再post
OB11Constructor.message(this.core, msg, this.configLoader.configData.messagePostFormat)
OB11Constructor.message(this.core, this, msg)
.then((ob11Msg) => {
if (!ob11Msg) return;
ob11Msg.target_id = parseInt(msg.peerUin);
@@ -425,7 +425,7 @@ export class NapCatOneBot11Adapter {
private async emitMsg(message: RawMessage) {
const { debug, reportSelfMessage, messagePostFormat } = this.configLoader.configData;
this.context.logger.logDebug('收到新消息 RawMessage', message);
OB11Constructor.message(this.core, message, messagePostFormat).then((ob11Msg) => {
OB11Constructor.message(this.core, this, message, messagePostFormat).then((ob11Msg) => {
if (!ob11Msg) return;
this.context.logger.logDebug('转化为 OB11Message', ob11Msg);
if (debug) {

View File

@@ -70,6 +70,7 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter {
let isClosedByError = false;
this.connection = new WebSocket(this.url, {
maxPayload: 1024 * 1024 * 1024,
headers: {
'X-Self-ID': this.coreContext.selfInfo.uin,
'Authorization': `Bearer ${this.token}`,

View File

@@ -36,8 +36,8 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter {
this.logger = coreContext.context.logger;
this.heartbeatInterval = heartbeatInterval;
this.wsServer = new WebSocketServer({ port: port, host: ip });
let core = coreContext;
this.wsServer = new WebSocketServer({ port: port, host: ip, maxPayload: 1024 * 1024 * 1024, });
const core = coreContext;
this.wsServer.on('connection', async (wsClient, wsReq) => {
if (!this.isOpen) {
wsClient.close();

View File

@@ -168,7 +168,8 @@ export async function NCoreInitShell() {
});
});
if (quickLoginUin && historyLoginList.some(u => u.uin === quickLoginUin)) {
if (quickLoginUin) {
if (historyLoginList.some(u => u.uin === quickLoginUin)) {
logger.log('正在快速登录 ', quickLoginUin);
setTimeout(() => {
loginService.quickLoginWithUin(quickLoginUin)
@@ -181,7 +182,11 @@ export async function NCoreInitShell() {
.catch();
}, 1000);
} else {
logger.log('没有 -q 指令指定快速登录,或未曾登录过这个 QQ,将使用二维码登录方式');
logger.logError('快速登录失败,未找到该 QQ 历史登录记录,将使用二维码登录方式');
loginService.getQRCodePicture();
}
} else {
logger.log('没有 -q 指令指定快速登录,将使用二维码登录方式');
if (historyLoginList.length > 0) {
logger.log(`可用于快速登录的 QQ\n${
historyLoginList

View File

@@ -19,7 +19,7 @@ export let webUiPathWrapper: NapCatPathWrapper;
export async function InitWebUi(logger: LogWrapper, pathWrapper: NapCatPathWrapper) {
webUiPathWrapper = pathWrapper;
WebUiConfig = new WebUiConfigWrapper();
let log = logger.log.bind(logger);
const log = logger.log.bind(logger);
const config = await WebUiConfig.GetWebUIConfig();
if (config.port == 0) {
log('[NapCat] [WebUi] Current WebUi is not run.');

View File

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