Commit 7a08a40b authored by nanahira's avatar nanahira

bump

parent 344ffc84
...@@ -71,7 +71,10 @@ app.on('message', (session) => { ...@@ -71,7 +71,10 @@ app.on('message', (session) => {
app app
.command('image') .command('image')
.action(async () => .action(async () =>
segment.image(await fs.promises.readFile(__dirname + '/10000.jpg')), segment.image(
await fs.promises.readFile(__dirname + '/10000.jpg'),
'image/jpeg',
),
); );
app.command('markdown').action(async () => { app.command('markdown').action(async () => {
......
This diff is collapsed.
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
"testEnvironment": "node" "testEnvironment": "node"
}, },
"peerDependencies": { "peerDependencies": {
"koishi": "^4.10.10", "koishi": "^4.11.0",
"koishi-plugin-cache-aragami": "^2.5.0" "koishi-plugin-cache-aragami": "^2.5.0"
}, },
"devDependencies": { "devDependencies": {
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
"fast-xml-parser": "^4.0.6", "fast-xml-parser": "^4.0.6",
"file-type": "^16.5.3", "file-type": "^16.5.3",
"form-data": "^4.0.0", "form-data": "^4.0.0",
"koishi-thirdeye": "^11.1.16", "koishi-thirdeye": "^11.1.20",
"raw-body": "^2.5.1" "raw-body": "^2.5.1"
}, },
"koishi": { "koishi": {
......
...@@ -118,31 +118,34 @@ export class WeComMessenger extends Messenger<WeComBot> { ...@@ -118,31 +118,34 @@ export class WeComMessenger extends Messenger<WeComBot> {
if (!url) { if (!url) {
return; return;
} }
let buffer: Buffer;
if (url.startsWith('file://')) { if (url.startsWith('file://')) {
buffer = await fs.promises.readFile(url.slice(7)); const filePath = url.slice(7);
} else if (url.startsWith('base64://')) { const buffer = await fs.promises.readFile(filePath);
buffer = Buffer.from(data.url.slice(9), 'base64'); const filename = path.basename(filePath);
} else { return { buffer, filename };
buffer = await this.bot.http.get(url, {
responseType: 'arraybuffer',
headers: { accept: type + '/*' },
});
} }
let filename = data.file;
if (!filename) { if (url.startsWith('base64://')) {
if (!url.startsWith('base64://')) { const buffer = Buffer.from(data.url.slice(9), 'base64');
filename = path.basename(url); let filename = data.file;
} else { if (!filename) {
const fileType = await FileType.fromBuffer(buffer); if (!url.startsWith('base64://')) {
if (fileType) { filename = path.basename(url);
filename = `media.${fileType.ext}`;
} else { } else {
filename = 'media.bin'; const fileType = await FileType.fromBuffer(buffer);
if (fileType) {
filename = `media.${fileType.ext}`;
} else {
filename = 'media.bin';
}
} }
} }
return { buffer, filename };
} }
return { buffer, filename };
const info = await this.bot.http.file(url);
return { buffer: Buffer.from(info.data), filename: info.filename };
} }
private text(content: string) { private text(content: string) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment