细节优化

This commit is contained in:
🌌 2023-07-19 09:34:22 +08:00
parent e1027169ba
commit 8bd23798ad
3 changed files with 7 additions and 9 deletions

View File

@ -7,6 +7,9 @@ Bot.adapter.push(new class stdinAdapter {
constructor() {
this.id = "stdin"
this.name = "标准输入"
this.path = "data/stdin/"
if (!fs.existsSync(this.path))
fs.mkdirSync(this.path)
}
async makeBuffer(file) {
@ -25,7 +28,7 @@ Bot.adapter.push(new class stdinAdapter {
file.url = data.replace(/^base64:\/\/.*/, "base64://...")
file.buffer = await this.makeBuffer(data)
file.type = await fileTypeFromBuffer(file.buffer)
file.path = `${Bot[this.id].data_dir}${Date.now()}.${file.type.ext}`
file.path = `${this.path}${Date.now()}.${file.type.ext}`
} catch (err) {
logger.error(`文件类型检测错误:${logger.red(err)}`)
}
@ -91,7 +94,7 @@ Bot.adapter.push(new class stdinAdapter {
return false
}
const files = `${Bot[this.id].data_dir}${Date.now()}-${name}`
const files = `${this.path}${Date.now()}-${name}`
logger.info(`${logger.blue(`[${this.id}]`)} 发送文件:${file}\n文件已保存到:${logger.cyan(files)}`)
return fs.writeFileSync(files, buffer)
}
@ -143,13 +146,8 @@ Bot.adapter.push(new class stdinAdapter {
group_id: this.id,
group_name: this.name,
}),
data_dir: `${process.cwd()}/data/stdin/`,
}
if (!fs.existsSync(Bot[this.id].data_dir))
fs.mkdirSync(Bot[this.id].data_dir)
if (!Bot.uin.includes(this.id))
Bot.uin.push(this.id)

View File

@ -32,7 +32,7 @@
"node-xlsx": "^0.23.0",
"oicq": "link:lib/modules/oicq",
"pm2": "^5.3.0",
"puppeteer": "^20.8.2",
"puppeteer": "^20.8.3",
"redis": "^4.6.7",
"sequelize": "^6.32.1",
"sqlite3": "^5.1.6",

View File

@ -589,7 +589,7 @@ Bot.adapter.push(new class gocqhttpAdapter {
makeMessage(data) {
const message = []
for (const i of data.message)
message.push({ type: i.type, ...i.data })
message.push({ ...i.data, type: i.type })
data.message = message
switch (data.message_type) {