Table of Contents
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)
Must read
Concepts & Important Elements
- Architecture Overview
- Builder Pattern for
Application
- Types of Handlers
- Working with Files and Media
- Exceptions, Warnings and Logging
- Concurrency in PTB
Notable Features
- Advanced Filters
- Storing data
- Making your bot persistent
- Adding Defaults
- Job Queue
- Arbitrary
callback_data
- Avoiding flood limits
- Webhooks
- Bot API Forward Compatiblity
Code Resources
- Frequently requested design patterns
- Code snippets
- Performance Optimizations
- Telegram Passport
- Bots built with PTB
- Automated Bot Tests
Examples explained
Networking
Other resources
- Where to host Telegram Bots
- How to host your bot
- Local API Server
- Type Checking with PTB
- Press
- Notes on GAE
- Related Projects
- Emoji
Transition Guides
Administration
- Wiki of
python-telegram-bot
© Copyright 2015-2024 – Licensed by Creative Commons