Compare commits

..

19 Commits

Author SHA1 Message Date
手瓜一十雪
35c232ab25 fix 2024-04-16 13:27:33 +08:00
手瓜一十雪
02299e3892 fix 2024-04-16 13:17:30 +08:00
手瓜一十雪
6af4d6f5b8 fix 2024-04-16 13:14:09 +08:00
手瓜一十雪
4fb5700367 fix 2024-04-16 13:12:33 +08:00
手瓜一十雪
8579276381 fix 2024-04-16 13:10:07 +08:00
手瓜一十雪
7ba60b22c5 fix 2024-04-16 13:06:07 +08:00
linyuchen
031932f41c Merge remote-tracking branch 'origin/main' 2024-04-16 13:00:02 +08:00
linyuchen
079d0a89b1 fix: tsconfig path alias 2024-04-16 12:59:52 +08:00
手瓜一十雪
c4fdce6d64 fix 2024-04-16 12:55:16 +08:00
手瓜一十雪
5604c2b29f Merge branch 'main' of https://github.com/NapNeko/NapCatQQ 2024-04-16 12:55:05 +08:00
手瓜一十雪
74b5ab2b47 fix 2024-04-16 12:53:37 +08:00
linyuchen
c29cbfe123 Merge remote-tracking branch 'origin/main' 2024-04-16 12:51:42 +08:00
手瓜一十雪
6fe5cb1ffd remove 2024-04-16 12:51:12 +08:00
linyuchen
7edd5a7a8e Merge remote-tracking branch 'origin/main' 2024-04-16 12:50:22 +08:00
linyuchen
c1edc1b99b fix: Send empty forward msg 2024-04-16 12:50:14 +08:00
手瓜一十雪
4d1d890f72 fix 2024-04-16 12:47:36 +08:00
手瓜一十雪
fe0f82fa2b fix:checkVesion 2024-04-16 12:46:37 +08:00
手瓜一十雪
84083a65a8 fix:checkVesion 2024-04-16 12:45:07 +08:00
手瓜一十雪
fc91c6bc08 fix 2024-04-16 12:43:39 +08:00
11 changed files with 53 additions and 28 deletions

View File

@@ -27,9 +27,10 @@ jobs:
- name: Check Version
run: |
ls
node ./script/checkVersion.js
node ./script/checkVersion.cjs
sh ./checkVersion.sh
build-linux:
needs: [check-version]
runs-on: ubuntu-latest
strategy:
fail-fast: false
@@ -62,6 +63,7 @@ jobs:
path: dist
build-win32:
runs-on: ubuntu-latest
needs: [check-version]
strategy:
fail-fast: false
matrix:

1
.gitignore vendored
View File

@@ -14,3 +14,4 @@ src/core.lib/common/
# Build
*.db
checkVersion.sh

View File

@@ -1,16 +1,15 @@
let fs = require("fs");
let process = require("process")
console.log("[NapCat] [CheckVersion] 开始检测当前仓库版本...");
let currentVersion = require("./package.json").version;
let currentVersion = require("../package.json").version;
let targetVersion = process.env.VERSION;
console.log("[NapCat] [CheckVersion] currentVersion:", currentVersion, " targetVersion:", targetVersion);
// 借用dist目录输出脚本
fs.mkdir("./dist");
// fs.mkdirSync("./dist");
if (currentVersion === targetVersion) {
fs.appendFileSync("./checkVersion.sh", "#!/bin/bashe\necho \"CheckVersion Is Done\"")
fs.writeFileSync("./checkVersion.sh", "#!/bin/bashe\necho \"CheckVersion Is Done\"")
} else {
let packageJson = JSON.parse(fs.readFileSync("./package.json"));
packageJson.version = targetVersion;
fs.writeFileSync("./package.json", JSON.stringify(packageJson));
fs.appendFileSync("./checkVersion.sh", "#!/bin/bashe\ngit add .\n git commit -m \"chore:version change\"\n git push")
fs.writeFileSync("./checkVersion.sh", "#!/bin/bashe\ngit config --global user.email \"bot@test.mail\"\n git config --global user.name \"Version\"\ngit checkout main\ngit add .\n git commit -m \"chore:version change\"\n git push -u origin main")
}

View File

@@ -29,7 +29,10 @@ export class WebsocketServerBase {
start(port: number) {
try {
this.ws = new WebSocketServer({ port });
this.ws = new WebSocketServer({
port ,
maxPayload: 1024 * 1024 * 1024
});
} catch (e: any) {
throw Error('ws服务启动失败, ' + e.toString());
}

1
src/core Submodule

Submodule src/core added at 0e7c9d43c4

View File

@@ -21,7 +21,6 @@ export interface GetFileResponse {
base64?: string;
}
export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
private getElement(msg: RawMessage): { id: string, element: VideoElement | FileElement } {
let element = msg.elements.find(e => e.fileElement);

View File

@@ -17,7 +17,7 @@ class GetMsg extends BaseAction<PayloadType, OB11Message> {
protected async _handle(payload: PayloadType) {
// log("history msg ids", Object.keys(msgHistory));
if (!payload.message_id) {
throw ('参数message_id不能为空');
throw Error('参数message_id不能为空');
}
let msg = await dbUtil.getMsgByShortId(payload.message_id);
if (!msg) {

View File

@@ -27,7 +27,8 @@ import { log } from '@/common/utils/log';
import { sleep } from '@/common/utils/helper';
import { uri2local } from '@/common/utils/file';
import { getFriend, getGroup, getGroupMember, getUidByUin, selfInfo } from '@/common/data';
import { NTQQMsgApi } from '@/core/qqnt/apis/msg';
import { NTQQMsgApi } from '@/core/qqnt/apis';
import { NTQQFileApi } from '@/core/qqnt/apis';
const ALLOW_SEND_TEMP_MSG = false;
@@ -144,25 +145,40 @@ export async function createSendElements(messageData: OB11MessageData[], group:
case OB11MessageDataType.file:
case OB11MessageDataType.video:
case OB11MessageDataType.voice: {
const file = sendMsg.data?.file;
let file = sendMsg.data?.file;
const payloadFileName = sendMsg.data?.name;
if (file) {
// todo: 使用缓存文件发送
// const cache = await dbUtil.getFileCache(file);
// if (cache) {
// if (fs.existsSync(cache.filePath)) {
// file = "file://" + cache.filePath;
// } else if (cache.downloadFunc) {
// await cache.downloadFunc();
// file = cache.filePath;
// } else if (cache.url) {
// file = cache.url;
// }
// log("找到文件缓存", file);
// }
const cache = await dbUtil.getFileCacheByName(file);
if (cache) {
if (fs.existsSync(cache.path)) {
file = 'file://' + cache.path;
}
else if (cache.url) {
file = cache.url;
}
else{
const fileMsg = await dbUtil.getMsgByLongId(cache.msgId);
if (fileMsg){
const downloadPath = await NTQQFileApi.downloadMedia(fileMsg.msgId, fileMsg.chatType, fileMsg.peerUid,
cache.elementId, '', '');
cache.path = downloadPath!;
dbUtil.updateFileCache(cache).then();
file = 'file://' + cache.path;
}
// await sleep(1000);
// log('download result', downloadPath);
// log('下载完成后的msg', msg);
}
log('找到文件缓存', file);
}
const { path, isLocal, fileName, errMsg } = (await uri2local(file));
if (errMsg) {
throw errMsg;
log('文件下载失败', errMsg);
throw Error('文件下载失败' + errMsg);
// throw (errMsg);
// continue
}
if (path) {
if (!isLocal) { // 只删除http和base64转过来的文件
@@ -311,7 +327,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
const returnMsg = await this.handleForwardNode(peer, messages as OB11MessageNode[], group);
return { message_id: returnMsg!.id! };
} catch (e: any) {
throw ('发送转发消息失败 ' + e.toString());
throw Error('发送转发消息失败 ' + e.toString());
}
} else {
if (this.getSpecialMsgNum(payload, OB11MessageDataType.music)) {
@@ -482,6 +498,9 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
// nodeIds.push(nodeMsg.msgId)
// await sleep(500);
// 开发转发
if (nodeMsgIds.length === 0){
throw Error('转发消息失败,生成节点为空');
}
try {
log('开发转发', nodeMsgIds);
return await NTQQMsgApi.multiForwardMsg(srcPeer!, destPeer, nodeMsgIds);

View File

@@ -79,6 +79,7 @@ export class ReverseWebsocket {
private connect() {
const { token, heartInterval } = ob11Config;
this.websocket = new WebSocketClass(this.url, {
maxPayload: 1024 * 1024 * 1024,
handshakeTimeout: 2000,
perMessageDeflate: false,
headers: {

View File

@@ -1 +1 @@
export const version = '1.0.0';
export const version = '1.0.3';

View File

@@ -30,11 +30,11 @@
],
"@/core/qqnt/*": [
"./src/core/src/qqnt/*",
"./src/core.lib/src/qqnt/index"
"./src/core.lib/src/qqnt/*"
],
"@/core/*": [
"./src/core/src/*",
"./src/core.lib/src"
"./src/core.lib/src/*"
]
}
},