nonebot-plugin-pErithacus 1.4.2__tar.gz → 1.4.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/PKG-INFO +1 -1
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/pyproject.toml +1 -1
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/__init__.py +1 -1
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/cmd_search.py +15 -21
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/lib.py +3 -3
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/README.md +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/apscheduler.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/cmd_add.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/cmd_check.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/cmd_delete.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/cmd_detail.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/cmd_edit.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/cmd_list.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/command.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/database.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/handle_args.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/migrations/4184a6a150e9_.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/migrations/59488f45afb7_.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/migrations/bd67704f77ad_.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/migrations/c2cbe27dd921_.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/migrations/cc658325e0ad_.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/trigger.py +0 -0
- {nonebot_plugin_perithacus-1.4.2 → nonebot_plugin_perithacus-1.4.3}/src/nonebot_plugin_perithacus/upgrade_database.py +0 -0
|
@@ -12,11 +12,12 @@ from nonebot_plugin_alconna import (
|
|
|
12
12
|
Query,
|
|
13
13
|
UniMessage,
|
|
14
14
|
)
|
|
15
|
+
from nonebot_plugin_alconna.uniseg.segment import At, Media
|
|
15
16
|
from nonebot_plugin_orm import async_scoped_session # noqa: TC002
|
|
16
17
|
|
|
17
18
|
from .command import pe
|
|
18
19
|
from .database import Index, get_all_contents, get_entries, get_entry_by_id
|
|
19
|
-
from .lib import
|
|
20
|
+
from .lib import get_scope, get_source, load_msg, pe_download
|
|
20
21
|
|
|
21
22
|
if TYPE_CHECKING:
|
|
22
23
|
from collections.abc import Sequence
|
|
@@ -82,19 +83,17 @@ async def _( # noqa: PLR0913
|
|
|
82
83
|
await pe.finish(UniMessage("搜索结果:\n无"))
|
|
83
84
|
|
|
84
85
|
async def get_key(keyword: Match) -> str:
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
msg = UniMessage(keyword.result) if not isinstance(keyword.result, UniMessage) else keyword.result
|
|
87
|
+
msg = await pe_download(msg)
|
|
87
88
|
|
|
88
89
|
# 检查pe_message_list中的每个元素
|
|
89
90
|
key = None
|
|
90
|
-
for
|
|
91
|
-
if
|
|
92
|
-
|
|
93
|
-
if item.get("media"):
|
|
94
|
-
key = item["id"]
|
|
91
|
+
for seg in msg:
|
|
92
|
+
if isinstance(seg, Media):
|
|
93
|
+
key = seg.id
|
|
95
94
|
break
|
|
96
|
-
if
|
|
97
|
-
key =
|
|
95
|
+
if isinstance(seg, At):
|
|
96
|
+
key = seg.target
|
|
98
97
|
break
|
|
99
98
|
if not key:
|
|
100
99
|
key = UniMessage(keyword.result).extract_plain_text()
|
|
@@ -110,9 +109,7 @@ async def search_in_entries(
|
|
|
110
109
|
# 检查keyword列和alias列包含key的行
|
|
111
110
|
if key in entry.keyword or (entry.alias and key in entry.alias):
|
|
112
111
|
result_list.append(entry.id)
|
|
113
|
-
logger.info(
|
|
114
|
-
f"在 Index 中找到匹配的词条 {entry.id},关键词 {entry.keyword}"
|
|
115
|
-
)
|
|
112
|
+
logger.info(f"在 Index 中找到匹配的词条 {entry.id},关键词 {entry.keyword}")
|
|
116
113
|
return result_list
|
|
117
114
|
|
|
118
115
|
async def search_in_contents(
|
|
@@ -124,14 +121,11 @@ async def search_in_contents(
|
|
|
124
121
|
) -> list[int]:
|
|
125
122
|
contents = await get_all_contents(session)
|
|
126
123
|
for content in contents:
|
|
127
|
-
if not content.deleted and key in content.content
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
logger.debug(f"跳过词条 {content.entry_id},该词条已存在搜索结果中")
|
|
133
|
-
else:
|
|
134
|
-
logger.debug(f"未在 {content.entry_id} 中找到包含 {key} 的内容")
|
|
124
|
+
if ((not content.deleted and key in content.content)
|
|
125
|
+
and (content.entry_id not in result_list)
|
|
126
|
+
and (not await check_is_deleted(session, content.entry_id, scope_list))):
|
|
127
|
+
result_list.append(content.entry_id)
|
|
128
|
+
logger.debug(f"在 {content.entry_id} 中找到包含 {key} 的内容")
|
|
135
129
|
|
|
136
130
|
return result_list
|
|
137
131
|
|
|
@@ -247,10 +247,10 @@ async def pe_download(
|
|
|
247
247
|
stream (bool, optional): 是否以流式下载. Defaults to False.
|
|
248
248
|
**kwargs: 传递给下载器的参数
|
|
249
249
|
"""
|
|
250
|
-
logger.debug("开始下载媒体数据")
|
|
251
250
|
for media in self.select(Media):
|
|
252
251
|
if not media.url:
|
|
253
252
|
continue
|
|
253
|
+
logger.debug("开始下载媒体数据")
|
|
254
254
|
raw: bytes = b""
|
|
255
255
|
async with httpx.AsyncClient(**kwargs) as client:
|
|
256
256
|
if stream:
|
|
@@ -363,7 +363,7 @@ def pe_save(
|
|
|
363
363
|
return path.resolve()
|
|
364
364
|
|
|
365
365
|
async def dump_msg(
|
|
366
|
-
msg: UniMessage,
|
|
366
|
+
msg: UniMessage | str | tuple,
|
|
367
367
|
*,
|
|
368
368
|
media_save_dir: str | Path | bool | None = MEDIA_SAVE_DIR
|
|
369
369
|
) -> str:
|
|
@@ -382,7 +382,7 @@ async def dump_msg(
|
|
|
382
382
|
:rtype: str
|
|
383
383
|
"""
|
|
384
384
|
|
|
385
|
-
if isinstance(msg,
|
|
385
|
+
if not isinstance(msg, UniMessage):
|
|
386
386
|
msg = UniMessage(msg)
|
|
387
387
|
|
|
388
388
|
msg = await pe_download(msg)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|