Skip to content

Commit

Permalink
🐛 version 0.2.2
Browse files Browse the repository at this point in the history
remove fetch image by knock url
  • Loading branch information
RF-Tar-Railt committed Sep 15, 2023
1 parent 9f4f9d4 commit 4618c25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
17 changes: 4 additions & 13 deletions nonebot/adapters/red/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,7 @@ async def download(self, bot: "Bot") -> bytes:
if path.exists():
with path.open("rb") as f:
return f.read()
if self.type == "image":
resp = await bot.adapter.request(
Request(
"GET",
f"https://gchat.qpic.cn/gchatpic_new/0/0-0-{self.data['md5'].upper()}/0",
)
)
if resp.status_code == 200:
return resp.content # type: ignore
resp1 = await bot.adapter.request(
resp = await bot.adapter.request(
Request(
"POST",
bot.info.api_base / "message" / "fetchRichMedia",
Expand All @@ -228,9 +219,9 @@ async def download(self, bot: "Bot") -> bytes:
},
)
)
if resp1.status_code == 200:
return resp1.content # type: ignore
raise NetworkError("red", resp1)
if resp.status_code == 200:
return resp.content # type: ignore
raise NetworkError("red", resp)

async def upload(self, bot: "Bot") -> dict:
data = self.data["file"] if self.data.get("file") else await self.download(bot)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "nonebot-adapter-red"
version = "0.2.1"
version = "0.2.2"
description = "Red Protocol Adapter for Nonebot2"
authors = [
{name = "zhaomaoniu"},
Expand Down

0 comments on commit 4618c25

Please sign in to comment.