Skip to content

Commit

Permalink
🐛 fix voice send error
Browse files Browse the repository at this point in the history
resolve #26
  • Loading branch information
RF-Tar-Railt committed Oct 16, 2023
1 parent 69bb6fe commit d4c9dc0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nonebot/adapters/red/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,17 @@ async def download(self, bot: "Bot") -> bytes:

async def upload(self, bot: "Bot") -> UploadResponse:
data = self.data["file"] if self.data.get("file") else await self.download(bot)
filename = f"{self.type}_{id(self)}"
if self.type == "voice":
filename += ".amr"
resp = await bot.adapter.request(
Request(
"POST",
bot.info.api_base / "upload",
headers={
"Authorization": f"Bearer {bot.info.token}",
},
files={f"file_{self.type}": (f"file_{self.type}", data)},
files={f"file_{self.type}": (filename, data)},
)
)
return UploadResponse.parse_raw(resp.content)
Expand Down

0 comments on commit d4c9dc0

Please sign in to comment.