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
(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
)
| 189 | |
| 190 | @classmethod |
| 191 | async def find(cls, talker_id: Optional[str] = None, |
| 192 | message_id: Optional[str] = None, |
| 193 | room_id: Optional[str] = None, |
| 194 | text: Optional[str] = None, |
| 195 | to_id: Optional[str] = None, |
| 196 | message_type: Optional[MessageType] = None |
| 197 | ) -> Optional[Message]: |
| 198 | """find the message from the server. |
| 199 | |
| 200 | Args: |
| 201 | talker_id (Optional[str], optional): the id of talker. |
| 202 | message_id (Optional[str], optional): the id of message. |
| 203 | room_id (Optional[str], optional): the id of room. |
| 204 | text (Optional[str], optional): you can search message by sub-string of the text. |
| 205 | to_id (Optional[str], optional): the id of receiver. |
| 206 | message_type (Optional[MessageType], optional): the type of the message |
| 207 | Examples: |
| 208 | >>> message = Message.find(message_id='message_id') |
| 209 | Returns: |
| 210 | Optional[Message]: if find the messages, return the first of it. |
| 211 | if can't find message, return None |
| 212 | """ |
| 213 | log.info('Message find all <%s, %s, %s, <%s, %s, %s>', talker_id, |
| 214 | message_id, room_id, text, to_id, message_type) |
| 215 | |
| 216 | messages = await cls.find_all( |
| 217 | talker_id=talker_id, |
| 218 | message_id=message_id, |
| 219 | room_id=room_id, |
| 220 | text=text, |
| 221 | to_id=to_id, |
| 222 | message_type=message_type |
| 223 | ) |
| 224 | if messages is None or len(messages) < 1: |
| 225 | return None |
| 226 | |
| 227 | if len(messages) > 1: |
| 228 | log.warning( |
| 229 | 'Message findAll() got more than one(%d) result', |
| 230 | len(messages)) |
| 231 | return messages[0] |
| 232 | |
| 233 | @classmethod |
| 234 | async def find_all(cls, talker_id: Optional[str] = None, |