DAGDA SEARCH | Back to results | Support

Emoji · python-telegram-bot/python-telegram-bot Wiki · GitHub

Source: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Emoji

Repository navigation

Emoji

Jump to bottom Edit New page Dmitry Serzhenko edited this page Jan 3, 2023 · 9 revisions

You've now made a cool bot, but it's lacking personality? Add some emoji!

Direct Method

The easiest way to use emoji is to directly put them in your strings. The Unicode website has a chart with all the emoji. Simply select any emoji you want, this works with both the images and the raw characters in the "Browser" column, and paste it in your string.

text = "🌈⛈🎉🌹🐧😊"

In the code you may see squares with numbers in them instead of the emoji themself. This means the font in your text editor does not have an image for that character, but it is still there.

Finally, test your emoji by sending it to yourself over Telegram. Know that Telegram does not support all the emoji.

The emoji module

With the emoji module you don't have to copy paste emoji, you can use their names or aliases as on GitHub:

from emoji import emojize
bot.send_message(emojize("yummy :cake:", use_aliases=True))

Note: the emojize function uses regular expressions and takes on the order of microseconds to complete. If your bot handles billions of messages per second, put the emoji in reusable variables to micro-optimize:

cake = emojize(":cake:", use_aliases=True)

Wiki of python-telegram-bot © Copyright 2015-2026 – Licensed by Creative Commons

Must read

  1. Introduction to the API
  2. Tutorial: Your first bot
  3. FAQ
  4. How to ask good questions
  5. How to write an MWE

Concepts & Important Elements

  1. Architecture Overview
  2. Builder Pattern for Application
  3. Types of Handlers
  4. Working with Files and Media
  5. Exceptions, Warnings and Logging
  6. Concurrency in PTB

Notable Features

  1. Advanced Filters
  2. Storing data
  3. Making your bot persistent
  4. Adding Defaults
  5. Job Queue
  6. Arbitrary callback_data
  7. Avoiding flood limits
  8. Webhooks
  9. Bot API Forward Compatiblity

Code Resources

  1. Frequently requested design patterns
  2. Code snippets
  3. Performance Optimizations
  4. Telegram Passport
  5. Bots built with PTB
  6. Automated Bot Tests

Examples explained

  1. InlineKeyboard Example

Networking

  1. Working Behind a Proxy
  2. Handling network errors

Other resources

  1. Where to host Telegram Bots
  2. How to host your bot
  3. Local API Server
  4. Type Checking with PTB
  5. Press
  6. Notes on GAE
  7. Related Projects
  8. Emoji

Transition Guides

Administration

Clone this wiki locally