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

Method qr_code

src/wechaty/user/contact_self.py:44–69  ·  view source on GitHub ↗

Return the qrcode of ContactSelf Examples: >>> contact_self = bot.contact_self() >>> qr_code = await contact_self.qr_code() Raises: WechatyOperationError: if there is login exception, it will not get the qrcode Wechat

(self)

Source from the content-addressed store, hash-verified

42 await self.puppet.contact_avatar(self.contact_id, file_box)
43
44 async def qr_code(self) -> str:
45 """
46 Return the qrcode of ContactSelf
47
48 Examples:
49 >>> contact_self = bot.contact_self()
50 >>> qr_code = await contact_self.qr_code()
51
52 Raises:
53 WechatyOperationError: if there is login exception, it will not get the qrcode
54 WechatyOperationError: if the contact is not self, it will not get the qrcode
55
56 Returns:
57 str: the content of qrcode
58 """
59 try:
60 contact_id: str = self.puppet.self_id()
61 except Exception:
62 raise WechatyOperationError(
63 'Can not get qr_code, user might be either not logged in or already logged out'
64 )
65
66 if self.contact_id != contact_id:
67 raise WechatyOperationError('only can get qr_code for the login user self')
68 qr_code_value = await self.puppet.contact_self_qr_code()
69 return qr_code_value
70
71 @property
72 def name(self) -> str:

Callers

nothing calls this directly

Calls 3

self_idMethod · 0.80
contact_self_qr_codeMethod · 0.80

Tested by

no test coverage detected