First beta release ever.
It has been so long since last release that we would like to test the impact before a final release.
We do NOT recommend using this beta release in production.
Major changes:
- Context based callbacks
- Persistence
- PrefixHandler added (Handler overhaul)
- Deprecation of RegexHandler and edited_messages, channel_post, etc. arguments (Filter overhaul)
- Various ConversationHandler changes and fixes
See the wiki page at https://git.io/fxJuV for a detailed guide on how to migrate from version 11 to version 12.
Context based callbacks (#1100)
- Use of
pass_
in handlers is deprecated. - Instead use
use_context=True
onUpdater
orDispatcher
and change callback from (bot, update, others...) to (update, context). - This also applies to error handlers
Dispatcher.add_error_handler
and JobQueue jobs (change (bot, job) to (context) here). - For users with custom handlers subclassing Handler, this is mostly backwards compatible, but to use the new context based callbacks you need to implement the new collect_additional_context method.
- Passing bot to
JobQueue.__init__
is deprecated. Use JobQueue.set_dispatcher with a dispatcher instead. - Dispatcher makes sure to use a single
CallbackContext
for a entire update. This means that if an update is handled by multiple handlers (by using the group argument), you can add custom arguments to theCallbackContext
in a lower group handler and use it in higher group handler. NOTE: Never use with @run_async, see docs for more info. (#1283) - If you have custom handlers they will need to be updated to support the changes in this release.
- Update all examples to use context based callbacks.
Persistence (#1017)
- Added PicklePersistence and DictPersistence for adding persistence to your bots.
- BasePersistence can be subclassed for all your persistence needs.
- Add a new example that shows a persistent ConversationHandler bot
Handler overhaul (#1114)
- CommandHandler now only triggers on actual commands as defined by telegram servers (everything that the clients mark as a tabable link).
- PrefixHandler can be used if you need to trigger on prefixes (like all messages starting with a "/" (old CommandHandler behaviour) or even custom prefixes like "#" or "!").
Filter overhaul (#1221)
- RegexHandler is deprecated and should be replaced with a MessageHandler with a regex filter.
- Use update filters to filter update types instead of arguments (message_updates, channel_post_updates and edited_updates) on the handlers.
- Completely remove allow_edited argument - it has been deprecated for a while.
- data_filters now exist which allows filters that return data into the callback function. This is how the regex filter is implemented.
- All this means that it no longer possible to use a list of filters in a handler. Use bitwise operators instead!
ConversationHandler
- Remove
run_async_timeout
andtimed_out_behavior
arguments (#1344) - Replace with
WAITING
constant and behavior from states (#1344) - Only emit one warning for multiple CallbackQueryHandlers in a ConversationHandler (#1319)
- Use warnings.warn for ConversationHandler warnings (#1343)
- Fix unresolvable promises (#1270)
Bug fixes & improvements
- Handlers should be faster due to deduped logic.
- Avoid compiling compiled regex in regex filter. (#1314)
- Add missing
left_chat_member
to Message.MESSAGE_TYPES (#1336) - Make custom timeouts actually work properly (#1330)
- Add convenience classmethods (from_button, from_row and from_column) to InlineKeyboardMarkup
- Small typo fix in setup.py (#1306)
- Add Conflict error (HTTP error code 409) (#1154)
- Change MAX_CAPTION_LENGTH to 1024 (#1262)
- Remove some unnecessary clauses (#1247, #1239)
- Allow filenames without dots in them when sending files (#1228)
- Fix uploading files with unicode filenames (#1214)
- Replace http.server with Tornado (#1191)
- Allow SOCKSConnection to parse username and password from URL (#1211)
- Fix for arguments in passport/data.py (#1213)
- Improve message entity parsing by adding text_mention (#1206)
Internal improvements
- Finally fix our CI builds mostly (too many commits and PRs to list)
- Use multiple bots for CI to improve testing times significantly.
- Allow pypy to fail in CI.
- Remove the last CamelCase CheckUpdate methods from the handlers we missed earlier.