MCPcopy Index your code
hub / github.com/wechaty/python-wechaty / forward

Method forward

src/wechaty/user/message.py:545–573  ·  view source on GitHub ↗

Forward a message to a room or a contact. Args: to: the room or contact to forward to Examples: >>> msg.forward(room) >>> msg.forward(contact)

(self, to: Union[Room, Contact])

Source from the content-addressed store, hash-verified

543 await to_contact.ready()
544
545 async def forward(self, to: Union[Room, Contact]) -> None:
546 """
547 Forward a message to a room or a contact.
548 Args:
549 to: the room or contact to forward to
550 Examples:
551 >>> msg.forward(room)
552 >>> msg.forward(contact)
553 """
554 log.info('forward() <%s>', to)
555 if to is None:
556 raise WechatyPayloadError('to param not found')
557 try:
558 if isinstance(to, Room):
559 to_id = to.room_id
560 elif isinstance(to, Contact):
561 to_id = to.contact_id
562 else:
563 raise WechatyPayloadError(
564 'expected type is <Room, Contact>, but get <%s>'
565 % to.__class__)
566 print(to_id)
567 await self.puppet.message_forward(to_id, self.message_id)
568
569 # pylint:disable=W0703
570 except Exception as exception:
571 message = 'Message forward error <%s>' % exception.args
572 log.error(message)
573 raise WechatyOperationError(message)
574
575 def date(self) -> datetime:
576 """

Callers

nothing calls this directly

Calls 3

WechatyPayloadErrorClass · 0.90
message_forwardMethod · 0.80

Tested by

no test coverage detected