Commit graph

2165 commits

Author SHA1 Message Date
JRoot Junior
6ad287c329
Bump changelog 2024-04-24 22:14:34 +03:00
unintended
f1c9fc50f0
Fix missing error logging (#1458)
* Fix missing error logging 

No error logging when handle_in_background=True

* add CHANGES
2024-04-23 13:59:13 +03:00
Alex Root Junior
4729978c60
Add context manager support for bot client (#1468)
* Add context manager support for bot client

The bot client now supports the context manager protocol, providing automatic resource management. This enhancement helps to automatically close the session when leaving the context, which cleans up resources better. The documentation and tests have been updated accordingly to illustrate this new feature. Moreover, an example of usage without a dispatcher has been provided to clarify its use in simple cases.

* Added changelog
2024-04-22 23:42:47 +03:00
Joren Hammudoglu
9756dac877
loosened pydantic upper bound to <2.8 (#1460)
* bump pydantic to 2.8

* add changelog entry for #1460
2024-04-22 13:49:34 +03:00
Alex Root Junior
057478621b
Added full support of Bot API 7.2 (#1444)
* 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>
2024-04-22 13:48:49 +03:00
Oleg A
5f157beb26
Bump actions versions (#1459)
* chore: bump actions versions

* chore: add pypy310
2024-04-17 14:09:19 +03:00
Yana Malenko
b49939aaff
add default bot properties and clean imports (#1447) 2024-04-09 01:27:29 +03:00
avoidaway
acf52f468c
chore: remove repetitive words (#1438)
Signed-off-by: avoidaway <cmoman@126.com>
2024-03-17 02:20:29 +02:00
Maxim
506dacc0ff
Added message_thread_id parameter to ChatActionSender class methods (#1437)
* Added message_thread_id parameter to ChatActionSender class methods

* Added changelog

* rename chagelog file
2024-03-11 21:53:17 +02:00
Alex Root Junior
0c9eeda8a7
Fixed poll answer FSM context (#1436)
* 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
2024-03-10 16:18:41 +02:00
JRoot Junior
30cee817f4
Merge remote-tracking branch 'origin/dev-3.x' into dev-3.x 2024-03-09 00:40:59 +02:00
JRoot Junior
bc08d90ce5
More tests for defaults 2024-03-09 00:40:46 +02:00
JRoot Junior
ee71117807
Bump pydantic version 2024-03-09 00:38:37 +02:00
Leroy-bit
a2e75e5345
doc updated for WebApp (#1433)
Added WebAppChat class to WebApp docs, updated uk_UA localisation of WebApp docs.
2024-03-06 01:37:37 +02:00
Kostiantyn Kriuchkov
a585fb08de
Add missing Telegram WebApp API classes and fields (#1424) (#1425)
* 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
2024-02-26 02:13:32 +02:00
JRoot Junior
a37deff396
Fixed typo in the changelog 2024-02-17 10:46:50 +02:00
JRoot Junior
27dddff7f5
Update changelog + version 2024-02-17 10:21:41 +02:00
Alex Root Junior
53849b01a7
Fixed default LinkPreviewOptions JSON serialization (#1419)
* Fixed default link preview options serialization

* Added changelog
2024-02-17 10:10:50 +02:00
JRoot Junior
eef50a2edb
Bump API version in the docs 2024-02-16 23:48:54 +02:00
JRoot Junior
eaa56623ff
Render changelog 2024-02-16 23:47:06 +02:00
Alex Root Junior
75323ac8c3
Added full support of Bot API 7.1 (#1417)
* Added full support of Bot API 7.1

* Added changelog
2024-02-16 23:44:35 +02:00
JRoot Junior
e5176b4434
Update docs translation files 2024-02-16 01:17:09 +02:00
JRoot Junior
18b32f065d
Update changelog 2024-02-16 01:15:12 +02:00
JRoot Junior
0cf5afeb99
Add deprecation warnings to Bot properties
Three properties of the Bot class - parse_mode, disable_web_page_preview, and protect_content - have been marked as deprecated with proper warning messages. The associated tests have also been added to confirm the working of these deprecation warnings. Users are advised to use the updated alternatives specified in the warning messages.
2024-02-16 01:13:51 +02:00
JRoot Junior
e6e2601d4b
Fixed typehints in keyboard builder 2024-02-13 22:09:48 +02:00
Robotvasya
298e9821a4
Add notion Working with plural forms in documentation (#1409) 2024-02-09 21:30:02 +02:00
JRoot Junior
091b82e13f
Change magic filter examples 2024-02-09 21:27:21 +02:00
JRoot Junior
f7af9e7f4a
Fixed deep linking URL 2024-02-04 01:49:39 +02:00
Egor
bff483b8a7
Update message.send_copy: add missing reply_parameters param (#1403)
* Update message.send_copy: add missing reply_parameters param

* added changes file

* update changes file

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

---------

Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>
2024-02-03 19:25:14 +02:00
Alex Root Junior
844d6f58f5
Update KeyboardBuilder utility, fixed type-hints for button method, a… (#1399)
* Update KeyboardBuilder utility, fixed type-hints for button method, adjusted limits of the different markup types to real world values.

* Added changelog

* Fixed coverage

* Update aiogram/utils/keyboard.py

Co-authored-by: Suren Khorenyan <surenkhorenyan@gmail.com>

* Fixed codestyle

---------

Co-authored-by: Suren Khorenyan <surenkhorenyan@gmail.com>
2024-01-27 19:01:19 +02:00
Alex Root Junior
d3c63797b0
Add KeyboardButtonPollTypeType enum (#1398)
* 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
2024-01-27 18:04:05 +02:00
JRoot Junior
eeafe4696c
Bump version 2024-01-27 17:20:29 +02:00
Alex Root Junior
24f59da70d
Reworked bot-wide defaults (#1392)
* Reworked defaults

* Added changelog and partial docs
2024-01-27 17:19:45 +02:00
JRoot Junior
1281bf551a
Describe new event observers in the docs 2023-12-31 15:21:41 +02:00
JRoot Junior
d394af83bd
Update docs 2023-12-31 11:51:00 +02:00
JRoot Junior
233d3c469d
Towncrier 2023-12-31 03:06:18 +02:00
Alex Root Junior
6795b3de05
Added support for Bot API 7.0 (#1387)
* 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>
2023-12-31 01:40:44 +02:00
SM CheeseNick
756cfeba0a
Update dispatcher.py (#1384)
On line 576 corrected typo in world more (was mre)
2023-12-23 01:47:38 +02:00
JRoot Junior
a2e5f9a8b8
Update changelog 2023-11-24 23:29:21 +02:00
JRoot Junior
69a07e3b0c
Update docs 2023-11-24 21:55:58 +02:00
JRoot Junior
fc9e2b82c6
Added page for deep linking util 2023-11-24 21:27:03 +02:00
JRoot Junior
94939660c7
Update texts 2023-11-24 21:26:33 +02:00
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
JRoot Junior
09af2a1c8b
Fixed lines range 2023-11-23 02:27:03 +02:00
JRoot Junior
ead79a1927
Fixed typo 2023-11-23 01:56:26 +02:00
JRoot Junior
423796a445
Added translation for Scenes 2023-11-23 01:28:11 +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
JRoot Junior
ce4e1a706d
#1370 added possibility to check X | None on Python >= 3.10 2023-11-20 22:49:55 +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
JRoot Junior
ebade3d51f
Merge test+pypy tests but with separated jobs 2023-11-18 21:45:22 +02:00