mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0a3ae76b89 | ||
![]() |
ddd60a6a79 | ||
![]() |
e4d8c5e72e | ||
![]() |
6d33fb8b14 | ||
![]() |
2350e4dc75 |
@@ -56,3 +56,6 @@
|
||||

|
||||
|
||||
*暂时不支持`"message": "hello"`这种message为字符串的形式*
|
||||
|
||||
## onebot11文档
|
||||
<https://11.onebot.dev/>
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"name": "LLOneBot",
|
||||
"slug": "LLOneBot",
|
||||
"description": "LiteLoaderQQNT的OneBotApi",
|
||||
"version": "1.2.6",
|
||||
"version": "1.2.7",
|
||||
"thumbnail": "./icon.png",
|
||||
"author": {
|
||||
"name": "linyuchen",
|
||||
|
@@ -114,7 +114,7 @@ export type SendMessage = {
|
||||
text: string, // 纯文本
|
||||
}
|
||||
} | {
|
||||
type: "image" | "voice",
|
||||
type: "image" | "voice" | "record",
|
||||
file: string, // 本地路径
|
||||
data?: {
|
||||
file: string // 本地路径
|
||||
|
@@ -17,7 +17,7 @@ import {
|
||||
} from "../common/IPCChannel";
|
||||
import {ConfigUtil} from "./config";
|
||||
import {startExpress} from "./HttpServer";
|
||||
import {log} from "./utils";
|
||||
import {isGIF, log} from "./utils";
|
||||
import {friends, groups, selfInfo} from "./data";
|
||||
|
||||
const fs = require('fs');
|
||||
@@ -55,7 +55,10 @@ function onLoad(plugin: any) {
|
||||
let buffer = await blob.arrayBuffer();
|
||||
fs.writeFileSync(arg.localFilePath, Buffer.from(buffer));
|
||||
}
|
||||
// todo: 需要识别gif格式
|
||||
if (isGIF(arg.localFilePath)) {
|
||||
fs.renameSync(arg.localFilePath, arg.localFilePath + ".gif");
|
||||
arg.localFilePath += ".gif";
|
||||
}
|
||||
return arg.localFilePath;
|
||||
})
|
||||
ipcMain.on(CHANNEL_SET_CONFIG, (event: any, arg: Config) => {
|
||||
|
@@ -5,4 +5,12 @@ export function log(msg: any) {
|
||||
fs.appendFile("./llonebot.log", currentDateTime + ":" + msg + "\n", (err: any) => {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
export function isGIF(path: string) {
|
||||
const buffer = Buffer.alloc(4);
|
||||
const fd = fs.openSync(path, 'r');
|
||||
fs.readSync(fd, buffer, 0, 4, 0);
|
||||
fs.closeSync(fd);
|
||||
return buffer.toString() === 'GIF8'
|
||||
}
|
@@ -227,23 +227,23 @@ async function listenSendMessage(postData: PostDataSendMsg) {
|
||||
message.content = `@${atMember.cardName || atMember.nick}`
|
||||
} else if (message.type == "text") {
|
||||
message.content = message.data?.text || message.content
|
||||
} else if (message.type == "image" || message.type == "voice") {
|
||||
} else if (message.type == "image" || message.type == "voice" || message.type == "record") {
|
||||
// todo: 收到的应该是uri格式的,需要转成本地的, uri格式有三种,http, file, base64
|
||||
let url = message.data?.file || message.file
|
||||
let uri = new URL(url);
|
||||
let ext: string;
|
||||
if (message.type == "image") {
|
||||
// todo: 需要识别gif格式
|
||||
ext = ".png"
|
||||
}
|
||||
if (message.type == "voice") {
|
||||
if (message.type == "voice" || message.type == "record") {
|
||||
message.type = "voice"
|
||||
ext = ".amr"
|
||||
}
|
||||
let localFilePath = `${Date.now()}${ext}`
|
||||
if (uri.protocol == "file:") {
|
||||
localFilePath = url.split("file://")[1]
|
||||
} else {
|
||||
await window.llonebot.downloadFile({uri: url, localFilePath: localFilePath})
|
||||
localFilePath = await window.llonebot.downloadFile({uri: url, localFilePath: localFilePath})
|
||||
}
|
||||
message.file = localFilePath
|
||||
sendFiles.push(localFilePath);
|
||||
|
Reference in New Issue
Block a user