浏览代码

调整

d1
H Vs 3 周前
父节点
当前提交
9e75cb9353
共有 1 个文件被更改,包括 22 次插入12 次删除
  1. +22
    -12
      tasks.py

+ 22
- 12
tasks.py 查看文件

@@ -226,7 +226,7 @@ def scheduled_task_add_contacts_from_chatrooms(self, redis_config, kafka_config,
contact_wxids = [c.get('userName') for c in contacts] contact_wxids = [c.get('userName') for c in contacts]
chatrooms = c.get('addContactsFromChatroomIdWhiteList', []) chatrooms = c.get('addContactsFromChatroomIdWhiteList', [])
logger.info(f'{wxid} 定时群成员定时添好友任务开始')
for chatroom_id in chatrooms: for chatroom_id in chatrooms:
chatroom = await gewe_service.get_group_info_from_cache_async(wxid, chatroom_id) chatroom = await gewe_service.get_group_info_from_cache_async(wxid, chatroom_id)
chatroom_member=await gewe_service.get_group_members_from_cache_async(wxid, chatroom_id) chatroom_member=await gewe_service.get_group_members_from_cache_async(wxid, chatroom_id)
@@ -303,17 +303,27 @@ def scheduled_task_add_contacts_from_chatrooms(self, redis_config, kafka_config,




ret, msg, data = await gewe_service.add_group_member_as_friend_async(token_id, app_id, chatroom_id, m.get('wxid'), f'我是群聊"{chatroom_nickname}"群的{nickname}') ret, msg, data = await gewe_service.add_group_member_as_friend_async(token_id, app_id, chatroom_id, m.get('wxid'), f'我是群聊"{chatroom_nickname}"群的{nickname}')
if ret==200:
history=AddGroupContactsHistory.model_validate({
"chatroomId":chatroom_id,
"wxid":wxid,
"contactWixd":contact_wxid,
"addTime":int(time.time())
})
await gewe_service.save_group_add_contacts_history_async(wxid,chatroom_id,contact_wxid,history)
else:
logger.info(f'群好友邀请失败原因:{data}')
# if ret==200:
# history=AddGroupContactsHistory.model_validate({
# "chatroomId":chatroom_id,
# "wxid":wxid,
# "contactWixd":contact_wxid,
# "addTime":int(time.time())
# })
# await gewe_service.save_group_add_contacts_history_async(wxid,chatroom_id,contact_wxid,history)
# else:
# logger.info(f'群好友邀请失败原因:{data}')
if ret!=200:
logger.info(f'群好友邀请失败原因:{ret} {data}')

history=AddGroupContactsHistory.model_validate({
"chatroomId":chatroom_id,
"wxid":wxid,
"contactWixd":contact_wxid,
"addTime":int(time.time())
})
await gewe_service.save_group_add_contacts_history_async(wxid,chatroom_id,contact_wxid,history)

logger.info(f'{nickname} 向 {chatroom_nickname}-{chatroom_id} 群的 {m.get("nickName")}-{m.get("wxid")} 发送好友邀请 {msg}') logger.info(f'{nickname} 向 {chatroom_nickname}-{chatroom_id} 群的 {m.get("nickName")}-{m.get("wxid")} 发送好友邀请 {msg}')
await asyncio.sleep(random.uniform(1.5, 3)) await asyncio.sleep(random.uniform(1.5, 3))
await asyncio.sleep(random.uniform(1.5, 3)) await asyncio.sleep(random.uniform(1.5, 3))


正在加载...
取消
保存