Skip to content

Commit

Permalink
🐛 修复fetch的内容解析问题 (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
Well2333 authored May 3, 2024
1 parent 8a8f6b4 commit bf7adcc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
19 changes: 8 additions & 11 deletions nonebot_plugin_bilichat/commands/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ async def check_dynamic_v11(target: MsgTarget, uid: Message = CommandArg()):
await UniMessage(Image(raw=image)).send(target=target)


async def _bili_check(state: T_State, msg: UniMsg, target: MsgTarget) -> bool:
bili_fetch_content = bilichat.command("fetch", aliases=set(plugin_config.bilichat_cmd_fetch), block=True)


@bili_fetch_content.handle()
async def fetch_check(state: T_State, msg: UniMsg, target: MsgTarget):
_msgs = msg.copy()
if Reply in msg:
# 如果是回复消息
Expand All @@ -56,7 +60,7 @@ async def _bili_check(state: T_State, msg: UniMsg, target: MsgTarget) -> bool:
break

if not bililink:
return False
raise FinishedException

content: Column | Video | Dynamic | None = None

Expand All @@ -80,18 +84,11 @@ async def _bili_check(state: T_State, msg: UniMsg, target: MsgTarget) -> bool:
state["_content_"] = content
else:
raise AbortError(f"查询 {bililink} 返回内容为空")

return True
except AbortError as e:
logger.info(e)
return False
raise FinishedException
except FinishedException:
return False


bili_fetch_content = bilichat.command(
"fetch", aliases=set(plugin_config.bilichat_cmd_fetch), rule=_bili_check, block=True
)
raise FinishedException


@bili_fetch_content.handle()
Expand Down
4 changes: 2 additions & 2 deletions nonebot_plugin_bilichat/content/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ async def fetch_content(self) -> list[bytes] | list[None]:
items = self.raw["modules"]["module_dynamic"]["major"]["draw"]["items"]
elif self.raw_type == "grpc":
for module in self.raw["modules"]:
if module["module_type"] == "module_dynamic":
items = module["dynDraw"]["items"]
if module["moduleType"] == "module_dynamic":
items = module["moduleDynamic"]["dynDraw"]["items"]
break
for item in items:
resq = await hc.get(item["src"])
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "nonebot-plugin-bilichat"

version = "5.9.0"
version = "5.9.1"

description = "多种B站链接解析,视频词云,AI总结,你想要的都在 bilichat"
authors = [
Expand Down

0 comments on commit bf7adcc

Please sign in to comment.