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

Method __str__

src/wechaty/user/message.py:96–116  ·  view source on GitHub ↗

format string for message, which keep consistant with wechaty/wechaty refer to : https://github.com/wechaty/wechaty/blob/master/src/user/message.ts#L195

(self)

Source from the content-addressed store, hash-verified

94 return self.payload.type
95
96 def __str__(self) -> str:
97 """
98 format string for message, which keep consistant with wechaty/wechaty
99 refer to : https://github.com/wechaty/wechaty/blob/master/src/user/message.ts#L195
100 """
101 if not self.is_ready():
102 return f'Message <{self.message_id}> is not ready'
103
104 message_list = [
105 'Message',
106 f'#{self.message_type().name.lower()}',
107 # talker can't be None
108 f'[🗣 {self.talker()}',
109 ]
110 if self.room():
111 message_list.append(f'@👥 {self.room()}]')
112
113 if self.message_type() == MessageType.MESSAGE_TYPE_TEXT:
114 message_list.append(f'\t{self.text()[:70]}')
115
116 return ''.join(message_list)
117
118 async def say(self, msg: Union[str, Contact, FileBox, UrlLink, MiniProgram],
119 mention_ids: Optional[List[str]] = None) -> Optional[Message]:

Callers

nothing calls this directly

Calls 5

message_typeMethod · 0.95
talkerMethod · 0.95
roomMethod · 0.95
textMethod · 0.95
is_readyMethod · 0.80

Tested by

no test coverage detected