Skip to content
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

feat: added setting to disable discord message on rate limit #232

Merged
merged 1 commit into from
Mar 8, 2025

Conversation

TeKrop
Copy link
Owner

@TeKrop TeKrop commented Mar 8, 2025

Summary by Sourcery

New Features:

  • Adds a setting to disable Discord messages when the Blizzard API rate limit is reached.

@TeKrop TeKrop added the enhancement New feature or request label Mar 8, 2025
@TeKrop TeKrop self-assigned this Mar 8, 2025
Copy link
Contributor

sourcery-ai bot commented Mar 8, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new configuration setting that allows users to disable the Discord message that is sent when the Blizzard API rate limit is reached. This is implemented by adding a new boolean setting to the Settings class and modifying the _blizzard_forbidden_error method to conditionally send the Discord message based on the value of this setting.

Sequence diagram for Blizzard Rate Limit with Discord Message Toggle

sequenceDiagram
    participant OverfastClient
    participant Settings
    participant DiscordWebhook

    OverfastClient->>Settings: Check discord_message_on_rate_limit
    alt discord_message_on_rate_limit is true
        OverfastClient->>DiscordWebhook: Send rate limit message
        DiscordWebhook-->>OverfastClient: OK
    else discord_message_on_rate_limit is false
        OverfastClient-->>OverfastClient: Continue without sending message
    end
    OverfastClient-->>OverfastClient: Return Too Many Requests Response
Loading

Updated class diagram for Settings

classDiagram
    class Settings {
        +sentry_dsn: str
        +environment: str
        +debug: bool
        +fastapi_logs: bool
        +uvicorn_logs: bool
        +overfast_api_url: str
        +openapi_route: str
        +exception_handler: bool
        +cors_origins: list[str]
        +cors_allow_credentials: bool
        +cors_allow_methods: list[str]
        +cors_allow_headers: list[str]
        +cache_enabled: bool
        +cache_timeout: int
        +cache_size: int
        +blizzard_client_id: str
        +blizzard_client_secret: str
        +blizzard_api_url: str
        +blizzard_oauth_url: str
        +blizzard_rate_limit_requests: int
        +blizzard_rate_limit_time_frame: int
        +blizzard_rate_limit_retry_after: int
        +discord_webhook_url: str
        +github_repo_url: str
        +contact_email: str
        +discord_message_on_rate_limit: bool
    }
    note for Settings "Added discord_message_on_rate_limit attribute"
Loading

File-Level Changes

Change Details Files
Added a configuration setting to control whether a Discord message is sent when the Blizzard API rate limit is reached.
  • Introduced a new boolean setting discord_message_on_rate_limit in the Settings class.
  • Modified the _blizzard_forbidden_error method to conditionally send a Discord message based on the value of the new setting.
  • Added the new setting to the .env.dist file.
app/overfast_client.py
app/config.py
.env.dist

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @TeKrop - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a comment to the config setting to explain when a user might want to disable the Discord message.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

sonarqubecloud bot commented Mar 8, 2025

@TeKrop TeKrop merged commit 9c9c115 into main Mar 8, 2025
4 checks passed
@TeKrop TeKrop deleted the feature/setting-for-discord-message-on-rate-limit branch March 8, 2025 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant