Skip to content

Commit

Permalink
fix #137
Browse files Browse the repository at this point in the history
  • Loading branch information
lgc2333 committed Aug 20, 2024
1 parent b35f9e2 commit 3bfab3c
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 132 deletions.
2 changes: 1 addition & 1 deletion YetAnotherPicSearch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

load_search_func()

__version__ = "2.0.0"
__version__ = "2.0.1"
__plugin_meta__ = PluginMetadata(
name="YetAnotherPicSearch",
description="基于 NoneBot2 及 PicImageSearch 的另一个 NoneBot 搜图插件",
Expand Down
6 changes: 4 additions & 2 deletions YetAnotherPicSearch/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ def pre_process_msg(m: UniMessage):
if not display_fav:
should_remove.append("❤️ 已收藏\n")
for txt in should_remove:
if seg := next((x for x in m[Text] if (txt in x.text)), None):
# alconna 的 text auto merge 害人
# for seg in (x for x in m[Text] if (txt in x.text)):
for seg in (x for x in m if isinstance(x, Text) and (txt in x.text)):
seg.text = seg.text.replace(txt, "")

return m
Expand Down Expand Up @@ -288,7 +290,7 @@ async def fetch_image(seg: Image) -> Optional[bytes]:
while True:
res = await func(file, client, mode)
msgs, func = res if isinstance(res, tuple) else (res, None)
messages.extend(msgs)
messages.extend([x.copy() for x in msgs])
await send_msgs(msgs, target, index, display_fav)
if not func:
break
Expand Down
3 changes: 1 addition & 2 deletions YetAnotherPicSearch/data_source/ehentai.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ async def ehentai_search(
if not (res := await ehentai.search(file=file, ex=ex)):
if "Please wait a bit longer between each file search" in res.origin:
return await ehentai_search(file, client, mode)

else:
final_res = await search_result_filter(res)
if not res.raw and config.auto_use_ascii2d:
final_res.append(UniMessage.text("自动使用 Ascii2D 进行搜索"))
return final_res, ascii2d_search

return final_res

return [UniMessage.text("EHentai 暂时无法使用")]
Expand Down
9 changes: 5 additions & 4 deletions YetAnotherPicSearch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,10 @@ def combine_message(
join: Optional[str] = "\n",
) -> UniMessage:
msg = UniMessage()
for it in msg_list:
if it:
msg += it
if join:
for i, it in enumerate(msg_list):
if not it:
continue
if join and i != 0:
msg += join
msg += it
return msg
Loading

0 comments on commit 3bfab3c

Please sign in to comment.