Skip to content

Conversation

@electron271
Copy link
Member

@electron271 electron271 commented May 13, 2025

Description

adds more categories to facts so its not just linux focused

#854

Summary by Sourcery

Improve the fun facts command by organizing facts into multiple categories, expanding its content, and enabling users to retrieve facts by category through both prefix and slash command interfaces.

New Features:

  • Allow users to select fact categories (Linux, Cat, Tux, or Random) in the fact command
  • Add new cat and Tux-specific fun facts

Enhancements:

  • Introduce FactType enum and fact_type_map to organize facts by category
  • Migrate monolithic fact list into separate category lists with validation and error handling
  • Annotate the slash command with app_commands choices and descriptions for category argument
  • Implement docstring_parameter decorator to format docstrings dynamically

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented May 13, 2025

Reviewer's Guide

Refactors the fun facts command to support multiple categories by introducing a FactType enum and separate fact lists, integrates slash-command metadata and a dynamic docstring decorator, and cleans up legacy hardcoded code.

File-Level Changes

Change Details Files
Introduce categorized fact data structures
  • Added linux_facts, cat_facts, and tux_facts lists
  • Created FactType enum for category labels
  • Built fact_type_map including a RANDOM category
tux/cogs/fun/fact.py
Update fact command signature and selection logic
  • Changed command to accept a fact_type argument with default RANDOM
  • Added validation of selected category and error handling
  • Picked facts from fact_type_map and updated embed title/description
tux/cogs/fun/fact.py
Add slash-command metadata and dynamic docstring decorator
  • Applied @app_commands.describe and @app_commands.choices for category selection
  • Implemented docstring_parameter decorator in utils/functions.py
  • Injected category options into the fact command docstring
tux/utils/functions.py
tux/cogs/fun/fact.py
Clean up legacy code and formatting
  • Removed old self.facts attribute and commented-out embed author code
  • Added explicit return statements and updated imports
  • Streamlined embed creation by removing redundant code
tux/cogs/fun/fact.py

Possibly linked issues


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!

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

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented May 13, 2025

Deploying tux with  Cloudflare Pages  Cloudflare Pages

Latest commit: b901b69
Status:⚡️  Build in progress...

View logs

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the fun facts command by extending the available fact categories and updating the command’s behavior and embed presentation.

  • Introduces three fact categories (Linux, Tux, and Cat) along with a RANDOM option that combines them.
  • Adds a new docstring_parameter decorator to dynamically format docstrings.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tux/utils/functions.py Added the docstring_parameter decorator to enable dynamic insertion into docstrings.
tux/cogs/fun/fact.py Extended the fact command with multiple fact categories and enriched its embed.
Comments suppressed due to low confidence (1)

tux/cogs/fun/fact.py:127

  • [nitpick] The variable name 'sel' is ambiguous; consider renaming it to a more descriptive name like 'selected_fact_type' for clarity.
sel = category_map[fact_type]

@kzndotsh
Copy link
Contributor

I suggest moving these out of the file and into a new global data dir or something

@electron271 electron271 requested a review from Copilot May 13, 2025 20:24
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 @electron271 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the fun facts command by organizing facts into multiple categories (Linux, Cat, Tux, and Random) and allowing users to select a category via prefix and slash command interfaces. Key changes include introducing new category lists and the FactType enum, refactoring the command to validate category selections, and adding a docstring_parameter decorator for dynamic docstring formatting.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tux/utils/functions.py Added a decorator to enable dynamic substitution in docstrings.
tux/cogs/fun/fact.py Refactored the fun fact command with category support and improved docs.
Comments suppressed due to low confidence (1)

tux/cogs/fun/fact.py:103

  • [nitpick] Consider using named placeholders in the docstring instead of a single unnamed {0} to improve clarity and maintainability of the substitution.
@docstring_parameter(f"Available categories: {', '.join([ft.value for ft in FactType])}. Default category is {FactType.RANDOM.value}.",)

@electron271
Copy link
Member Author

I suggest moving these out of the file and into a new global data dir or something

will make a issue and handle that soon so i can also try and see if anything else needs moving

@electron271 electron271 requested a review from Copilot May 13, 2025 20:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the fun facts command by organizing facts into multiple categories, enhancing user interaction, and expanding the repository of fun facts.

  • Introduces FactType enum and separate fact lists (linux, cat, tux, random)
  • Updates the command interface to support category selection via hybrid and slash commands
  • Adds a docstring_parameter decorator for dynamic docstring formatting

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tux/utils/functions.py Added a decorator for dynamic docstring formatting
tux/cogs/fun/fact.py Refactored fact command to support multiple categories and improved docs
Comments suppressed due to low confidence (1)

tux/cogs/fun/fact.py:102

  • [nitpick] Consider clarifying the usage of the docstring substitution placeholder '{0}' in the function's docstring so that it clearly maps to the provided dynamic content. This will improve readability and maintainability.
@docstring_parameter(f"Available categories: {', '.join([ft.value for ft in FactType])}. Default category is {FactType.RANDOM.value}.",)

@electron271 electron271 merged commit 1f61728 into main May 13, 2025
9 of 10 checks passed
@electron271 electron271 deleted the facts-revamp branch May 13, 2025 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants