MCPcopy
hub / github.com/wechaty/python-wechaty / search

Method search

src/wechaty/user/friendship.py:80–104  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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:

Callers 1

on_messageMethod · 0.80

Calls 5

friendship_searchMethod · 0.80
get_puppetMethod · 0.80
get_wechatyMethod · 0.80
loadMethod · 0.45
readyMethod · 0.45

Tested by

no test coverage detected