|
@@ -422,7 +422,23 @@ class GeWeChatCom: |
|
|
print(response_object) |
|
|
print(response_object) |
|
|
return response_object.get('ret',None),response_object.get('msg',None) |
|
|
return response_object.get('ret',None),response_object.get('msg',None) |
|
|
|
|
|
|
|
|
|
|
|
def check_relation(self,token_id, app_id,wxids:list): |
|
|
|
|
|
''' |
|
|
|
|
|
检查好友关系 |
|
|
|
|
|
''' |
|
|
|
|
|
api_url = f"{self.base_url}/v2/api/contacts/checkRelation" |
|
|
|
|
|
headers = { |
|
|
|
|
|
'X-GEWE-TOKEN': token_id, |
|
|
|
|
|
'Content-Type': 'application/json' |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
data = { |
|
|
|
|
|
"appId": app_id, |
|
|
|
|
|
"wxids":wxids # list 1<= wxids <=20 |
|
|
|
|
|
} |
|
|
|
|
|
response = requests.post(url=api_url, headers=headers, data=json.dumps(data)) |
|
|
|
|
|
response_object = response.json() |
|
|
|
|
|
return response_object.get('ret',None),response_object.get('msg',None),response_object.get('data',None) |
|
|
|
|
|
|
|
|
############################### 下载模块 ############################### |
|
|
############################### 下载模块 ############################### |
|
|
def download_audio_msg(self,token_id:str,app_id:str,msg_id: int, xml: str): |
|
|
def download_audio_msg(self,token_id:str,app_id:str,msg_id: int, xml: str): |
|
@@ -769,7 +785,27 @@ class GeWeChatCom: |
|
|
redis_helper.redis_helper.update_hash_field(hash_key, "data", json.dumps(cache, ensure_ascii=False)) |
|
|
redis_helper.redis_helper.update_hash_field(hash_key, "data", json.dumps(cache, ensure_ascii=False)) |
|
|
|
|
|
|
|
|
return cache |
|
|
return cache |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def delete_contacts_brief_from_cache(self, wxid, contacts_wxids: list): |
|
|
|
|
|
""" |
|
|
|
|
|
删除联系人信息保存到 Redis 缓存。 |
|
|
|
|
|
""" |
|
|
|
|
|
hash_key = f"__AI_OPS_WX__:CONTACTS_BRIEF:{wxid}" |
|
|
|
|
|
cache_str = redis_helper.redis_helper.get_hash_field(hash_key, "data") |
|
|
|
|
|
cache = json.loads(cache_str) if cache_str else [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 将 contacts_wxids 转换为集合,提高查找效率 |
|
|
|
|
|
wxids_set = set(contacts_wxids) |
|
|
|
|
|
|
|
|
|
|
|
# 过滤 cache:保留 userName 不在集合中的对象 |
|
|
|
|
|
filtered_cache = [contact for contact in cache if contact["userName"] not in wxids_set] |
|
|
|
|
|
|
|
|
|
|
|
# # 如果需要原地修改原 cache 列表: |
|
|
|
|
|
# cache[:] = filtered_cache |
|
|
|
|
|
redis_helper.redis_helper.update_hash_field(hash_key, "data", json.dumps(filtered_cache, ensure_ascii=False)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def save_contacts_brief_to_cache_prev(self, token_id, app_id, wxid, contacts_wxids: list): |
|
|
def save_contacts_brief_to_cache_prev(self, token_id, app_id, wxid, contacts_wxids: list): |
|
|
""" |
|
|
""" |
|
|
将联系人信息保存到 Redis 缓存。 |
|
|
将联系人信息保存到 Redis 缓存。 |
|
|