Commit graph

194 commits

Author SHA1 Message Date
Alex Root Junior
c8dff11d1e
Update thumbnail type to InputFile only (#1374)
* 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
2023-11-24 21:10:02 +02:00
Alex Root Junior
3d63bf3b99
PoC Scenes (#1280)
* 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>
2023-11-23 00:41:21 +02:00
Oleg A
e17e3bc71c
Fix CallbackData without default Optional (#1370)
* 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>
2023-11-20 22:39:09 +02:00
Nachtalb
c1bafea3e8
Upgrade to py12 (#1354)
* 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>
2023-11-18 21:24:19 +02:00
JRoot Junior
0fc718deeb
Small changes in the pending changelog 2023-11-17 00:27:30 +02:00
Alex Root Junior
3ad5ed6bc2
Fixed ResourceWarnings in tests (#1366)
* #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
2023-11-16 02:08:36 +02:00
Oleg A
9a2a72fe97
Add pydantic 2.5 support (#1361)
* chore: add pydantic 2.5 support

* docs: add changelog
2023-11-14 12:35:37 +02:00
Egor
7b30caed53
chore(docs): update middleware.rst (#1353)
* Update middleware.rst

* changes
2023-11-14 02:44:04 +02:00
RootShinobi
e76f4c38ad
new improved CallableMixin (#1357)
* optimized CallableMixin

* changes and Sets

* reformatted

* Update CHANGES/1357.misc.rst

Co-authored-by: Oleg A. <t0rr@mail.ru>

---------

Co-authored-by: Oleg A. <t0rr@mail.ru>
2023-11-13 21:04:58 +02:00
Kostiantyn Kriuchkov
9b5e462068
Add current handler to filters, so that flags can be retrieved from it. (#1360)
* 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>
2023-11-13 21:03:21 +02:00
Alex Root Junior
180a7297ff
Update typing-extensions version range in dependencies (#1352)
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.
2023-10-28 23:09:30 +03:00
Alex Root Junior
e3def608f1
Add CITATION.cff for automatic academic citation (#1351)
* 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
2023-10-27 00:48:47 +03:00
ZeroN
d8e7801963
Add new FSM strategy CHAT_TOPIC strategy.py (#1344)
* Create 1343.feature.rst

* Add new FSM strategy CHAT_TOPIC strategy.py

* ADD CHAT_TOPIC tests test_strategy.py

* Update 1343.feature.rst

* Update strategy.py

* add typing  user_id: Optional[int] = None, middleware.py

* add typing  user_id: Optional[int] = None  base.py

* Update strategy.py

* Update strategy.py

* Update middleware.py

* Update base.py

* Update test_strategy.py

* Update base.py

* Update strategy.py
2023-10-22 00:41:13 +03:00
VasBrd
98771fdf31
Update base.rst (#1340)
* Update base.rst

Typo correction

* Create 1340.doc.rst
2023-10-18 22:00:25 +03:00
Suren Khorenyan
564292dd79
Fix send_copy helper parse mode (#1332)
* Fix send_copy helper parse mode

* Add changelog for bugfix 1332
2023-10-08 18:56:30 +03:00
Sergey Akentev
cad42580dd
Prevent update handling task pointers from being garbage collected, backport of #1328 (#1331)
* Preserve update handling task pointers, backport of #1328

* Changelog

* Typing improvements
2023-10-08 18:13:06 +03:00
Alex Root Junior
67382553e5
Update dependencies (#1327)
* Update dependencies

* Added changelog
2023-10-01 16:22:26 +03:00
Kostiantyn Kriuchkov
b5ef05c01a
Corrected grammatical errors, improved sentence structures, translation for migration 2.x-3.x (#1302)
* Corrected grammatical errors, improved sentence structures for clarity, added translation to migration_2_to_3.rst

* add changelog

* Update method name in docs for error handling

* Update migration_2_to_3.rst

Co-authored-by: Oleg A. <t0rr@mail.ru>

* Update migration_2_to_3.rst

Co-authored-by: Oleg A. <t0rr@mail.ru>

* Update migration_2_to_3.rst

Co-authored-by: Oleg A. <t0rr@mail.ru>

* Update docs/locale/uk_UA/LC_MESSAGES/api/methods/set_sticker_set_thumb.po

Co-authored-by: Oleg A. <t0rr@mail.ru>

* rollback unnecessary change for error attribute

---------

Co-authored-by: Oleg A. <t0rr@mail.ru>
2023-10-01 15:29:18 +03:00
Alex Root Junior
0895e0f49c
Bump version 2023-09-25 19:07:47 +03:00
Oleg A
1dcb830b9d
Fix pydantic version (#1322)
* fix: fix pydantic version

* docs: changelog add
2023-09-25 19:04:16 +03:00
Alex Root Junior
c3dc6fe7a8
Changelog 2023-09-22 18:11:30 +03:00
Alex Root Junior
fec138977d
Telegram Bot API 6.9 (#1319)
* Added support for Bot API 6.9

* Bump API

* Added changelog
2023-09-22 17:46:57 +03:00
Alex Root Junior
a0828f6ddf
#1317 Fixed priority of events isolation (#1318) 2023-09-21 22:54:48 +03:00
Oleg A
83a01f014c
fix: added absent params for button builders (#1304)
* fix: added absent params for button builders

* docs: added changelog

* fix: renamed changelog item
2023-09-19 17:42:09 +03:00
Oleg A
995a0d7e9b
Custom encoding support (#1278)
* Custom encoding support in deep-linking
2023-09-03 00:26:57 +03:00
Alex Root Junior
5cf8d7b565
Add MediaGroupBuilder for media group construction (#1293)
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
2023-09-03 00:25:31 +03:00
Alex Root Junior
0161322598
Bump changelog 2023-09-01 18:04:42 +03:00
Alex Root Junior
04bd0c9e7c
Fixed error overlapping when validation error is caused by remove_unset root validator in base types and methods. (#1290)
* 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
2023-08-29 02:01:54 +03:00
Alex Root Junior
e1be9dd668
Fix Message.send_copy method for stories (#1287)
* 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
2023-08-28 22:32:11 +03:00
Alex Root Junior
6eb5ef2606
Replace datetime.datetime with DateTime across codebase (#1285)
* #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.
2023-08-27 17:09:56 +03:00
Alex Root Junior
397f30b58b
Fixed method :code:Message.send_copy for stickers (#1284) 2023-08-26 23:24:51 +03:00
Alex Root Junior
ee8e457c5f
#1281 Fix magic operation .as_ for values interpreted as False (#1283)
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.
2023-08-26 22:33:32 +03:00
onejeuu
bff2ed0a86
Fix markdown italic quote (#1282)
* Fix markdown italic quote

* Add changelog
2023-08-26 22:31:30 +03:00
Alex Root Junior
787ad6b094
Render changelog 2023-08-18 20:21:01 +03:00
Alex Root Junior
678b3cfe7d
Bot API 6.8 (#1276)
* Prepare for Bot API 6.8

* Bump after public release

* Bump version, added changelog
2023-08-18 20:18:05 +03:00
Alex Root Junior
d0d0ff1be0
Update a warning message in dispatcher (#1269)
* Update a warning message in dispatcher

Enhanced the warning message in aiogram/dispatcher/dispatcher.py to include a JSON dump of the update. This change helps to give clearer and more detailed information on why an update type is unknown by including the specifics of what the update contains.

* Added changelog
2023-08-16 20:43:18 +03:00
nullmatawasoradesu
2093b45799
Fixed some typos in documentation (#1268)
* Fixed typo in i18n documentation

* Removed extra param in docstring of TelegramEventObserver's filter method

* Added changelog
2023-08-16 17:23:10 +03:00
Danipulok
16649ec896
Add error handling example (#1099)
* Add error handling example

* Add `ExceptionMessageFilter` usage

* Add `CHANGES`

* Update CHANGES/1099.doc.rst

---------

Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>
2023-08-14 23:43:44 +03:00
Alex Root Junior
8ff992bf1d
Content from global filters (#1267)
* Move 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

* Added changelog
2023-08-14 22:18:11 +03:00
Alex Root Junior
577b44cdc1
Merge remote-tracking branch 'origin/dev-3.x' into dev-3.x 2023-08-14 01:34:30 +03:00
Alex Root Junior
3facba2730
Remove bad file 2023-08-14 01:34:24 +03:00
nullmatawasoradesu
0cec7d4933
Migration FAQ supplement (Finite State Machine) (#1264)
* Updated Migration FAQ > Finite State Machine

* Fixed typos, added changelog

* Fixed typo x2
2023-08-13 22:41:56 +03:00
Forden
4d12e073ee
Fix missing message content types (#1252)
* Fix missing message content types

* Added changelog

* Fix black

* Update CHANGES/1252.bugfix.rst

Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>

* add tests

---------

Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>
2023-08-13 18:05:04 +03:00
Kostiantyn Kriuchkov
fac0a533b0
Examples/dev 3x multi file (#1254)
* Add multi-file bot example

This commit adds a multi-file bot example to the repository. .

* Refactor: Clean up code formatting for consistency

* add Changelog

* Refactor bot code, fix changelog version
2023-08-13 18:00:59 +03:00
nullmatawasoradesu
f87deea4fb
Added a section on Dependency Injection technology in documentation (#1253)
* Added a section on Dependency Injection technology in documentation

* Added changelog

* Edited comments & titles
2023-08-13 17:59:38 +03:00
Kostiantyn Kriuchkov
068875534b
Examples/dev 3x refactor fix* (#1261)
* Refactor and improve bot messages

Refactored bot code to use aiogram enumerations and enhanced chat messages with markdown beautifications for a more user-friendly display.

CommandStart() is now used instead of Command('start') for readability.

Furthermore, the bot's 'stop' command was improved, ensuring it executes appropriately during KeyboardInterrupt or SystemExit.

Additionally, the bot's logging was adjusted to output to sys.stdout for better logs' readability.

* Added Changelog

* Add guidance comments on obtaining bot tokens from environment variables

* Remove hardcoded tokens, opt for environment variable

* Remove unnecessary spaces and reorganize imports

* Fix error, switch default storage from Redis to Memory, and add logging to multibot example

* fix changelog version

---------

Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>
2023-08-13 17:56:32 +03:00
Alex Root Junior
a80031509e
Fixed nested hashtag, cashtag and email entnties parsing (#1263)
* Fixed nested hashtag, cashtag and email message entities not being parsed correctly when these entities are inside another entity.

* Tests coverage
2023-08-13 17:55:35 +03:00
Kostiantyn Kriuchkov
c516ea9d6a
Refactor and improve bot examples (#1256)
* Refactor and improve bot messages

Refactored bot code to use aiogram enumerations and enhanced chat messages with markdown beautifications for a more user-friendly display.

CommandStart() is now used instead of Command('start') for readability.

Furthermore, the bot's 'stop' command was improved, ensuring it executes appropriately during KeyboardInterrupt or SystemExit.

Additionally, the bot's logging was adjusted to output to sys.stdout for better logs' readability.

* Added Changelog

* Add guidance comments on obtaining bot tokens from environment variables

* Remove hardcoded tokens, opt for environment variable

* Remove unnecessary spaces and reorganize imports

* Fix error, switch default storage from Redis to Memory, and add logging to multibot example
2023-08-10 22:10:30 +03:00
nullmatawasoradesu
6d6bcd0a9b
Added a few words about skipping pending updates (#1251)
* Added a few words about skipping pending updates

* Added changelog

* Fixed typo
2023-08-07 23:54:05 +03:00
Alex Root Junior
649f76b5f6
Bump changelog 2023-08-06 19:31:10 +03:00