mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix: http file ext
fix: vite build ws
This commit is contained in:
parent
c22965275c
commit
4a09a51722
@ -1,6 +1,13 @@
|
||||
import cp from 'vite-plugin-cp';
|
||||
import "./scripts/gen-version"
|
||||
export default {
|
||||
|
||||
const external = ["silk-wasm", "ws"];
|
||||
|
||||
function genCpModule(module: string) {
|
||||
return { src: `./node_modules/${module}`, dest: `dist/node_modules/${module}`, flatten: false }
|
||||
}
|
||||
|
||||
let config = {
|
||||
main: {
|
||||
build: {
|
||||
outDir: "dist/main",
|
||||
@ -10,7 +17,7 @@ export default {
|
||||
entry: { "main": "src/main/main.ts" },
|
||||
},
|
||||
rollupOptions: {
|
||||
external: ["silk-wasm"],
|
||||
external,
|
||||
input: "src/main/main.ts",
|
||||
}
|
||||
},
|
||||
@ -19,7 +26,7 @@ export default {
|
||||
'./lib-cov/fluent-ffmpeg': './lib/fluent-ffmpeg'
|
||||
},
|
||||
},
|
||||
plugins: [cp({ targets: [{src: './node_modules/silk-wasm', dest: 'dist/node_modules/silk-wasm', flatten: false}, { src: './manifest.json', dest: 'dist' }] })]
|
||||
plugins: [cp({ targets: [...external.map(genCpModule), { src: './manifest.json', dest: 'dist' }] })]
|
||||
},
|
||||
preload: {
|
||||
// vite config options
|
||||
@ -56,3 +63,5 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default config;
|
92
package-lock.json
generated
92
package-lock.json
generated
@ -10,8 +10,8 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"express": "^4.18.2",
|
||||
"file-type": "^19.0.0",
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"music-metadata": "^8.1.4",
|
||||
"silk-wasm": "^3.2.3",
|
||||
"utf-8-validate": "^6.0.3",
|
||||
"uuid": "^9.0.1",
|
||||
@ -27,7 +27,6 @@
|
||||
"electron": "^29.0.1",
|
||||
"electron-vite": "^2.0.0",
|
||||
"eslint": "^8.0.1",
|
||||
"eslint-config-standard-with-typescript": "^43.0.1",
|
||||
"eslint-plugin-import": "^2.25.2",
|
||||
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
|
||||
"eslint-plugin-promise": "^6.0.0",
|
||||
@ -1662,6 +1661,7 @@
|
||||
"resolved": "https://mirrors.cloud.tencent.com/npm/@typescript-eslint/parser/-/parser-6.21.0.tgz",
|
||||
"integrity": "sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "6.21.0",
|
||||
"@typescript-eslint/types": "6.21.0",
|
||||
@ -2546,6 +2546,7 @@
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
},
|
||||
@ -3032,53 +3033,6 @@
|
||||
"eslint": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-config-standard": {
|
||||
"version": "17.1.0",
|
||||
"resolved": "https://mirrors.cloud.tencent.com/npm/eslint-config-standard/-/eslint-config-standard-17.1.0.tgz",
|
||||
"integrity": "sha512-IwHwmaBNtDK4zDHQukFDW5u/aTb8+meQWZvNFWkiGmbWjD6bqyuSSBxxXKkCftCUzc1zwCH2m/baCNDLGmuO5Q==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.0.1",
|
||||
"eslint-plugin-import": "^2.25.2",
|
||||
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
|
||||
"eslint-plugin-promise": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-config-standard-with-typescript": {
|
||||
"version": "43.0.1",
|
||||
"resolved": "https://mirrors.cloud.tencent.com/npm/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-43.0.1.tgz",
|
||||
"integrity": "sha512-WfZ986+qzIzX6dcr4yGUyVb/l9N3Z8wPXCc5z/70fljs3UbWhhV+WxrfgsqMToRzuuyX9MqZ974pq2UPhDTOcA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/parser": "^6.4.0",
|
||||
"eslint-config-standard": "17.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^6.4.0",
|
||||
"eslint": "^8.0.1",
|
||||
"eslint-plugin-import": "^2.25.2",
|
||||
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
|
||||
"eslint-plugin-promise": "^6.0.0",
|
||||
"typescript": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-import-resolver-node": {
|
||||
"version": "0.3.9",
|
||||
"resolved": "https://mirrors.cloud.tencent.com/npm/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz",
|
||||
@ -3709,16 +3663,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/file-type": {
|
||||
"version": "18.7.0",
|
||||
"resolved": "https://registry.npmjs.org/file-type/-/file-type-18.7.0.tgz",
|
||||
"integrity": "sha512-ihHtXRzXEziMrQ56VSgU7wkxh55iNchFkosu7Y9/S+tXHdKyrGjVK0ujbqNnsxzea+78MaLhN6PGmfYSAv1ACw==",
|
||||
"version": "19.0.0",
|
||||
"resolved": "https://mirrors.cloud.tencent.com/npm/file-type/-/file-type-19.0.0.tgz",
|
||||
"integrity": "sha512-s7cxa7/leUWLiXO78DVVfBVse+milos9FitauDLG1pI7lNaJ2+5lzPnr2N24ym+84HVwJL6hVuGfgVE+ALvU8Q==",
|
||||
"dependencies": {
|
||||
"readable-web-to-node-stream": "^3.0.2",
|
||||
"strtok3": "^7.0.0",
|
||||
"token-types": "^5.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.16"
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sindresorhus/file-type?sponsor=1"
|
||||
@ -4740,14 +4694,6 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/media-typer": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz",
|
||||
"integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/merge-descriptors": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
|
||||
@ -4834,28 +4780,8 @@
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"node_modules/music-metadata": {
|
||||
"version": "8.2.0",
|
||||
"resolved": "https://registry.npmjs.org/music-metadata/-/music-metadata-8.2.0.tgz",
|
||||
"integrity": "sha512-9nRmW635ew/lHhxV+Hf+S7k2YwebVGLGHyO5itc8QZicRBLyC8/4imN8wp6+rcKyA+RChE2q9OyEmhdvHBrhsQ==",
|
||||
"dependencies": {
|
||||
"@tokenizer/token": "^0.3.0",
|
||||
"content-type": "^1.0.5",
|
||||
"debug": "^4.3.4",
|
||||
"file-type": "^18.6.0",
|
||||
"media-typer": "^1.1.0",
|
||||
"strtok3": "^7.0.0",
|
||||
"token-types": "^5.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/Borewit"
|
||||
}
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/nanoid": {
|
||||
"version": "3.3.7",
|
||||
|
@ -15,6 +15,7 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"express": "^4.18.2",
|
||||
"file-type": "^19.0.0",
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"silk-wasm": "^3.2.3",
|
||||
"utf-8-validate": "^6.0.3",
|
||||
|
14
src/onebot11/action/MarkMsgAsRead.ts
Normal file
14
src/onebot11/action/MarkMsgAsRead.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import BaseAction from "./BaseAction";
|
||||
import {ActionName} from "./types";
|
||||
|
||||
interface Payload{
|
||||
message_id: number
|
||||
}
|
||||
|
||||
export default class GoCQHTTPMarkMsgAsRead extends BaseAction<Payload, null>{
|
||||
actionName = ActionName.GoCQHTTP_MarkMsgAsRead
|
||||
|
||||
protected async _handle(payload: Payload): Promise<null> {
|
||||
return null
|
||||
}
|
||||
}
|
@ -30,6 +30,7 @@ import SetGroupAdmin from "./SetGroupAdmin";
|
||||
import SetGroupCard from "./SetGroupCard";
|
||||
import GetImage from "./GetImage";
|
||||
import GetRecord from "./GetRecord";
|
||||
import GoCQHTTPMarkMsgAsRead from "./MarkMsgAsRead";
|
||||
|
||||
export const actionHandlers = [
|
||||
new Debug(),
|
||||
@ -60,7 +61,8 @@ export const actionHandlers = [
|
||||
new GoCQHTTPSendGroupForwardMsg(),
|
||||
new GoCQHTTPSendPrivateForwardMsg(),
|
||||
new GoCQHTTPGetStrangerInfo(),
|
||||
new GetGuildList()
|
||||
new GetGuildList(),
|
||||
new GoCQHTTPMarkMsgAsRead(),
|
||||
|
||||
]
|
||||
|
||||
|
@ -47,4 +47,5 @@ export enum ActionName {
|
||||
GoCQHTTP_SendPrivateForwardMsg = "send_private_forward_msg",
|
||||
GoCQHTTP_GetStrangerInfo = "get_stranger_info",
|
||||
GetGuildList = "get_guild_list",
|
||||
GoCQHTTP_MarkMsgAsRead = "mark_msg_as_read",
|
||||
}
|
@ -10,8 +10,8 @@ export function wsReply(wsClient: WebSocketClass, data: OB11Response | PostEvent
|
||||
delete packet["echo"];
|
||||
}
|
||||
wsClient.send(JSON.stringify(packet))
|
||||
log("ws 消息上报", wsClient.url || "", data)
|
||||
log("ws 消息上报", wsClient.url || "", data);
|
||||
} catch (e) {
|
||||
log("websocket 回复失败", e)
|
||||
log("websocket 回复失败", e.stack, data);
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ import {CONFIG_DIR, isGIF} from "../common/utils";
|
||||
import {v4 as uuidv4} from "uuid";
|
||||
import * as path from 'node:path';
|
||||
import {fileCache} from "../common/data";
|
||||
import * as fileType from 'file-type';
|
||||
|
||||
const fs = require("fs").promises;
|
||||
|
||||
@ -23,6 +24,7 @@ export async function uri2local(uri: string, fileName: string = null) {
|
||||
try {
|
||||
const buffer = Buffer.from(base64Data, 'base64');
|
||||
await fs.writeFile(filePath, buffer);
|
||||
|
||||
} catch (e: any) {
|
||||
res.errMsg = `base64文件下载失败,` + e.toString()
|
||||
return res
|
||||
@ -37,7 +39,7 @@ export async function uri2local(uri: string, fileName: string = null) {
|
||||
let blob = await fetchRes.blob();
|
||||
let buffer = await blob.arrayBuffer();
|
||||
try {
|
||||
fileName = path.basename(url.pathname) || fileName
|
||||
fileName = path.parse(url.pathname).name || fileName
|
||||
filePath = path.join(CONFIG_DIR, fileName)
|
||||
await fs.writeFile(filePath, Buffer.from(buffer));
|
||||
} catch (e: any) {
|
||||
@ -73,6 +75,13 @@ export async function uri2local(uri: string, fileName: string = null) {
|
||||
await fs.rename(filePath, filePath + ".gif");
|
||||
filePath += ".gif";
|
||||
}
|
||||
if (!res.isLocal) {
|
||||
const {ext} = await fileType.fileTypeFromFile(filePath)
|
||||
if (ext) {
|
||||
await fs.rename(filePath, filePath + `.${ext}`)
|
||||
filePath += `.${ext}`
|
||||
}
|
||||
}
|
||||
res.success = true
|
||||
res.path = filePath
|
||||
return res
|
||||
|
@ -157,8 +157,8 @@ async function onSettingWindowCreated (view: Element) {
|
||||
</setting-item>
|
||||
<setting-item data-direction="row" class="vertical-list-item">
|
||||
<div>
|
||||
<div>上报自身消息</div>
|
||||
<div class="tips">慎用,不然会自己和自己聊个不停</div>
|
||||
<div>上报自身发送消息</div>
|
||||
<div class="tips"></div>
|
||||
</div>
|
||||
<setting-switch id="reportSelfMessage" ${config.reportSelfMessage ? 'is-active' : ''}></setting-switch>
|
||||
</setting-item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user