wechaty / python-wechaty

Python Wechaty is a Conversational RPA SDK for Chatbot Makers written in Python
https://wechaty.readthedocs.io/zh_CN/latest/
Apache License 2.0
1.56k stars 229 forks source link

How to convert message to normal text that contains emoji character⁉ ⁉ #283

Closed Alexhuihui closed 2 years ago

Alexhuihui commented 2 years ago

requirements

Describe your problem

When wechat robot recieve a text message that contains emoji character, msg.text() return the content of message, but i found that content convert emoji character to '<img class="emoji emoji1f43d" text="_web" 'src="/zh_CN/htmledition/v2/images/spacer.gif" />. so how can i get the real emoji character instead of the img tag?

Reproduce your problem

    async def on_message(self, msg: Message) -> None:
        from_contact: Contact = msg.talker()
        contact_id: str = from_contact.contact_id
        text: str = msg.text()
        logger.info("text===%s", text)
        room: Optional[Room] = msg.room()
        msg_type: MessageType = msg.type()

Error info

text===<img class="emoji emoji1f43d" text="_web" src="/zh_CN/htmledition/v2/images/spacer.gif" />
Alexhuihui commented 2 years ago

使用print(\u1f43d)