* Added base support of Bot API 7.2
* Added base support of Bot API 7.2
* Fixing tests and content types for Telegram Bot API 7.2 update (#1453)
* Fixing tests and content types for Telegram Bot API 7.2
* Adding changelog for 1453 PR
* Fixes + coverage
* Replace `BusinessConnection.date` type
* Reformat code
* Refactor UserContextMiddleware to use EventContext class
This update significantly refactors UserContextMiddleware to leverage a new class, EventContext. Instead of resolving event context as a tuple, it now produces an instance of EventContext. Additional adjustments include supporting a business connection ID for event context identification and facilitating backwards compatibility. Tests and other files were also updated accordingly for these changes.
* Cover FSM key builder (business_connection_id
* Added changelog
---------
Co-authored-by: RoLOQ <roman.fedunn@gmail.com>
* Add voter_chat to poll_answer event handling
The change ensures that when a poll_answer event is processed, the user context middleware now also returns the chat where the vote took place. Previously, only the user who cast the vote was returned.
* Added changelog
* Fixed tests
* Bump Python version in test
* Add missing Telegram WebApp API classes and fields (#1424)
* Implemented `WebAppChat` class with fields `id`, `type`, `title`, `username`, and `photo_url` as per Telegram documentation.
* Modified `WebAppUser` class by adding `is_premium`, `added_to_attachment_menu`, and `allows_write_to_pm` fields.
* Modified `WebAppInitData` class to include `chat`, `chat_type`, `chat_instance` fields for full API support.
* fix changelog file name
* fix line too long
* Add KeyboardButtonPollTypeType enum
A new enum, KeyboardButtonPollType, has been added and documented. This enum holds types of polls that can be created and sent when the corresponding button is pressed. It is now imported and included in the aiogram enums documentation.
* Added changelog
* Added support for Bot API 7.0
* Fixed available tests
* Fixed text decorations
* Bot API 7.0 tests for ForwardMessages
* Bot API 7.0 tests for CopyMessages
* Bot API 7.0 tests for DeleteMessages
* Bot API 7.0 tests for GetUserChatBoosts
* Bot API 7.0 tests for SetMessageReaction
* Fixed custom_emoji attribute name
* Fixed tests
* Test parsing CallbackQuery message (inaccessible and accessible)
* Added changes description
* Bot API 7.0 tests for dispatcher handle update message_reaction
* Bot API 7.0 tests for dispatcher handle update message_reaction_count
* Bot API 7.0 tests for dispatcher handle update chat_boost
* Bot API 7.0 tests for dispatcher handle update removed_chat_boost
* fix tests: update ReactionTypeCustomEmoji custom_emoji -> custom_emoji_id
* micro fix Markdown V2 blockquote
* add tests for Markdown tools
* fix markdown test apply single entity
* add tests coverage for Message.react
* check that all messages and content types are covered for Message.content_type
* sort imports in tests (run `make reformat lint`)
* update Giveaway objects Unix time field to DateTime type
* Update Message.content_type property
* upgrade tests for message content_types and sent_copy
* Update Giveaway type generation config
* Update GiveawayWinners and PassportFile types generation configs
---------
Co-authored-by: Suren Khorenyan <surenkhorenyan@gmail.com>
* Update thumbnail type to InputFile only
The thumbnail's type restriction has been changed in several methods and types. Previously, it accepted Union[InputFile, str], allowing both InputFile instances and strings. Now it's changed to accept only InputFile instances. This change enhances meaning of the thumbnail fields in due to Bot API accepts only InputFile instances.
* Added changelog
* Fixed typehints
* Base implementation
* Small refactoring + added possibility to specify post-action on handlers
* Move scene properties to config object
* Revise aiogram/scenes with wizard-based design pattern
Modified files in aiogram/scenes to incorporate the Wizard design pattern. Files affected are _marker.py, _registry.py, _wizard.py and __init__.py. The changes introduced a SceneWizard Class and ScenesManager, both of which aid in controlling navigation between different scenes or states. This helps clarifying the codebase, streamline scene transitions and offer more control over the app flow.
* Added example
* Small optimizations
* Replace ValueError with SceneException in scenes. Added error safety in scene resolver.
* str
* Added possibility to reset context on scene entered and to handle callback query in any state
* Remove inline markup in example
* Small changes
* Docs + example
* Small refactoring
* Remove scene inclusion methods from router
The methods for including scenes as sub-routers have been removed from the router.py file. Instead, the SceneRegistry class is now set to register scenes by default upon initializing. This streamlines the scene management process by removing redundant routers and making registration automatic.
* Init tests
* Small fix in tests
* Add support for State instance in the scene
The aiogram FSM scene now allows the use of State instance as an argument, enabling more customization. Modified the 'as_handler' method to receive **kwargs arguments, allowing passing of attributes to the handler. An additional type check has been also added to ensure the 'scene' is either a subclass of Scene or a string.
* Fixed test
* Expand test coverage for test_fsm module
The commit enhances tests for the test_fsm module to improve code reliability. It includes additional unit tests for the ObserverDecorator and ActionContainer classes and introduces new tests for the SceneHandlerWrapper class. This ensures the correct functionality of the decorator methods, the action container execution, and the handler wrapper.
* Reformat code
* Fixed long line in the example
* Skip some tests on PyPy
* Change mock return_value
* Compatibility...
* Compatibility...
* Compatibility...
* Added base changes description
* Scenes Tests (#1369)
* ADD tests for `SceneRegistry`
* ADD tests for `ScenesManager`
* ADD Changelog
* Revert "ADD Changelog"
This reverts commit 6dd9301252.
* Remove `@pytest.mark.asyncio`, Reformat code
* Scenes Tests. Part 2 (#1371)
* ADD tests for `SceneWizard`
* ADD tests for `Scene`
* Refactor ObserverDecorator to use on.message syntax in test_scene.py
Cover `Scene::__init_subclass__::if isinstance(value, ObserverDecorator):`
* Refactor `HistoryManager` in `aiogram/fsm/scene.py`
Removed condition that checked if 'history' is empty before calling 'update_data' in 'Scene'.
* ADD tests for `HistoryManager`
* Small changes in the documentation
* Small changes in the documentation
* Small changes in the documentation
---------
Co-authored-by: Andrew <11490628+andrew000@users.noreply.github.com>
* fix: CallbackData set optional as None
* docs: add fix changelog
* Add support for nullable fields in callback data
This update extends the callback data handling by adding support for nullable fields. The code now uses the Python typing structures `Optional` and `Union` to parse such fields correctly. A helper function `_check_field_is_nullable` has been added to assist in efficiently checking if a given field is nullable.
* Add support for nullable fields in callback data
This update extends the callback data handling by adding support for nullable fields. The code now uses the Python typing structures `Optional` and `Union` to parse such fields correctly. A helper function `_check_field_is_nullable` has been added to assist in efficiently checking if a given field is nullable.
---------
Co-authored-by: JRoot Junior <jroot.junior@gmail.com>
* Upgrade to py12 compatible aiohttp beta version
* Fix uvloop deprecation warning causing pytest not to run
* Fix test due to asyncio task scheduling race condition
* Fix test_state_in_unknown_class for Python 3.12+ due to PEP 678 changes
* Add Python 3.12 support in GitHub Actions and project configurations
* Add changelog entry
---------
Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>
* #1320 Update pytest configuration and tests cleanup
This commit modifies the pytest's configuration file, `pyproject.toml`, to remove filterwarnings settings. It also makes changes in various test files; the Redis isolation test is now using the provided `redis_storage` fixture instead of setting up its own connection, pytest.mark.filterwarnings is no longer used in `test_isolation.py` and `test_aiohttp_session.py` properly closes off sessions.
* Added changelog
* Fixed coverage for the RedisEventIsolation
* Add current handler to filters, so that flags can be retrieved from it.
* run black isort
* add changelog
* Update CHANGES/1360.bugfix.rst
Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>
---------
Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>
This commit changes the version requirements for typing-extensions in the dependencies section of pyproject.toml file. This change now requires versions that are greater than or equal to 4.7.0 and less than or equal to 5.0. The previous version, 4.8.0, has been found to cause compatibility issues with some other libraries.
* Add CITATION.cff for automatic academic citation
A `CITATION.cff` file has been added to the project to facilitate the generation of accurate academic citations directly from the GitHub page. This allows users to easily copy the citation and paste it into their academic papers. The file includes the project's information like title, authors, repository code, url, keywords, and license.
* Fixed category name
Implemented a MediaGroupBuilder class in 'aiogram/utils/media_group.py' to help construct media groups. The class supports addition of different media types (audio, photo, video, document) to the media group with a maximum limit of 10 files. The functionality is demonstrated and usage is documented in 'docs/utils/media_group.rst'. Added related test cases in 'tests/test_utils/test_media_group.py'. This is to streamline and simplify the process of media group creation
* Ensure base type validation can handle non-dictionary values
The update introduces a condition to verify whether the values being validated are a dictionary before attempting to handle UNSET_TYPE in the aiogram base type. This adjustment helps to prevent potential errors or incorrect validation when non-dictionary values are faced.
* Added a test case for non-dictionary input in remove_unset method
* Added changelog
* Fixed tests
* Fix `Message.send_copy` method for stories
Fixed an issue with the `Message.send_copy` method, which was not functioning properly with story-type messages. The `ForwardMessage` logic has been added to the method to enable copying of stories, in addition to other types. Tests and documentation have also been updated to reflect these changes.
* Typo fix
* #1277 Replace datetime.datetime with DateTime across codebase
Replaced all instances of standard library 'datetime.datetime' with a new 'DateTime' type from `.custom` module. This change is necessary to make all date-time values compatible with the Telegram Bot API (it uses Unix time). This will simplify the conversion process and eliminate potential errors related to date-time format mismatches. Changed codebase, butcher files, and modified 'pyproject.toml' to shift the typing-extensions dependency. The 'aiogram/custom_types.py' file was renamed to 'aiogram/types/custom.py' to better reflect its nature as a location for custom types used in the aiogram library.
Modified the ".as_" method in the magic filter class to correctly handle values that are interpreted as `False` such as `0`. Previously, the method incorrectly dismissed these valid values. The issue was identified and fixed to ensure correct handling of all valid data inputs.