keyword 更合理的频率限制

This commit is contained in:
c3b2a 2021-07-03 15:07:59 +08:00 committed by GitHub
parent 1395c71678
commit b0af55dbeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -216,11 +216,13 @@ async def send_reply(chat_id, trigger, mode, reply_msg, context):
if not last_name:
last_name = ""
replace_data["chat_name"] = f"{chat.first_name} {last_name}"
update_last_time = False
could_send_msg = valid_time(chat_id)
if not could_send_msg:
return
message_list = []
for re_type, re_msg in reply_msg:
try:
update_last_time = False
catch_pattern = r"\$\{func_(?P<str>((?!\}).)+)\}"
count = 0
bracket_str = random_str()
@ -256,7 +258,6 @@ async def send_reply(chat_id, trigger, mode, reply_msg, context):
edit_id = int(s[5:])
type_parse.remove(s)
if ("file" in type_parse or "photo" in type_parse) and len(re_msg.split()) >= 2:
if could_send_msg:
update_last_time = True
re_data = re_msg.split(" ")
cache_exists, filename = has_cache(chat_id, mode, trigger, re_data[0])
@ -301,7 +302,6 @@ async def send_reply(chat_id, trigger, mode, reply_msg, context):
if not is_opened:
remove(filename)
elif ("tgfile" in type_parse or "tgphoto" in type_parse) and len(re_msg.split()) >= 2:
if could_send_msg:
update_last_time = True
re_data = re_msg.split(" ")
re_data[0] = " ".join(re_data[0:-1])
@ -357,7 +357,6 @@ async def send_reply(chat_id, trigger, mode, reply_msg, context):
if not is_opened:
remove(filename)
elif "plain" in type_parse:
if could_send_msg:
update_last_time = True
if edit_id == -1:
message_list.append(await bot.send_message(
@ -371,7 +370,6 @@ async def send_reply(chat_id, trigger, mode, reply_msg, context):
link_preview=("nopreview" not in type_parse)
)
elif "reply" in type_parse and chat_id == real_chat_id:
if could_send_msg:
update_last_time = True
if edit_id == -1:
reply_to = context.id
@ -407,14 +405,14 @@ async def send_reply(chat_id, trigger, mode, reply_msg, context):
]
await eval(f"aexec(args[0]{f', {args[1]}' if args[1] else ''})")
chdir(working_dir)
except:
pass
chat_id = real_chat_id
if update_last_time:
global group_last_time
group_last_time[int(chat_id)] = time.time()
except:
pass
chat_id = real_chat_id
except:
pass
@listener(is_plugin=True, outgoing=True, command=alias_command("keyword"),