* Search a Friend by phone or weixin. * The best practice is to search friend request once per minute.\ Remeber not to do this too frequently, or your account \ will be blocked. Args: weixin: the weixin id of the contact phone
(cls, weixin: Optional[str] = None,
phone: Optional[str] = None)
| 78 | |
| 79 | @classmethod |
| 80 | async def search(cls, weixin: Optional[str] = None, |
| 81 | phone: Optional[str] = None) -> Optional[Contact]: |
| 82 | """ |
| 83 | * Search a Friend by phone or weixin. |
| 84 | * The best practice is to search friend request once per minute.\ |
| 85 | Remeber not to do this too frequently, or your account \ |
| 86 | will be blocked. |
| 87 | |
| 88 | Args: |
| 89 | weixin: the weixin id of the contact |
| 90 | phone: the phone of the contact |
| 91 | Examples: |
| 92 | >>> friendship = await Friendship.search('phone') |
| 93 | >>> friendship.contact() |
| 94 | Returns: |
| 95 | Contact: the contact found |
| 96 | """ |
| 97 | log.info('search() <%s, %s, %s>', cls, weixin, phone) |
| 98 | friend_id = await cls.get_puppet().friendship_search(weixin=weixin, |
| 99 | phone=phone) |
| 100 | if friend_id is None: |
| 101 | return None |
| 102 | contact = cls.get_wechaty().Contact.load(friend_id) |
| 103 | await contact.ready() |
| 104 | return contact |
| 105 | |
| 106 | @classmethod |
| 107 | async def add(cls, contact: Contact, hello: str) -> None: |
no test coverage detected