-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Types of Handlers
Joscha Götzer edited this page Dec 27, 2017
·
33 revisions
A Handler
is an instance derived from the base class telegram.ext.Handler which is responsible for the routing of different kinds of updates (text, audio, inlinequery, button presses, ...) to their corresponding callback function in your code.
For example, if you want your bot to respond to the command /start
, you can use a CommandHandler that maps the input to a callback named my_start_callback
:
def my_start_callback(bot, update):
update.message.reply_text("Welcome to my awesome bot!")
...
dispatcher.add_handler(CommandHandler("start", my_start_callback))```
- Wiki of
python-telegram-bot
© Copyright 2015-2024 – Licensed by Creative Commons
- Architecture Overview
- Builder Pattern for
Application
- Types of Handlers
- Working with Files and Media
- Exceptions, Warnings and Logging
- Concurrency in PTB
- Advanced Filters
- Storing data
- Making your bot persistent
- Adding Defaults
- Job Queue
- Arbitrary
callback_data
- Avoiding flood limits
- Webhooks
- Bot API Forward Compatiblity
- Frequently requested design patterns
- Code snippets
- Performance Optimizations
- Telegram Passport
- Bots built with PTB
- Automated Bot Tests