瀏覽代碼

调整

1257
H Vs 1 周之前
父節點
當前提交
53205d17cc
共有 2 個檔案被更改,包括 13 行新增3 行删除
  1. +5
    -0
      services/gewe_service.py
  2. +8
    -3
      tasks.py

+ 5
- 0
services/gewe_service.py 查看文件

@@ -1101,6 +1101,9 @@ class GeWeService:
""" """
更新将群信息保存到 Redis 缓存。 更新将群信息保存到 Redis 缓存。
""" """

if not check_chatroom(chatroom_id):
return
# Redis 缓存的 key # Redis 缓存的 key
hash_key = f"__AI_OPS_WX__:GROUPS_MEMBERS:{wxid}" hash_key = f"__AI_OPS_WX__:GROUPS_MEMBERS:{wxid}"


@@ -1185,6 +1188,8 @@ class GeWeService:
""" """
更新将群信息保存到 Redis 缓存。 更新将群信息保存到 Redis 缓存。
""" """
if not check_chatroom(chatroom_id):
return
# Redis 缓存的 key # Redis 缓存的 key
hash_key = f"__AI_OPS_WX__:GROUPS_INFO:{wxid}" hash_key = f"__AI_OPS_WX__:GROUPS_INFO:{wxid}"
if not check_chatroom(chatroom_id): if not check_chatroom(chatroom_id):


+ 8
- 3
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) 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 kafka_service.send_message_async(k_message)
# await asyncio.sleep(random.uniform(1.5, 3)) # 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 # 任务状态推送到kafka
task_status = await gewe_service.wx_add_contacts_from_chatroom_task_status_async(wxid, chatroom_id) 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) 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(): async def task():
try: try:
now = datetime.now() 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 return


logger.info('定时群成员定时添好友任务开始') logger.info('定时群成员定时添好友任务开始')


Loading…
取消
儲存