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

Method to_contact

src/wechaty/user/message.py:659–680  ·  view source on GitHub ↗

Get Share Card of the Message Extract the Contact Card from the Message, and encapsulate it into Contact class Examples: >>> msg.to_contact() Returns: Contact: contact

(self)

Source from the content-addressed store, hash-verified

657 return self.wechaty.Image.create(self.message_id)
658
659 async def to_contact(self) -> Contact:
660 """
661 Get Share Card of the Message
662 Extract the Contact Card from the Message, and encapsulate it into
663 Contact class
664 Examples:
665 >>> msg.to_contact()
666 Returns:
667 Contact: contact
668 """
669 log.info('Message to Contact')
670 if self.type() != MessageType.MESSAGE_TYPE_CONTACT:
671 raise WechatyOperationError(
672 'current message type: %s, not contact type'
673 % self.type()
674 )
675
676 contact_id = await self.puppet.message_contact(self.message_id)
677
678 contact = self.wechaty.Contact.load(contact_id)
679 await contact.ready()
680 return contact
681
682 async def to_url_link(self) -> UrlLink:
683 """

Callers

nothing calls this directly

Calls 5

typeMethod · 0.95
message_contactMethod · 0.80
loadMethod · 0.45
readyMethod · 0.45

Tested by

no test coverage detected