Display all the contacts and dump the avatars
()
| 30 | |
| 31 | |
| 32 | async def display_contacts() -> None: |
| 33 | """Display all the contacts and dump the avatars""" |
| 34 | # pylint: disable=W0603 |
| 35 | global bot |
| 36 | assert bot is not None |
| 37 | while True: |
| 38 | contacts = await bot.Contact.find_all() |
| 39 | |
| 40 | log.info('#######################') |
| 41 | log.info('Contact number: %s\n', len(contacts)) |
| 42 | |
| 43 | for index, contact in enumerate(contacts): |
| 44 | if contact.type() == ContactType.CONTACT_TYPE_PERSONAL: |
| 45 | log.info('personal %s: %s : %s', index, contact.name, contact.get_id()) |
| 46 | |
| 47 | for contact in contacts[:MAX_CONTACTS]: |
| 48 | file = await contact.avatar() |
| 49 | name = file.name |
| 50 | await file.to_file(name, True) |
| 51 | |
| 52 | log.info('Contact: "%s" with avatar file: "%s"', contact.name, name) |
| 53 | |
| 54 | if len(contacts) > MAX_CONTACTS: |
| 55 | log.info('Too many contacts. I only show you the first %s ones...', MAX_CONTACTS) |
| 56 | |
| 57 | log.info('I will re-dump contact weixin id & names after %s second... ', INTERVAL) |
| 58 | await asyncio.sleep(INTERVAL) |
| 59 | |
| 60 | |
| 61 | async def handle_login(user: Contact) -> None: |
no test coverage detected