Skip to content

Add new FSM strategy CHAT_TOPIC to strategy.py #1343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

OnaZeroN
Copy link
Contributor

The new FSM strategy, which sets the state for the entire topic in the chat, also works in private messages and regular groups without topics.

Description

Aiogram did not have an FSM strategy that would set state only for a specific topic in the chat. This strategy is quite reasonable and it has many applications.
The work of state in private messages remains unchanged
The work of state in groups / super groups without topics, state will be established for all groups
The work of state in groups /super groups with topics, State will be established only for one topic, other topics will not have a state until it is installed, state can be set separately for each topic, and state_data will be separate in all topics where state is installed.

Fixes # (issue)

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

  • Run tests/test_fsm/test_strategy.py

  • You can run bot with FSMStrategy.CHAT_TOPIC, and make sure that the strategy is working correctly:

    • Check the work of state in private messages
    • Check the work of state in groups/super groups without topics, State should be set for the whole group, since the topic value will be None
    • Check the work of state in groups/super groups with topics, State should be installed only for one topic, other topics will not have a state until it is installed, state can be set separately for each topic, and state_data for should be separate in all topics where state is installed.

Test Configuration:

  • Operating System: windows 11
  • Python version: 3.11

Checklist:

  • [+] My code follows the style guidelines of this project
  • [+] I have performed a self-review of my own code
  • [-] I have made corresponding changes to the documentation
  • [+] I have added tests that prove my fix is effective or that my feature works
  • [+] New and existing unit tests pass locally with my changes

The new FSM strategy, which sets the state for the entire topic in the chat, also works in private messages and regular groups without topics.
@github-actions github-actions bot added the 3.x Issue or PR for stable 3.x version label Oct 20, 2023
@github-actions
Copy link

❌ Changelog is required!

You need to add a brief description of the changes to the CHANGES directory.

Changes file should be named like <issue or PR number>.<category>.rst,
example 1234.bugfix.rst where 1234 is the PR or issue number and bugfix is the category.

The content of the file should be a brief description of the changes in
the PR in the format of a description of what has been done.

Possible categories are: feature, bugfix, doc, removal and misc.

@OnaZeroN OnaZeroN closed this Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Issue or PR for stable 3.x version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant