mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix: Send empty forward msg
This commit is contained in:
parent
5575c3cb13
commit
c1edc1b99b
@ -29,7 +29,10 @@ export class WebsocketServerBase {
|
|||||||
|
|
||||||
start(port: number) {
|
start(port: number) {
|
||||||
try {
|
try {
|
||||||
this.ws = new WebSocketServer({ port });
|
this.ws = new WebSocketServer({
|
||||||
|
port ,
|
||||||
|
maxPayload: 1024 * 1024 * 1024
|
||||||
|
});
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
throw Error('ws服务启动失败, ' + e.toString());
|
throw Error('ws服务启动失败, ' + e.toString());
|
||||||
}
|
}
|
||||||
|
1
src/core
Submodule
1
src/core
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 0e7c9d43c4c401a2b34f4b5637d566a2ff27b7b7
|
@ -21,7 +21,6 @@ export interface GetFileResponse {
|
|||||||
base64?: string;
|
base64?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
||||||
private getElement(msg: RawMessage): { id: string, element: VideoElement | FileElement } {
|
private getElement(msg: RawMessage): { id: string, element: VideoElement | FileElement } {
|
||||||
let element = msg.elements.find(e => e.fileElement);
|
let element = msg.elements.find(e => e.fileElement);
|
||||||
|
@ -17,7 +17,7 @@ class GetMsg extends BaseAction<PayloadType, OB11Message> {
|
|||||||
protected async _handle(payload: PayloadType) {
|
protected async _handle(payload: PayloadType) {
|
||||||
// log("history msg ids", Object.keys(msgHistory));
|
// log("history msg ids", Object.keys(msgHistory));
|
||||||
if (!payload.message_id) {
|
if (!payload.message_id) {
|
||||||
throw ('参数message_id不能为空');
|
throw Error('参数message_id不能为空');
|
||||||
}
|
}
|
||||||
let msg = await dbUtil.getMsgByShortId(payload.message_id);
|
let msg = await dbUtil.getMsgByShortId(payload.message_id);
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
|
@ -28,6 +28,7 @@ import { sleep } from '@/common/utils/helper';
|
|||||||
import { uri2local } from '@/common/utils/file';
|
import { uri2local } from '@/common/utils/file';
|
||||||
import { getFriend, getGroup, getGroupMember, getUidByUin, selfInfo } from '@/common/data';
|
import { getFriend, getGroup, getGroupMember, getUidByUin, selfInfo } from '@/common/data';
|
||||||
import { NTQQMsgApi } from '@/core/qqnt/apis/msg';
|
import { NTQQMsgApi } from '@/core/qqnt/apis/msg';
|
||||||
|
import {NTQQFileApi} from "@/core/qqnt/apis/file";
|
||||||
|
|
||||||
const ALLOW_SEND_TEMP_MSG = false;
|
const ALLOW_SEND_TEMP_MSG = false;
|
||||||
|
|
||||||
@ -144,25 +145,40 @@ export async function createSendElements(messageData: OB11MessageData[], group:
|
|||||||
case OB11MessageDataType.file:
|
case OB11MessageDataType.file:
|
||||||
case OB11MessageDataType.video:
|
case OB11MessageDataType.video:
|
||||||
case OB11MessageDataType.voice: {
|
case OB11MessageDataType.voice: {
|
||||||
const file = sendMsg.data?.file;
|
let file = sendMsg.data?.file;
|
||||||
const payloadFileName = sendMsg.data?.name;
|
const payloadFileName = sendMsg.data?.name;
|
||||||
if (file) {
|
if (file) {
|
||||||
// todo: 使用缓存文件发送
|
// todo: 使用缓存文件发送
|
||||||
// const cache = await dbUtil.getFileCache(file);
|
const cache = await dbUtil.getFileCacheByName(file);
|
||||||
// if (cache) {
|
if (cache) {
|
||||||
// if (fs.existsSync(cache.filePath)) {
|
if (fs.existsSync(cache.path)) {
|
||||||
// file = "file://" + cache.filePath;
|
file = "file://" + cache.path;
|
||||||
// } else if (cache.downloadFunc) {
|
}
|
||||||
// await cache.downloadFunc();
|
else if (cache.url) {
|
||||||
// file = cache.filePath;
|
file = cache.url;
|
||||||
// } else if (cache.url) {
|
}
|
||||||
// file = cache.url;
|
else{
|
||||||
// }
|
const fileMsg = await dbUtil.getMsgByLongId(cache.msgId);
|
||||||
// log("找到文件缓存", file);
|
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));
|
const { path, isLocal, fileName, errMsg } = (await uri2local(file));
|
||||||
if (errMsg) {
|
if (errMsg) {
|
||||||
throw errMsg;
|
log('文件下载失败', errMsg);
|
||||||
|
throw Error('文件下载失败' + errMsg);
|
||||||
|
// throw (errMsg);
|
||||||
|
// continue
|
||||||
}
|
}
|
||||||
if (path) {
|
if (path) {
|
||||||
if (!isLocal) { // 只删除http和base64转过来的文件
|
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);
|
const returnMsg = await this.handleForwardNode(peer, messages as OB11MessageNode[], group);
|
||||||
return { message_id: returnMsg!.id! };
|
return { message_id: returnMsg!.id! };
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
throw ('发送转发消息失败 ' + e.toString());
|
throw Error('发送转发消息失败 ' + e.toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.getSpecialMsgNum(payload, OB11MessageDataType.music)) {
|
if (this.getSpecialMsgNum(payload, OB11MessageDataType.music)) {
|
||||||
@ -482,6 +498,9 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
// nodeIds.push(nodeMsg.msgId)
|
// nodeIds.push(nodeMsg.msgId)
|
||||||
// await sleep(500);
|
// await sleep(500);
|
||||||
// 开发转发
|
// 开发转发
|
||||||
|
if (nodeMsgIds.length === 0){
|
||||||
|
throw Error('转发消息失败,生成节点为空');
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
log('开发转发', nodeMsgIds);
|
log('开发转发', nodeMsgIds);
|
||||||
return await NTQQMsgApi.multiForwardMsg(srcPeer!, destPeer, nodeMsgIds);
|
return await NTQQMsgApi.multiForwardMsg(srcPeer!, destPeer, nodeMsgIds);
|
||||||
|
@ -79,6 +79,7 @@ export class ReverseWebsocket {
|
|||||||
private connect() {
|
private connect() {
|
||||||
const { token, heartInterval } = ob11Config;
|
const { token, heartInterval } = ob11Config;
|
||||||
this.websocket = new WebSocketClass(this.url, {
|
this.websocket = new WebSocketClass(this.url, {
|
||||||
|
maxPayload: 1024 * 1024 * 1024,
|
||||||
handshakeTimeout: 2000,
|
handshakeTimeout: 2000,
|
||||||
perMessageDeflate: false,
|
perMessageDeflate: false,
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -1 +1 @@
|
|||||||
export const version = '1.0.0';
|
export const version = '1.0.3';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user