I have a telegram bot into which the user enters text for sending. The mailing is carried out by the telethon client. The problem is that the client cannot send premium emoji.
I know that in order to send a premium Emoji, the text must be in the format: [](emoji/5388790256772331442) where the numbers are the document_id of the Emoji.
The question is how to get it?
Simply put, how can I make it so that I immediately write down [](emoji/5388790256772331442) instead of '' when receiving an Emoji?
I wrote code to get the document_id of an Emoji and even the object of this Emoji, but to get it the text must already be in the format [](emoji/5388790256772331442), although Python itself perceives premium Emoji as ''.
me = await client.get_me()
access_hash = me.access_hash
prem_emoji = await client(functions.messages.SearchCustomEmojiRequest(
emoticon=text, # my text with premium emoji
hash=access_hash
))
emoji_ids = prem_emoji.document_id # List with premium emoji ids
emojies = await client(functions.messages.GetCustomEmojiDocumentsRequest(
document_id=emoji_ids
))
logging.info(emojies) # return Emoji Object
I dug into the documentation and found the answer for myself. All messages are Message objects, they in turn have “entities”, printed, found MessageEntities of type custom_emoji_id where the Emoji id is located.
Next, simply look for emoji in the text using the pattern and replace them with
[{emoji}](emoji/entities[i])and the telethon client will write you a premium emoji