keyword重复回复bug不稳定修复

This commit is contained in:
c3b2a 2021-06-16 00:02:38 +08:00 committed by GitHub
parent 1693ce412d
commit ed8905220b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import re, time, asyncio, requests, os, json import re, time, asyncio, requests, os, json, random
from io import BytesIO from io import BytesIO
from os import path, mkdir, remove, makedirs, chdir from os import path, mkdir, remove, makedirs, chdir
from shutil import copyfile, move, rmtree from shutil import copyfile, move, rmtree
@ -975,12 +975,15 @@ async def setdata(context):
@listener(incoming=True, outgoing=True, ignore_edited=True) @listener(incoming=True, outgoing=True, ignore_edited=True)
async def auto_reply(context): async def auto_reply(context):
global read_context global read_context
asyncio.sleep(random.randint(0, 100) / 1000)
if (context.chat_id, context.id) in read_context:
return
read_context[(context.chat_id, context.id)] = True
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 (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