Skip to content

Commit d208bae

Browse files
committed
```
fix(command): 修改正则匹配选项短名称为 `-R` 将正则匹配选项的短名称从 `-re` 更改为 `-R`,以避免与 `-r` 或其他可能的短名称冲突。 docs(readme): 更新命令行选项说明和示例 更新 README 中 `pe edit` 和 `pe list` 命令的选项描述及使用示例,确保文档与实际功能一致。 feat(list): 修复使用 --all 选项列出所有作用域中的词条不起作用的问题 新增 `pe list -a` 命令用法,支持查看词库中所有未删除的词条。 refactor(cmd_check): 修复使用 --force 选项强制查看被删除词条不起作用的问题 优化 `cmd_check.py` 中对 `force` 选项的判断方式,去除冗余的 `.available` 检查。 feat(timezone): 时间显示调整为北京时间 在 `cmd_check.py` 和 `cmd_detail.py` 中增加时区转换逻辑,将 UTC 时间转为北京时间后显示。 build(version): 发布版本 v1.1.3 更新项目版本号至 v1.1.3,并同步更新 `pyproject.toml` 和插件元数据中的版本信息。 ```
1 parent b330706 commit d208bae

8 files changed

Lines changed: 30 additions & 21 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ pe edit <关键词> [选项...]
239239
- `-m`, `--match`: 修改当前的匹配方式(精准/模糊)。
240240
- `-c`, `--cron`: 替换当前的cron表达式。详见[CRON 表达式](#CRON-表达式)
241241
- `-s`, `--scope`: 作用域。该参数配合<关键词>进行词条查询,默认为当前会话所在作用域。指定作用域时,将会根据指定作用域对应的词条,并向其添加作用域。详见[作用域](#作用域)
242-
- `-re`, `--regex`: 修改正则匹配的正则表达式。当存在正则表达式时,将不会进行模糊匹配。
242+
- `-R`, `--regex`: 修改正则匹配的正则表达式。当存在正则表达式时,将不会进行模糊匹配。
243243
- `-a`, `--alias`: 为词条添加别名。一次只能添加一个别名。
244244
- `-d`, `--delete`: 删除指定ID的回复内容
245245
- `-rep`, `--replace`: 替换指定ID的回复内容
@@ -291,10 +291,14 @@ pe add 晨报 新的一天开始了! -c 0#9#*#*#*
291291
```
292292
pe add 笑话 这是一个有趣的笑话 -m 模糊
293293
```
294-
查看所有词条
294+
查看当前作用域的所有未删除词条
295295
```
296296
pe list
297297
```
298+
查看词库所有未删除的词条:
299+
```
300+
pe list -a
301+
```
298302
搜索相关词条:
299303
```
300304
pe search 笑话

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "nonebot-plugin-pErithacus"
3-
version = "1.1.2"
3+
version = "1.1.3"
44
description = "pErithacus 是一个基于 NoneBot2 框架的聊天插件,可以根据用户设定的关键词自动回复相关内容。该插件提供了完整的词条管理功能,让用户能够轻松创建、编辑和管理自定义回复内容"
55
readme = "README.md"
66
requires-python = ">=3.12, <4.0"

src/nonebot_plugin_perithacus/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
driver = get_driver()
2727

28-
__version__ = "1.1.2"
28+
__version__ = "1.1.3"
2929
__plugin_meta__ = PluginMetadata(
3030
name="pErithacus",
3131
description=("pErithacus 是一个基于 NoneBot2 框架的聊天插件,"

src/nonebot_plugin_perithacus/cmd_check.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from datetime import timedelta, timezone
23

34
from nonebot_plugin_alconna import AlconnaMatch, AlconnaQuery, Match, Query, UniMessage
45
from nonebot_plugin_orm import async_scoped_session # noqa: TC002
@@ -19,8 +20,12 @@ async def _(
1920

2021
entry = await get_entry_by_id(session, entry_id.result)
2122
if entry:
22-
if force.available or not entry.deleted:
23+
if force.result or not entry.deleted:
2324
keyword = load_media(entry.keyword)
25+
# 将UTC时间转换为北京时间
26+
beijing_tz = timezone(timedelta(hours=8))
27+
date_create = entry.date_create.astimezone(beijing_tz)
28+
date_modified = entry.date_modified.astimezone(beijing_tz)
2429

2530
aliases = UniMessage()
2631
if entry.alias:
@@ -37,8 +42,8 @@ async def _(
3742
f"正则表达式:{entry.reg}\n" +
3843
f"来源:{entry.source}\n" +
3944
f"删除:{entry.deleted}\n" +
40-
f"创建时间:{entry.date_create}\n" +
41-
f"修改时间:{entry.date_modified}\n" +
45+
f"创建时间:{date_create}\n" +
46+
f"修改时间:{date_modified}\n" +
4247
"别名:" + aliases
4348
)
4449
else:
@@ -52,11 +57,11 @@ async def _(
5257
f"正则表达式:{entry.reg}\n" +
5358
f"来源:{entry.source}\n" +
5459
f"删除:{entry.deleted}\n" +
55-
f"创建时间:{entry.date_create}\n" +
56-
f"修改时间:{entry.date_modified}\n" +
60+
f"创建时间:{date_create}\n" +
61+
f"修改时间:{date_modified}\n" +
5762
f"别名:{aliases}"
5863
)
59-
elif not force.available and entry.deleted:
64+
elif not force.result and entry.deleted:
6065
await pe.finish(
6166
"请输入有效的词条 ID 。使用 search 或 list 命令查看词条列表。"
6267
)

src/nonebot_plugin_perithacus/cmd_detail.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from datetime import timedelta, timezone
2+
13
from nonebot_plugin_alconna import AlconnaMatch, AlconnaQuery, Match, Query, UniMessage
24
from nonebot_plugin_orm import async_scoped_session # noqa: TC002
35

@@ -16,7 +18,7 @@ async def _(
1618
):
1719
entry = await get_entry_by_id(session, entry_id.result)
1820
if entry:
19-
if force.available or not entry.deleted:
21+
if force.result or not entry.deleted:
2022
rows = await get_contents(entry_id.result)
2123

2224
# 分页处理
@@ -41,17 +43,19 @@ async def _(
4143
)
4244

4345
# 显示当前页的内容
46+
beijing_tz = timezone(timedelta(hours=8))
4447
for i in range(start_index, end_index):
4548
row = rows[i]
49+
date_modified = row.date_modified.astimezone(beijing_tz)
4650
msg.extend(
4751
f"{row.id} " +
4852
load_media(row.content) +
49-
f" 时间: {row.date_modified}\n"
53+
f" 时间: {date_modified}\n"
5054
)
5155

5256
await pe.finish(msg)
5357

54-
elif not force.available and entry.deleted:
58+
elif not force.result and entry.deleted:
5559
await pe.finish(
5660
"请输入有效的词条 ID 。使用 search 或 list 命令查看词条列表。"
5761
)

src/nonebot_plugin_perithacus/cmd_list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def _(
4141
if not s.startswith(("g", "u")):
4242
await pe.finish("scope参数必须以g或u开头")
4343

44-
if is_all.available and is_all.result:
44+
if is_all.result:
4545
entries = await get_entries(session, scope_list, is_all=True)
4646
else:
4747
entries = await get_entries(session, scope_list)

src/nonebot_plugin_perithacus/cmd_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async def _(
6666
if not key:
6767
key = UniMessage(keyword.result).extract_plain_text()
6868

69-
if is_all.available and is_all.result:
69+
if is_all.result:
7070
entries = await get_entries(session, scope_list, is_all=True)
7171
else:
7272
entries = await get_entries(session, scope_list)

src/nonebot_plugin_perithacus/command.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@
4444
Arg("page?#页码", int, notice="列出指定页的搜索结果"),
4545
),
4646
Option("-s|--scope", Args["scope#作用域", str], default=""),
47-
Option(
48-
"-a|--all",
49-
Args["is_all#是否列出所有作用域的搜索结果", bool],
50-
default=False
51-
),
47+
Option("-a|--all"),
5248
help_text="搜索词条",
5349
),
5450
Subcommand(
@@ -79,7 +75,7 @@
7975
),
8076
Option("-c|--cron", Args["cron#定时触发的cron表达式", str], default=""),
8177
Option("-s|--scope", Args["scope#作用域群号", str], default=""),
82-
Option("-re|--regex", Args["reg#正则匹配的正则表达式", str], default=""),
78+
Option("-R|--regex", Args["reg#正则匹配的正则表达式", str], default=""),
8379
Option("-a|--alias", Args["alias#为词条添加别名", str], default=""),
8480
Option("-d|--delete", Args["delete_id#删除指定id的回复", int], default=0),
8581
Option(

0 commit comments

Comments
 (0)