简体   繁体   中英

How to send emoji (not custom) throw the Telegram API

I tried few variants. Like here:

How to send Emoji with Telegram Bot API?

python telegram telethon how to send emoji

And each variant of encoding from this page https://www.fileformat.info/info/unicode/char/1f4b5/index.htm

But nothing helped for me.

I tried to escape backslashes and to not. So I get this U0001F609 or this \U0001F609 in Telegram message.

Can somebody just show me JSON which I have to send in order to finally receive a smiley in the message?

So, I see that in telegrams you need to send emoji as a UTF-8 entity (ie /, etc.).

But my problem was that the text that the bot sends is regulated from the site's admin panel and stored in the database. And in the table, I cannot change the encoding for the correct storage of such characters (I get???? at the output).

The solution I came up with:

Right now I'm storing an HTML entity in the database (ie 🔝 / &#128181 etc.) and before sending the message, I cut them out of the regular expression /&#.*;/mU and convert to correct encoding with mb_convert_encoding($match, 'UTF-8', 'HTML-ENTITIES')

I did not describe all these points in the original message because I myself did not fully understand why the telegram does not process what I am trying to send to it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM