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

Method avatar

src/wechaty/user/contact_self.py:16–42  ·  view source on GitHub ↗

Get or set avatar of ContactSelf. Args: file_box: FileBox object, if not provided, it will return a FileBox object Examples: >>> contact_self = bot.contact_self() >>> file_box = await contact_self.avatar() >>> file_box = awai

(self, file_box: Optional[FileBox] = None)

Source from the content-addressed store, hash-verified

14 """ContactSelf"""
15
16 async def avatar(self, file_box: Optional[FileBox] = None) -> FileBox:
17 """
18 Get or set avatar of ContactSelf.
19
20 Args:
21 file_box: FileBox object, if not provided, it will return a FileBox object
22
23 Examples:
24 >>> contact_self = bot.contact_self()
25 >>> file_box = await contact_self.avatar()
26 >>> file_box = await contact_self.avatar(file_box)
27
28 Raises:
29 WechatyOperationError: if the contact is not self, it will not get the avatar
30
31 Returns:
32 FileBox: file_box
33 """
34 log.info('avatar(%s)' % file_box.name if file_box else '')
35 if not file_box:
36 file_box = await super().avatar(None)
37 return file_box
38
39 if self.contact_id != self.puppet.self_id():
40 raise WechatyOperationError('set avatar only available for user self')
41
42 await self.puppet.contact_avatar(self.contact_id, file_box)
43
44 async def qr_code(self) -> str:
45 """

Callers

nothing calls this directly

Calls 3

self_idMethod · 0.80
contact_avatarMethod · 0.80

Tested by

no test coverage detected