fix: 发送file://文件时会误删除原文件

This commit is contained in:
linyuchen 2024-01-28 10:41:48 +08:00
parent 05c4d693e0
commit 7dde7cbc2b
2 changed files with 2 additions and 4 deletions

View File

@ -1,7 +1,6 @@
import {log} from "./utils"; import {log} from "./utils";
const express = require("express"); const express = require("express");
const bodyParser = require('body-parser');
import {sendIPCRecallQQMsg, sendIPCSendQQMsg} from "./IPCSend"; import {sendIPCRecallQQMsg, sendIPCSendQQMsg} from "./IPCSend";
import {OnebotGroupMemberRole, PostDataAction, PostDataSendMsg, SendMessage} from "../common/types"; import {OnebotGroupMemberRole, PostDataAction, PostDataSendMsg, SendMessage} from "../common/types";
import {friends, groups, selfInfo} from "./data"; import {friends, groups, selfInfo} from "./data";
@ -146,8 +145,7 @@ export function startExpress(port: number) {
const app = express(); const app = express();
// 中间件用于解析POST请求的请求体 // 中间件用于解析POST请求的请求体
app.use(express.urlencoded({extended: true, limit: "500mb"})); app.use(express.urlencoded({extended: true, limit: "500mb"}));
app.use(bodyParser({limit: '500mb'})) app.use(express.json({limit: '500mb'}));
app.use(express.json());
function parseToOnebot12(action: PostDataAction) { function parseToOnebot12(action: PostDataAction) {
app.post('/' + action, (req: any, res: any) => { app.post('/' + action, (req: any, res: any) => {

View File

@ -245,9 +245,9 @@ async function listenSendMessage(postData: PostDataSendMsg) {
localFilePath = url.split("file://")[1] localFilePath = url.split("file://")[1]
} else { } else {
localFilePath = await window.llonebot.downloadFile({uri: url, localFilePath: localFilePath}) localFilePath = await window.llonebot.downloadFile({uri: url, localFilePath: localFilePath})
sendFiles.push(localFilePath);
} }
message.file = localFilePath message.file = localFilePath
sendFiles.push(localFilePath);
} else if (message.type == "reply") { } else if (message.type == "reply") {
let msgId = message.data?.id || message.msgId let msgId = message.data?.id || message.msgId
let replyMessage = msgHistory.find(msg => msg.raw.msgId == msgId) let replyMessage = msgHistory.find(msg => msg.raw.msgId == msgId)