async def find_all( cls, talker_id: Optional[str] = None, message_id: Optional[str] = None, room_id: Optional[str] = None, text: Optional[str] = None, to_id: Optional[str] = None, message_type: Optional[MessageType] = None) -> List[Message]: """find the message from the server. Args: talker_id (Optional[str], optional): the id of talker. message_id (Optional[str], optional): the id of message. room_id (Optional[str], optional): the id of room. text (Optional[str], optional): you can search message by sub-string of the text. to_id (Optional[str], optional): the id of receiver. message_type (Optional[MessageType], optional): the type of the message Returns: List[Message]: return all of the searched messages """ log.info('Message find all <%s, %s, %s, <%s, %s, %s>', talker_id, message_id, room_id, text, to_id, message_type) query_filter = MessageQueryFilter(from_id=talker_id, id=message_id, room_id=room_id, text=text, to_id=to_id, type=message_type) message_ids = await cls.get_puppet().message_search(query_filter) messages = [cls.load(message_id) for message_id in message_ids] return messages
def _convert_message( user_query: MessageUserQueryFilter = None ) -> Optional[MessageQueryFilter]: """ convert wechaty message_user_query_filter to wechaty_puppet message_query_filter """ if user_query is None: return None query = MessageQueryFilter(text=user_query.text) if user_query.room is not None: query.room_id = user_query.room.room_id if user_query.talker is not None: query.talker_id = user_query.talker.contact_id if user_query.type is not None: query.type = user_query.type if user_query.to is not None: query.to_id = user_query.to.contact_id return query
async def find_all( cls, talker_id: Optional[str] = None, message_id: Optional[str] = None, room_id: Optional[str] = None, text: Optional[str] = None, to_id: Optional[str] = None, message_type: Optional[MessageType] = None) -> List[Message]: """ Find messages in cache """ log.info('Message find all <%s, %s, %s, <%s, %s, %s>', talker_id, message_id, room_id, text, to_id, message_type) query_filter = MessageQueryFilter(from_id=talker_id, id=message_id, room_id=room_id, text=text, to_id=to_id, type=message_type) message_ids = await cls.get_puppet().message_search(query_filter) messages = [cls.load(message_id) for message_id in message_ids] return messages