[UNRELEASED DRAFT]
- Added full support of Bot API 7.3 #1480
- Added telegram objects transformation block in 2.x -> 3.x migration guide #1412
- Added message_thread_id parameter to ChatActionSender class methods. #1437
Added context manager interface to Bot instance, from now you can use:
async with Bot(...) as bot: ...
instead of
async with Bot(...).context() as bot: ...
- WebAppUser Class Fields: Added missing is_premium, added_to_attachment_menu, and allows_write_to_pm fields to WebAppUser class to align with the Telegram API.
- WebAppChat Class Implementation: Introduced the WebAppChat class with all its fields (id, type, title, username, and photo_url) as specified in the Telegram API, which was previously missing from the library.
- WebAppInitData Class Fields: Included previously omitted fields in the WebAppInitData class: chat, chat_type, chat_instance, to match the official documentation for a complete Telegram Web Apps support. #1424
- Fixed poll answer FSM context by handling
voter_chat
forpoll_answer
event #1436 - Added missing error handling to
_background_feed_update
(when inhandle_in_background=True
webhook mode) #1458
- Added WebAppChat class to WebApp docs, updated uk_UA localisation of WebApp docs. #1433
- Added full support of Bot API 7.2 #1444
- Loosened pydantic version upper restriction from
<2.7
to<2.8
#1460
- Fixed JSON serialization of the
LinkPreviewOptions
class while it is passed as bot-wide default options. #1418
Reworked bot-wide globals like
parse_mode
,disable_web_page_preview
, and others to be more flexible.Warning
Note that the old way of setting these global bot properties is now deprecated and will be removed in the next major release.
- A new enum
KeyboardButtonPollTypeType
forKeyboardButtonPollTypeType.type
field has bed added. #1398 Added full support of Bot API 7.1
- Added support for the administrator rights
can_post_stories
,can_edit_stories
,can_delete_stories
in supergroups. - Added the class
ChatBoostAdded
and the fieldboost_added
to the classMessage
for service messages about a user boosting a chat. - Added the field
sender_boost_count
to the classMessage
. - Added the field
reply_to_story
to the classMessage
. - Added the fields
chat
andid
to the classStory
. - Added the field
unrestrict_boost_count
to the classChat
.
- Added the field
custom_emoji_sticker_set_name
to the classChat
. #1417- Added support for the administrator rights
- Update KeyboardBuilder utility, fixed type-hints for button method, adjusted limits of the different markup types to real world values. #1399
- Added new
reply_parameters
param tomessage.send_copy
because it hasn't been added there #1403
- Add notion "Working with plural forms" in documentation Utils -> Translation #1395
Added full support of Bot API 7.0
- Reactions
- Replies 2.0
- Link Preview Customization
- Block Quotation
- Multiple Message Actions
- Requests for multiple users
- Chat Boosts
- Giveaway
- Other changes #1387
- Introduced Scenes feature that helps you to simplify user interactions using Finite State Machine. Read more about 👉
Scenes <Scenes>
. #1280 - Added the new FSM strategy
CHAT_TOPIC
, which sets the state for the entire topic in the chat, also works in private messages and regular groups without topics. #1343
- Fixed
parse_mode
argument in the inMessage.send_copy
shortcut. Disable by default. #1332 - Added ability to get handler flags from filters. #1360
- Fixed a situation where a
CallbackData
could not be parsed without a default value. #1368
- Corrected grammatical errors, improved sentence structures, translation for migration 2.x-3.x #1302
- Minor typo correction, specifically in module naming + some grammar. #1340
- Added CITATION.cff file for automatic academic citation generation. Now you can copy citation from the GitHub page and paste it into your paper. #1351
- Minor typo correction in middleware docs. #1353
- Fixed ResourceWarning in the tests, reworked
RedisEventsIsolation
fixture to use Redis connection fromRedisStorage
#1320 Updated dependencies, bumped minimum required version:
magic-filter
- fixed .resolve operationpydantic
- fixed compatibility (broken in 2.4)aiodns
- added new dependency to thefast
extras (pip install aiogram[fast]
)
- others... #1327
- Prevent update handling task pointers from being garbage collected, backport from 2.x #1331
- Updated
typing-extensions
package version range in dependencies to fix compatibility withFastAPI
#1347 - Introduce Python 3.12 support #1354
- Speeded up CallableMixin processing by caching references to nested objects and simplifying kwargs assembly. #1357
- Added
pydantic
v2.5 support. #1361 - Updated
thumbnail
fields type toInputFile
only #1372
- Fixed pydantic version <2.4, since 2.4 has breaking changes. #1322
- Added support for custom encoders/decoders for payload (and also for deep-linking). #1262
- Added
aiogram.utils.input_media.MediaGroupBuilder
for media group construction. #1293 - Added full support of Bot API 6.9 #1319
- Added actual param hints for InlineKeyboardBuilder and ReplyKeyboardBuilder. #1303
- Fixed priority of events isolation, now user state will be loaded only after lock is acquired #1317
- Replaced
datetime.datetime
with DateTime type wrapper across types to make dumped JSONs object more compatible with data that is sent by Telegram. #1277 - Fixed magic
.as_(...)
operation for values that can be interpreted as False (e.g. 0). #1281 - Italic markdown from utils now uses correct decorators #1282
- Fixed method
Message.send_copy
for stickers. #1284 - Fixed
Message.send_copy
method, which was not working properly with stories, so not you can copy stories too (forwards messages). #1286 - Fixed error overlapping when validation error is caused by remove_unset root validator in base types and methods. #1290
- Fixed missing message content types (
ContentType.USER_SHARED
,ContentType.CHAT_SHARED
) #1252 - Fixed nested hashtag, cashtag and email message entities not being parsed correctly when these entities are inside another entity. #1259
- Moved global filters check placement into router to add chance to pass context from global filters into handlers in the same way as it possible in other places #1266
- Added error handling example examples/error_handling.py #1099
- Added a few words about skipping pending updates #1251
- Added a section on Dependency Injection technology #1253
- This update includes the addition of a multi-file bot example to the repository. #1254
- Refactored examples code to use aiogram enumerations and enhanced chat messages with markdown beautification's for a more user-friendly display. #1256
- Supplemented "Finite State Machine" section in Migration FAQ #1264
- Removed extra param in docstring of TelegramEventObserver's filter method and fixed typo in I18n documentation. #1268
- Enhanced the warning message in dispatcher to include a JSON dump of the update when update type is not known. #1269
- Added support for Bot API 6.8 #1275
Added Currency enum. You can use it like this:
from aiogram.enums import Currency await bot.send_invoice( ..., currency=Currency.USD, ... )
- Updated keyboard builders with new methods for integrating buttons and keyboard creation more seamlessly. Added functionality to create buttons from existing markup and attach another builder. This improvement aims to make the keyboard building process more user-friendly and flexible. #1236
- Added support for message_thread_id in ChatActionSender #1249
- Fixed polling startup when "bot" key is passed manually into dispatcher workflow data #1242
Added codegen configuration for lost shortcuts:
- ShippingQuery.answer
- PreCheckoutQuery.answer
- Message.delete_reply_markup #1244
- Added documentation for webhook and polling modes. #1241
- Reworked InputFile reading, removed
__aiter__
method, added bot: Bot argument to the.read(...)
method, so, from now URLInputFile can be used without specifying bot instance. #1238 - Code-generated
__init__
typehints in types and methods to make IDE happy without additional pydantic plugin #1245
- Added new shortcuts for
aiogram.types.chat_member_updated.ChatMemberUpdated
to send message to chat that member joined/left. #1234 - Added new shortcuts for
aiogram.types.chat_join_request.ChatJoinRequest
to make easier access to sending messages to users who wants to join to chat. #1235
- Fixed bot assignment in the
Message.send_copy
shortcut #1232 - Added model validation to remove UNSET before field validation. This change was necessary to correctly handle parse_mode where 'UNSET' is used as a sentinel value. Without the removal of 'UNSET', it would create issues when passed to model initialization from Bot.method_name. 'UNSET' was also added to typing. #1233
- Updated pydantic to 2.1 with few bugfixes
- Improved docs, added basic migration guide (will be expanded later) #1143
- Removed the use of the context instance (Bot.get_current) from all placements that were used previously. This is to avoid the use of the context instance in the wrong place. #1230
- Added possibility to use custom events in routers (If router does not support custom event it does not break and passes it to included routers). #1147
Added support for FSM in Forum topics.
The strategy can be changed in dispatcher:
from aiogram.fsm.strategy import FSMStrategy ... dispatcher = Dispatcher( fsm_strategy=FSMStrategy.USER_IN_TOPIC, storage=..., # Any persistent storage )
Note
If you have implemented you own storages you should extend record key generation with new one attribute -
thread_id
Improved CallbackData serialization.
- Minimized UUID (hex without dashes)
- Replaced bool values with int (true=1, false=0) #1163
- Added a tool to make text formatting flexible and easy. More details on the
corresponding documentation page <formatting-tool>
#1172 - Added
X-Telegram-Bot-Api-Secret-Token
header check #1173 - Made
allowed_updates
list to revolve automatically in start_polling method if not set explicitly. #1178 - Added possibility to pass custom headers to
URLInputFile
object #1191
Change type of result in InlineQueryResult enum for
InlineQueryResultCachedMpeg4Gif
andInlineQueryResultMpeg4Gif
to more correct according to documentation.Change regexp for entities parsing to more correct (
InlineQueryResultType.yml
). #1146- Fixed signature of startup/shutdown events to include the
**dispatcher.workflow_data
as the handler arguments. #1155 - Added missing
FORUM_TOPIC_EDITED
value to content_type property #1160 - Fixed compatibility with Python 3.8-3.9 (from previous release) #1162
- Fixed the markdown spoiler parser. #1176
- Fixed workflow data propagation #1196
Fixed the serialization error associated with nested subtypes like InputMedia, ChatMember, etc.
The previously generated code resulted in an invalid schema under pydantic v2, which has stricter type parsing. Hence, subtypes without the specification of all subtype unions were generating an empty object. This has been rectified now. #1213
- Changed small grammar typos for
upload_file
#1133
Removed text filter in due to is planned to remove this filter few versions ago.
Use
F.text
instead #1170
Added full support of Bot API 6.6
Danger
Note that this issue has breaking changes described in the Bot API changelog, this changes is not breaking in the API but breaking inside aiogram because Beta stage is not finished.
Added full support of Bot API 6.7
Warning
Note that arguments switch_pm_parameter and switch_pm_text was deprecated and should be changed to button argument as described in API docs.
Updated Pydantic to V2
Warning
Be careful, not all libraries is already updated to using V2
- Added global defaults
disable_web_page_preview
andprotect_content
in addition toparse_mode
to the Bot instance, reworked internal request builder mechanism. #1142 - Removed bot parameters from storages #1144
Replaced ContextVar's with a new feature called Validation Context in Pydantic to improve the clarity, usability, and versatility of handling the Bot instance within method shortcuts.
Danger
Breaking: The 'bot' argument now is required in URLInputFile
Updated magic-filter with new features
- Added hint for
len(F)
error
- Added not in operation #1221
- Added hint for
Warning
Note that this version has incompatibility with Python 3.8-3.9 in case when you create an instance of Dispatcher outside of the any coroutine.
Sorry for the inconvenience, it will be fixed in the next version.
This code will not work:
dp = Dispatcher()
def main():
...
dp.run_polling(...)
main()
But if you change it like this it should works as well:
router = Router()
async def main():
dp = Dispatcher()
dp.include_router(router)
...
dp.start_polling(...)
asyncio.run(main())
Added missing shortcuts, new enums, reworked old stuff
Breaking All previously added enums is re-generated in new place - aiogram.enums instead of aiogram.types
- Added enums:
aiogram.enums.bot_command_scope_type.BotCommandScopeType
, aiogram.enums.chat_action.ChatAction
,aiogram.enums.chat_member_status.ChatMemberStatus
,aiogram.enums.chat_type.ChatType
,aiogram.enums.content_type.ContentType
,aiogram.enums.dice_emoji.DiceEmoji
,aiogram.enums.inline_query_result_type.InlineQueryResultType
,aiogram.enums.input_media_type.InputMediaType
,aiogram.enums.mask_position_point.MaskPositionPoint
,aiogram.enums.menu_button_type.MenuButtonType
,aiogram.enums.message_entity_type.MessageEntityType
,aiogram.enums.parse_mode.ParseMode
,aiogram.enums.poll_type.PollType
,aiogram.enums.sticker_type.StickerType
,aiogram.enums.topic_icon_color.TopicIconColor
,aiogram.enums.update_type.UpdateType
,
Added shortcuts:
- Chat
aiogram.types.chat.Chat.get_administrators
, aiogram.types.chat.Chat.delete_message
,aiogram.types.chat.Chat.revoke_invite_link
,aiogram.types.chat.Chat.edit_invite_link
,aiogram.types.chat.Chat.create_invite_link
,aiogram.types.chat.Chat.export_invite_link
,aiogram.types.chat.Chat.do
,aiogram.types.chat.Chat.delete_sticker_set
,aiogram.types.chat.Chat.set_sticker_set
,aiogram.types.chat.Chat.get_member
,aiogram.types.chat.Chat.get_member_count
,aiogram.types.chat.Chat.leave
,aiogram.types.chat.Chat.unpin_all_messages
,aiogram.types.chat.Chat.unpin_message
,aiogram.types.chat.Chat.pin_message
,aiogram.types.chat.Chat.set_administrator_custom_title
,aiogram.types.chat.Chat.set_permissions
,aiogram.types.chat.Chat.promote
,aiogram.types.chat.Chat.restrict
,aiogram.types.chat.Chat.unban
,aiogram.types.chat.Chat.ban
,aiogram.types.chat.Chat.set_description
,aiogram.types.chat.Chat.set_title
,aiogram.types.chat.Chat.delete_photo
,aiogram.types.chat.Chat.set_photo
,
- Chat
- Sticker:
aiogram.types.sticker.Sticker.set_position_in_set
, aiogram.types.sticker.Sticker.delete_from_set
,
- Sticker:
- User:
aiogram.types.user.User.get_profile_photos
#952- Added enums:
- Added
callback answer <callback-answer-util>
feature #1091 - Added a method that allows you to compactly register routers #1117
- Check status code when downloading file #816
- Fixed ignore_case parameter in
aiogram.filters.command.Command
filter #1106
- Added integration with new code-generator named Butcher #1069
- Added full support of Bot API 6.4 #1088
- Updated package metadata, moved build internals from Poetry to Hatch, added contributing guides. #1095
Added full support of Bot API 6.5
Danger
Note that
aiogram.types.chat_permissions.ChatPermissions
is updated without backward compatibility, so now this object has nocan_send_media_messages
attribute- Replaced error
TypeError: TelegramEventObserver.__call__() got an unexpected keyword argument '<name>'
with a more understandable one for developers and with a link to the documentation. #1114 - Added possibility to reply into webhook with files #1120
- Reworked graceful shutdown. Added method to stop polling. Now polling started from dispatcher can be stopped by signals gracefully without errors (on Linux and Mac). #1124
(again) Added possibility to combine filters with an and/or operations.
Read more in "
Combining filters <combining-filters>
" documentation section #1018Added following methods to
Message
class:Message.forward(...)
Message.edit_media(...)
Message.edit_live_location(...)
Message.stop_live_location(...)
Message.pin(...)
-
Message.unpin()
#1030Added following methods to
User
class:User.mention_markdown(...)
-
User.mention_html(...)
#1049- Added full support of Bot API 6.3 #1057
- Fixed
Message.send_invoice
andMessage.reply_invoice
, added missing arguments #1047 Fixed copy and forward in:
Message.answer(...)
-
Message.copy_to(...)
#1064
- Fixed UA translations in index.po #1017
- Fix typehints for
Message
,reply_media_group
andanswer_media_group
methods #1029 - Removed an old now non-working feature #1060
- Enabled testing on Python 3.11 #1044
- Added a mandatory dependency
certifi
in due to in some cases on systems that doesn't have updated ca-certificates the requests to Bot API fails with reason[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain
#1066
- Add PyPy support and run tests under PyPy #985
- Added message text to aiogram exceptions representation #988
- Added warning about using magic filter from magic_filter instead of aiogram's ones. Is recommended to use from aiogram import F instead of from magic_filter import F #990
- Added more detailed error when server response can't be deserialized. This feature will help to debug unexpected responses from the Server #1014
- Reworked error event, introduced
aiogram.types.error_event.ErrorEvent
object. #898 - Fixed escaping markdown in aiogram.utils.markdown module #903
- Fixed polling crash when Telegram Bot API raises HTTP 429 status-code. #995
- Fixed empty mention in command parsing, now it will be None instead of an empty string #1013
- Initialized Docs translation (added Ukrainian language) #925
- Removed filters factory as described in corresponding issue. #942
- Now Router/Dispatcher accepts only keyword arguments. #982
- Add class helper ChatAction for constants that Telegram BotAPI uses in sendChatAction request. In my opinion, this will help users and will also improve compatibility with 2.x version where similar class was called "ChatActions". #803
Added possibility to combine filters or invert result
Example:
Text(text="demo") | Command(commands=["demo"]) MyFilter() & AnotherFilter() ~StateFilter(state='my-state')
- Fixed type hints for redis TTL params. #922
- Added full_name shortcut for Chat object #929
- Fixed false-positive coercing of Union types in API methods #901
Added 3 missing content types:
- proximity_alert_triggered
- supergroup_chat_created
* channel_chat_created #906
- Fixed the ability to compare the state, now comparison to copy of the state will return True. #927
- Fixed default lock kwargs in RedisEventIsolation. #972
- Restrict including routers with strings #896
- Changed CommandPatterType to CommandPatternType in aiogram/dispatcher/filters/command.py #907
- Added full support of Bot API 6.1 #936
Breaking! More flat project structure
These packages was moved, imports in your code should be fixed:
aiogram.dispatcher.filters
->aiogram.filters
aiogram.dispatcher.fsm
->aiogram.fsm
aiogram.dispatcher.handler
->aiogram.handler
aiogram.dispatcher.webhook
->aiogram.webhook
-
aiogram.dispatcher.flags/*
->aiogram.dispatcher.flags
(single module instead of package) #938- Removed deprecated
router.<event>_handler
androuter.register_<event>_handler
methods. #941 - Deprecated filters factory. It will be removed in next Beta (3.0b5) #942
- MessageEntity method get_text was removed and extract was renamed to extract_from #944
- Added full support of Bot API 6.2 #975
- Added possibility to get command magic result as handler argument #889
- Added full support of Telegram Bot API 6.0 #890
- Fixed I18n lazy-proxy. Disabled caching. #839
- Added parsing of spoiler message entity #865
- Fixed default parse_mode for Message.copy_to() method. #876
- Fixed CallbackData factory parsing IntEnum's #885
- Added automated check that pull-request adds a changes description to CHANGES directory #873
- Changed
Message.html_text
andMessage.md_text
attributes behaviour when message has no text. The empty string will be used instead of raising error. #874 - Used redis-py instead of aioredis package in due to this packages was merged into single one #882
- Solved common naming problem with middlewares that confusing too much developers - now you can't see the middleware and middlewares attributes at the same point because this functionality encapsulated to special interface. #883
- Added possibility to pass additional arguments into the aiohttp webhook handler to use this arguments inside handlers as the same as it possible in polling mode. #785
- Added possibility to add handler flags via decorator (like pytest.mark decorator but aiogram.flags) #836
Added
ChatActionSender
utility to automatically sends chat action while long process is running.It also can be used as message middleware and can be customized via
chat_action
flag. #837
- Logger name for processing events is changed to
aiogram.events
. #830 - Added full support of Telegram Bot API 5.6 and 5.7 #835
- BREAKING Events isolation mechanism is moved from FSM storages to standalone managers #838
Added new custom operation for MagicFilter named
as_
Now you can use it to get magic filter result as handler argument
from aiogram import F ... @router.message(F.text.regexp(r"^(\d+)$").as_("digits")) async def any_digits_handler(message: Message, digits: Match[str]): await message.answer(html.quote(str(digits))) @router.message(F.photo[-1].as_("photo")) async def download_photos_handler(message: Message, photo: PhotoSize, bot: Bot): content = await bot.download(photo)
- Fixed: Missing
ChatMemberHandler
import inaiogram/dispatcher/handler
#751
- Check
destiny
in case of nowith_destiny
enabled in RedisStorage key builder #776 - Added full support of Bot API 5.5 #777
- Stop using feature from #336. From now settings of client-session should be placed as initializer arguments instead of changing instance attributes. #778
- Make TelegramAPIServer files wrapper in local mode bi-directional (server-client, client-server) Now you can convert local path to server path and server path to local path. #779
- Breaking: Changed the signature of the session middlewares Breaking: Renamed AiohttpSession.make_request method parameter from call to method to match the naming in the base class Added middleware for logging outgoing requests #716
Improved description of filters resolving error. For example when you try to pass wrong type of argument to the filter but don't know why filter is not resolved now you can get error like this:
aiogram.exceptions.FiltersResolveError: Unknown keyword filters: {'content_types'} Possible cases: - 1 validation error for ContentTypesFilter content_types Invalid content types {'42'} is not allowed here (type=value_error)
- Breaking internal API change Reworked FSM Storage record keys propagation #723
Implemented new filter named
MagicData(magic_data)
that helps to filter event by data from middlewares or other filtersFor example your bot is running with argument named
config
that contains the application config then you can filter event by value from this config:@router.message(magic_data=F.event.from_user.id == F.config.admin_id) ...
- Fixed I18n context inside error handlers #726
- Fixed bot session closing before emit shutdown #734
- Fixed: bound filter resolving does not require children routers #736
- Enabled testing on Python 3.10 Removed async_lru dependency (is incompatible with Python 3.10) and replaced usage with protected property #719
- Converted README.md to README.rst and use it as base file for docs #725
Rework filters resolving:
- Automatically apply Bound Filters with default values to handlers
- Fix data transfer from parent to included routers filters #727
- Added full support of Bot API 5.4 https://core.telegram.org/bots/api-changelog#november-5-2021 #744
- Added
html_text
andmd_text
to Message object #708 - Refactored I18n, added context managers for I18n engine and current locale #709
Added support of local Bot API server files downloading
When Local API is enabled files can be downloaded via bot.download/bot.download_file methods. #698
- Implemented I18n & L10n support #701
- Covered by tests and docs KeyboardBuilder util #699
Breaking!!!. Refactored and renamed exceptions.
- Exceptions module was moved from
aiogram.utils.exceptions
toaiogram.exceptions
- Added prefix Telegram for all error classes #700
- Exceptions module was moved from
- Replaced all
pragma: no cover
marks via global.coveragerc
config #702 Updated dependencies.
Breaking for framework developers Now all optional dependencies should be installed as extra: poetry install -E fast -E redis -E proxy -E i18n -E docs #703
- Ability to iterate over all states in StatesGroup. Aiogram already had in check for states group so this is relative feature. #666
- Fixed incorrect type checking in the
aiogram.utils.keyboard.KeyboardBuilder
#674
- Disable ContentType filter by default #668
- Moved update type detection from Dispatcher to Update object #669
- Updated pre-commit config #681
- Reworked handlers_in_use util. Function moved to Router as method .resolve_used_update_types() #682
- add aliases for edit/delete reply markup to Message #662
- Reworked outer middleware chain. Prevent to call many times the outer middleware for each nested router #664
- Prepare parse mode for InputMessageContent in AnswerInlineQuery method #660
- Added integration with
towncrier
#602