server启动之后,填入callback
This commit is contained in:
9
robot.py
9
robot.py
@@ -41,6 +41,7 @@ class Robot(Job):
|
|||||||
def __init__(self, config: Config) -> None:
|
def __init__(self, config: Config) -> None:
|
||||||
self.client = gewe_client.client
|
self.client = gewe_client.client
|
||||||
self.config = config
|
self.config = config
|
||||||
|
self.app_id = gewe_client.app_id
|
||||||
self.LOG = logging.getLogger("Robot")
|
self.LOG = logging.getLogger("Robot")
|
||||||
|
|
||||||
self.LOG.info(f"DB+REDIS 连接池开始初始化")
|
self.LOG.info(f"DB+REDIS 连接池开始初始化")
|
||||||
@@ -62,7 +63,7 @@ class Robot(Job):
|
|||||||
self.contact_manager.set_contacts(self.allContacts)
|
self.contact_manager.set_contacts(self.allContacts)
|
||||||
|
|
||||||
# 获取个人信息
|
# 获取个人信息
|
||||||
obj = json_to_object(self.client.get_profile(self.client.app_id))
|
obj = json_to_object(self.client.get_profile(self.app_id))
|
||||||
if obj.data.wxid is None:
|
if obj.data.wxid is None:
|
||||||
self.LOG.info(f"获取个人信息失败,退出程序!")
|
self.LOG.info(f"获取个人信息失败,退出程序!")
|
||||||
return
|
return
|
||||||
@@ -466,7 +467,7 @@ class Robot(Job):
|
|||||||
batch_wxids = wxids[i:i + batch_size]
|
batch_wxids = wxids[i:i + batch_size]
|
||||||
|
|
||||||
# 批量获取联系人详细信息
|
# 批量获取联系人详细信息
|
||||||
contact_info = self.client.get_detail_info(self.client.app_id, batch_wxids)
|
contact_info = self.client.get_detail_info(self.app_id, batch_wxids)
|
||||||
self.LOG.info(f"获取联系人详细信息响应: {contact_info}")
|
self.LOG.info(f"获取联系人详细信息响应: {contact_info}")
|
||||||
# 处理返回的数据
|
# 处理返回的数据
|
||||||
if contact_info and contact_info.get("ret") == 200 and "data" in contact_info:
|
if contact_info and contact_info.get("ret") == 200 and "data" in contact_info:
|
||||||
@@ -505,7 +506,7 @@ class Robot(Job):
|
|||||||
"""更新群成员详细信息"""
|
"""更新群成员详细信息"""
|
||||||
try:
|
try:
|
||||||
# 首先获取群成员列表
|
# 首先获取群成员列表
|
||||||
members_response = self.client.get_chatroom_member_list(self.client.app_id, chatroom_id)
|
members_response = self.client.get_chatroom_member_list(self.app_id, chatroom_id)
|
||||||
if members_response and members_response.get('ret') == 200:
|
if members_response and members_response.get('ret') == 200:
|
||||||
member_list = members_response.get('data', {}).get('memberList', [])
|
member_list = members_response.get('data', {}).get('memberList', [])
|
||||||
|
|
||||||
@@ -515,7 +516,7 @@ class Robot(Job):
|
|||||||
if member_wxids:
|
if member_wxids:
|
||||||
# 按照官方接口格式传递参数
|
# 按照官方接口格式传递参数
|
||||||
details_response = self.client.get_chatroom_member_detail(
|
details_response = self.client.get_chatroom_member_detail(
|
||||||
self.client.app_id,
|
self.app_id,
|
||||||
chatroom_id,
|
chatroom_id,
|
||||||
member_wxids # 直接传递列表,不需要转换为集合
|
member_wxids # 直接传递列表,不需要转换为集合
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user