diff --git a/services/gewe_service.py b/services/gewe_service.py index a11ee9f..43c0bcc 100644 --- a/services/gewe_service.py +++ b/services/gewe_service.py @@ -1101,6 +1101,9 @@ class GeWeService: """ 更新将群信息保存到 Redis 缓存。 """ + + if not check_chatroom(chatroom_id): + return # Redis 缓存的 key hash_key = f"__AI_OPS_WX__:GROUPS_MEMBERS:{wxid}" @@ -1185,6 +1188,8 @@ class GeWeService: """ 更新将群信息保存到 Redis 缓存。 """ + if not check_chatroom(chatroom_id): + return # Redis 缓存的 key hash_key = f"__AI_OPS_WX__:GROUPS_INFO:{wxid}" if not check_chatroom(chatroom_id): diff --git a/tasks.py b/tasks.py index b27d6e4..7792de5 100644 --- a/tasks.py +++ b/tasks.py @@ -722,7 +722,8 @@ def scheduled_task_add_contacts_from_chatrooms(self, redis_config, kafka_config, k_message = wx_add_contacts_from_chatroom_message(history.wxid, history.chatroomId, history.contactWixd, history.addTime) await kafka_service.send_message_async(k_message) # await asyncio.sleep(random.uniform(1.5, 3)) - await asyncio.sleep(random.uniform(30, 60)) + # await asyncio.sleep(random.uniform(30, 60)) + await asyncio.sleep(random.uniform(270,300)) # 任务状态推送到kafka task_status = await gewe_service.wx_add_contacts_from_chatroom_task_status_async(wxid, chatroom_id) k_message=wx_add_contacts_from_chatroom_task_status_message(wxid, chatroom_id, task_status) @@ -733,8 +734,12 @@ def scheduled_task_add_contacts_from_chatrooms(self, redis_config, kafka_config, async def task(): try: now = datetime.now() - if now.hour < 8: - logger.info(f"定时群成员定时添好友任务不启动,当前时间为 {now.strftime('%Y-%m-%d %H:%M:%S')},早于8点") + # if 10> now.hour < 8: + # logger.info(f"定时群成员定时添好友任务不启动,当前时间为 {now.strftime('%Y-%m-%d %H:%M:%S')},早于8点") + # return + + if now.hour < 8 or now.hour > 22: + logger.info(f"定时群成员定时添好友任务不启动, 当前时间为 {now.strftime('%Y-%m-%d %H:%M:%S')},不在8点到22点之间") return logger.info('定时群成员定时添好友任务开始')