keyword 问题修复

This commit is contained in:
c3b2a 2021-04-04 23:22:54 +08:00
parent 51e01490a2
commit 3fd37a3147
No known key found for this signature in database
GPG Key ID: 99AF7FB0C31367BB

View File

@ -972,14 +972,15 @@ async def setdata(context):
return return
@listener(incoming=True, outgoing=True, ignore_edited=False) @listener(incoming=True, outgoing=True, ignore_edited=True)
async def auto_reply(context): async def auto_reply(context):
global read_context
if not redis_status(): if not redis_status():
return return
try: try:
chat_id = context.chat_id chat_id = context.chat_id
sender_id = context.sender_id sender_id = context.sender_id
if f"{chat_id}:{context.id}" not in read_context: if (chat_id, context.id) not in read_context:
n_settings = get_redis(f"keyword.{chat_id}.settings") n_settings = get_redis(f"keyword.{chat_id}.settings")
if n_settings.get("status", "1") == "0": if n_settings.get("status", "1") == "0":
return return
@ -1019,7 +1020,7 @@ async def auto_reply(context):
if tmp: if tmp:
could_reply = validate(str(sender_id), int(tmp.get("mode", "0")), tmp.get("list", [])) could_reply = validate(str(sender_id), int(tmp.get("mode", "0")), tmp.get("list", []))
if could_reply and (not self_sent or validsent(int(trig), tmp)): if could_reply and (not self_sent or validsent(int(trig), tmp)):
read_context[f"{chat_id}:{context.id}"] = None read_context[(chat_id, context.id)] = None
await send_reply(chat_id, k, "plain", parse_multi(v), context) await send_reply(chat_id, k, "plain", parse_multi(v), context)
for k, v in regex_dict.items(): for k, v in regex_dict.items():
pattern = re.compile(k) pattern = re.compile(k)
@ -1029,7 +1030,7 @@ async def auto_reply(context):
if tmp: if tmp:
could_reply = validate(str(sender_id), int(tmp.get("mode", "0")), tmp.get("list", [])) could_reply = validate(str(sender_id), int(tmp.get("mode", "0")), tmp.get("list", []))
if could_reply and (not self_sent or validsent(int(trig), tmp)): if could_reply and (not self_sent or validsent(int(trig), tmp)):
read_context[f"{chat_id}:{context.id}"] = None read_context[(chat_id, context.id)] = None
catch_pattern = r"\$\{regex_(?P<str>((?!\}).)+)\}" catch_pattern = r"\$\{regex_(?P<str>((?!\}).)+)\}"
count = 0 count = 0
while re.search(catch_pattern, v) and count < 20: while re.search(catch_pattern, v) and count < 20: