Make contact ready for use which will load contact payload info. Args: force_sync: if true, it will re-fetch the data although it exist. Examples: >>> contact = Contact.load('contact-id') >>> await await contact.ready() Raises:
(self, force_sync: bool = False)
| 267 | return contacts |
| 268 | |
| 269 | async def ready(self, force_sync: bool = False) -> None: |
| 270 | """ |
| 271 | Make contact ready for use which will load contact payload info. |
| 272 | |
| 273 | Args: |
| 274 | force_sync: if true, it will re-fetch the data although it exist. |
| 275 | |
| 276 | Examples: |
| 277 | >>> contact = Contact.load('contact-id') |
| 278 | >>> await await contact.ready() |
| 279 | |
| 280 | Raises: |
| 281 | WechatyPayloadError: when payload can"t be loaded |
| 282 | """ |
| 283 | if force_sync or not self.is_ready(): |
| 284 | try: |
| 285 | self.payload = await self.puppet.contact_payload( |
| 286 | self.contact_id) |
| 287 | log.info('load contact <%s>', self) |
| 288 | except IOError as e: |
| 289 | log.info('can"t load contact %s payload, message : %s', |
| 290 | self.name, |
| 291 | str(e.args)) |
| 292 | |
| 293 | raise WechatyPayloadError('can"t load contact payload') |
| 294 | |
| 295 | def __str__(self) -> str: |
| 296 | """ |
no test coverage detected