nonebot-plugin-keyreply 0.1.4__tar.gz → 0.1.5__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_keyreply-0.1.4 → nonebot_plugin_keyreply-0.1.5}/PKG-INFO +1 -1
- {nonebot_plugin_keyreply-0.1.4 → nonebot_plugin_keyreply-0.1.5}/nonebot_plugin_keyreply/__init__.py +10 -6
- {nonebot_plugin_keyreply-0.1.4 → nonebot_plugin_keyreply-0.1.5}/pyproject.toml +1 -1
- {nonebot_plugin_keyreply-0.1.4 → nonebot_plugin_keyreply-0.1.5}/README.md +0 -0
- {nonebot_plugin_keyreply-0.1.4 → nonebot_plugin_keyreply-0.1.5}/nonebot_plugin_keyreply/rule_manager.py +0 -0
{nonebot_plugin_keyreply-0.1.4 → nonebot_plugin_keyreply-0.1.5}/nonebot_plugin_keyreply/__init__.py
RENAMED
|
@@ -44,6 +44,10 @@ async def handle_reply(bot: Bot, event: MessageEvent, command_arg: Message = Com
|
|
|
44
44
|
if not args_str:
|
|
45
45
|
await reply_cmd.finish(__plugin_meta__.usage)
|
|
46
46
|
|
|
47
|
+
# 先转义反斜杠,再将真换行符替换为转义后的 \\n,防止 shlex.split 剥离
|
|
48
|
+
args_str = args_str.replace("\r", "")
|
|
49
|
+
args_str = args_str.replace("\\", "\\\\").replace("\n", "\\\\n")
|
|
50
|
+
|
|
47
51
|
# 解析参数
|
|
48
52
|
try:
|
|
49
53
|
args = shlex.split(args_str)
|
|
@@ -86,8 +90,8 @@ async def handle_reply(bot: Bot, event: MessageEvent, command_arg: Message = Com
|
|
|
86
90
|
else:
|
|
87
91
|
group_id = str(event.group_id) if isinstance(event, GroupMessageEvent) else "private"
|
|
88
92
|
|
|
89
|
-
key = clean_args[0]
|
|
90
|
-
reply = " ".join(clean_args[1:])
|
|
93
|
+
key = clean_args[0].replace("\\n", "\n")
|
|
94
|
+
reply = " ".join(clean_args[1:]).replace("\\n", "\n")
|
|
91
95
|
|
|
92
96
|
match_types = {"exact": "精确匹配", "fuzzy": "模糊匹配", "regex": "正则匹配"}
|
|
93
97
|
rule_manager.add_rule(key, reply, match_type, group_id)
|
|
@@ -123,8 +127,8 @@ async def handle_reply(bot: Bot, event: MessageEvent, command_arg: Message = Com
|
|
|
123
127
|
else:
|
|
124
128
|
group_id = str(event.group_id) if isinstance(event, GroupMessageEvent) else "private"
|
|
125
129
|
|
|
126
|
-
key = clean_args[0]
|
|
127
|
-
reply = " ".join(clean_args[1:])
|
|
130
|
+
key = clean_args[0].replace("\\n", "\n")
|
|
131
|
+
reply = " ".join(clean_args[1:]).replace("\\n", "\n")
|
|
128
132
|
|
|
129
133
|
success = rule_manager.edit_rule(key, reply, group_id)
|
|
130
134
|
if success:
|
|
@@ -162,7 +166,7 @@ async def handle_reply(bot: Bot, event: MessageEvent, command_arg: Message = Com
|
|
|
162
166
|
else:
|
|
163
167
|
group_id = str(event.group_id) if isinstance(event, GroupMessageEvent) else "private"
|
|
164
168
|
|
|
165
|
-
key = clean_args[0]
|
|
169
|
+
key = clean_args[0].replace("\\n", "\n")
|
|
166
170
|
|
|
167
171
|
success = rule_manager.del_rule(key, group_id)
|
|
168
172
|
if success:
|
|
@@ -237,7 +241,7 @@ async def handle_reply(bot: Bot, event: MessageEvent, command_arg: Message = Com
|
|
|
237
241
|
await reply_cmd.finish("当前生效的词条关键词列表:\n" + "\n".join(msg_parts))
|
|
238
242
|
else:
|
|
239
243
|
# 查询指定关键词
|
|
240
|
-
key = clean_args[0]
|
|
244
|
+
key = clean_args[0].replace("\\n", "\n")
|
|
241
245
|
rule = rule_manager.get_rule(key, group_id)
|
|
242
246
|
if not rule and group_id != "global":
|
|
243
247
|
# 在当前上下文没找到时,也去全局找一下
|
|
File without changes
|
|
File without changes
|