Commit 7a08a40b authored by nanahira's avatar nanahira

bump

parent 344ffc84
......@@ -71,7 +71,10 @@ app.on('message', (session) => {
app
.command('image')
.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 () => {
......
This diff is collapsed.
......@@ -45,7 +45,7 @@
"testEnvironment": "node"
},
"peerDependencies": {
"koishi": "^4.10.10",
"koishi": "^4.11.0",
"koishi-plugin-cache-aragami": "^2.5.0"
},
"devDependencies": {
......@@ -75,7 +75,7 @@
"fast-xml-parser": "^4.0.6",
"file-type": "^16.5.3",
"form-data": "^4.0.0",
"koishi-thirdeye": "^11.1.16",
"koishi-thirdeye": "^11.1.20",
"raw-body": "^2.5.1"
},
"koishi": {
......
......@@ -118,31 +118,34 @@ export class WeComMessenger extends Messenger<WeComBot> {
if (!url) {
return;
}
let buffer: Buffer;
if (url.startsWith('file://')) {
buffer = await fs.promises.readFile(url.slice(7));
} else if (url.startsWith('base64://')) {
buffer = Buffer.from(data.url.slice(9), 'base64');
} else {
buffer = await this.bot.http.get(url, {
responseType: 'arraybuffer',
headers: { accept: type + '/*' },
});
const filePath = url.slice(7);
const buffer = await fs.promises.readFile(filePath);
const filename = path.basename(filePath);
return { buffer, filename };
}
let filename = data.file;
if (!filename) {
if (!url.startsWith('base64://')) {
filename = path.basename(url);
} else {
const fileType = await FileType.fromBuffer(buffer);
if (fileType) {
filename = `media.${fileType.ext}`;
if (url.startsWith('base64://')) {
const buffer = Buffer.from(data.url.slice(9), 'base64');
let filename = data.file;
if (!filename) {
if (!url.startsWith('base64://')) {
filename = path.basename(url);
} 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) {
......
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