Skip to content

Commit

Permalink
细节优化
Browse files Browse the repository at this point in the history
  • Loading branch information
TimeRainStarSky committed Sep 22, 2024
1 parent a413c2b commit f28f423
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export default class Yunzai extends EventEmitter {
else if (data.match(/^https?:\/\//))
return opts.http ? data : Buffer.from(await (await fetch(data, opts)).arrayBuffer())
else if (await this.fsStat(data.replace(/^file:\/\//, "")))
return opts.file ? data : Buffer.from(await fs.readFile(data.replace(/^file:\/\//, "")))
return opts.file ? `file://${path.resolve(data.replace(/^file:\/\//, ""))}` : Buffer.from(await fs.readFile(data))
return data
}

Expand Down
8 changes: 4 additions & 4 deletions plugins/adapter/OneBotv11.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Bot.adapter.push(new class OneBotv11Adapter {
)
}

async makeFile(file) {
file = await Bot.Buffer(file, { http: true })
async makeFile(file, opts) {
file = await Bot.Buffer(file, { http: true, ...opts })
if (Buffer.isBuffer(file))
file = `base64://${file.toString("base64")}`
return file
Expand Down Expand Up @@ -496,7 +496,7 @@ Bot.adapter.push(new class OneBotv11Adapter {
Bot.makeLog("info", `发送好友文件:${name}(${file})`, `${data.self_id} => ${data.user_id}`)
return data.bot.sendApi("upload_private_file", {
user_id: data.user_id,
file: await this.makeFile(file),
file: await this.makeFile(file, { file: true }),
name,
})
}
Expand All @@ -506,7 +506,7 @@ Bot.adapter.push(new class OneBotv11Adapter {
return data.bot.sendApi("upload_group_file", {
group_id: data.group_id,
folder,
file: await this.makeFile(file),
file: await this.makeFile(file, { file: true }),
name,
})
}
Expand Down

0 comments on commit f28f423

Please sign in to comment.