diff --git a/services/biz_service.py b/services/biz_service.py index 8de9e27..a8243d0 100644 --- a/services/biz_service.py +++ b/services/biz_service.py @@ -17,6 +17,10 @@ from services.kafka_service import KafkaService from fastapi import Request from common.utils import * +from services.redis_service import RedisService +from services.kafka_service import KafkaService +from services.gewe_service import GeWeService + @singleton class BizService(): @@ -24,8 +28,8 @@ class BizService(): if not hasattr(self, 'initialized'): #self.kafka_service =kafka_service # 获取 KafkaService 单例 self.kafka_service =app.state.kafka_service - self.wxchat=app.state.gewe_service - self.redis_service=app.state.redis_service + self.wxchat:GeWeService=app.state.gewe_service + self.redis_service:RedisService=app.state.redis_service self.initialized = True def setup_handlers(self): @@ -292,11 +296,17 @@ class BizService(): if not wxids: logger.warning(f'wxids 空列表不处理 {wxids}') return - wxids_first=wxids[0] + #wxids_first=wxids[0] + tasks = [] + + for wxid in wxids: + tasks.append(self.wxchat.send_text_sns_async(self.token_id, self.app_id, wx_sns_content)) + + await asyncio.gather(*tasks) async def sns_sendimages_forward_handler_async(self,content_data): pass async def sns_sendvideo_forward_handler_async(self,content_data): - pass \ No newline at end of file + pass diff --git a/services/gewe_service.py b/services/gewe_service.py index 7687ace..4038b76 100644 --- a/services/gewe_service.py +++ b/services/gewe_service.py @@ -1021,6 +1021,7 @@ class GeWeService: if not check_chatroom(chatroom_id): await self.redis_service.delete_hash_field(f'__AI_OPS_WX__:GROUPS_INFO:{wxid}',chatroom_id) + await self.redis_service.delete_hash_field(f'__AI_OPS_WX__:GROUPS_MEMBERS:{wxid}',chatroom_id) logger.info(f'{chatroom_id} 不是有效的群,不处理') continue @@ -1029,9 +1030,14 @@ class GeWeService: ret, msg, data =await self.get_chatroom_info_async(token_id, app_id, chatroom_id) if ret != 200: continue - + # print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') + # print('群信息save_groups_info_to_cache_async') + # print(data) + # print(bool(not data.get('memberList', []))) + # print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') if not data.get('memberList', []): await self.redis_service.delete_hash_field(f'__AI_OPS_WX__:GROUPS_INFO:{wxid}',chatroom_id) + await self.redis_service.delete_hash_field(f'__AI_OPS_WX__:GROUPS_MEMBERS:{wxid}',chatroom_id) logger.info(f'通过 成员列表为空 清理 {chatroom_id}群成员信息') continue # 更新缓存 @@ -1156,6 +1162,7 @@ class GeWeService: hash_key = f"__AI_OPS_WX__:GROUPS_INFO:{wxid}" if not check_chatroom(chatroom_id): await self.redis_service.delete_hash_field(f'__AI_OPS_WX__:GROUPS_INFO:{wxid}',chatroom_id) + await self.redis_service.delete_hash_field(f'__AI_OPS_WX__:GROUPS_MEMBERS:{wxid}',chatroom_id) return # 获取群信息 ret, msg, data =await self.get_chatroom_info_async(token_id, app_id, chatroom_id)