telegramtelethon

Send premium emojis with telethon


How can I find list of Telegram premium emojis?

Do they have any unicode?

How can I send them in my message using Telethon?


Solution

  • As Telethon documentation says

    emoji URL is followed by a number. This number is a document_id. To find it, the easiest way is to send a message to your own chat with the premium emoji you want to use using an official client, and then use Telethon to print the message.entities. It will contain the document_id you need to use.

    Now, in your message text, you can use inline links which become spoilers and custom emoji! (Note that for custom emoji to work, the inline link text must be a normal emoji):

    client.send_message('me', 'hello this is a [hidden text](spoiler), with custom emoji [❤️](emoji/10002345) !')
    

    According to Telegram's official documentation

    All users – Premium or not – can see any animated emoji. Everyone can also use all custom emoji for free in their Saved Messages chat to try them out – or to add extra flair to notes and reminders.

    So, you can retrieve all emojis including, premium ones. Here is an example in Telethon:

    from telethon.sync import TelegramClient
    from telethon import functions, types
    
    with TelegramClient(name, api_id, api_hash) as client:
        result = client(functions.messages.GetEmojiKeywordsRequest(
            lang_code='en'
        ))
        print(result.stringify())