koishi-plugin-meinv 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +5 -9
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
const { Context } = require('koishi')
|
|
1
|
+
const { Context, File } = require('koishi')
|
|
2
2
|
const axios = require('axios')
|
|
3
3
|
const fs = require('fs').promises
|
|
4
4
|
const path = require('path')
|
|
5
5
|
|
|
6
|
+
// 创建临时目录
|
|
6
7
|
const TEMP_DIR = path.resolve(__dirname, '../temp')
|
|
7
8
|
fs.mkdir(TEMP_DIR, { recursive: true }).catch(() => {})
|
|
8
9
|
|
|
@@ -50,17 +51,12 @@ exports.apply = (ctx) => {
|
|
|
50
51
|
timeout: 30000
|
|
51
52
|
})
|
|
52
53
|
|
|
53
|
-
// 保存到本地(可选)
|
|
54
54
|
await fs.writeFile(filePath, response.data)
|
|
55
55
|
ctx.logger('meinv').info(`视频下载完成: ${filePath}`)
|
|
56
56
|
|
|
57
|
-
//
|
|
58
|
-
const
|
|
59
|
-
await session.send(
|
|
60
|
-
type: 'file',
|
|
61
|
-
buffer: fileBuffer,
|
|
62
|
-
name: 'meinv.mp4'
|
|
63
|
-
})
|
|
57
|
+
// 第五步:使用 File 类发送(关键!)
|
|
58
|
+
const file = new File(filePath)
|
|
59
|
+
await session.send(file)
|
|
64
60
|
|
|
65
61
|
// 第六步:删除临时文件
|
|
66
62
|
await fs.unlink(filePath).catch(e => {
|