Skip to content

feat: add extensions system and update README #828

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

Merged
merged 3 commits into from
Apr 19, 2025
Merged

Conversation

electron271
Copy link
Contributor

@electron271 electron271 commented Apr 19, 2025

Description

Adds a gitignored folder called tux/extensions/ where people can easily add custom cogs (even submodule them!)

Guidelines

  • My code follows the style guidelines of this project (formatted with Ruff)

  • I have performed a self-review of my own code

  • I have commented my code, particularly in hard-to-understand areas

  • I have made corresponding changes to the documentation if needed

  • My changes generate no new warnings

  • I have tested this change

  • Any dependent changes have been merged and published in downstream modules

  • I have added all appropriate labels to this PR

  • I have followed all of these guidelines.

How Has This Been Tested? (if applicable)

Added the file from #720 into the folder and also tested it in a subdirectory

Screenshots (if applicable)

Please add screenshots to help explain your changes.

Additional Information

Please add any other information that is important to this PR.

Summary by Sourcery

Implement an extensions system for Tux, allowing users to add custom cogs easily without modifying the core bot code

New Features:

  • Add a new extensions folder where users can add custom cogs
  • Implement automatic loading of cogs from the extensions directory, including support for subdirectories

Enhancements:

  • Modify cog loader to support loading cogs from an additional extensions folder

Documentation:

  • Update README to highlight the new extensions system feature
  • Add a detailed README.md in the extensions folder explaining how to use the new feature

@electron271 electron271 added category: meta Relating to architecture, systems and critical functions type: enhancement priority: high labels Apr 19, 2025
@electron271 electron271 self-assigned this Apr 19, 2025
Copy link

trunk-io bot commented Apr 19, 2025

⏱️ 13m total CI duration on this PR

Job Cumulative Duration Recent Runs
docker 5m 🟩🟩🟩
Analyze (python) 3m 🟩🟩🟩
pyright 3m 🟩🟩🟩🟩🟩
Ruff 2m 🟩🟩🟩🟩🟩

settingsfeedbackdocs ⋅ learn more about trunk.io

Copy link

trunk-io bot commented Apr 19, 2025

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

Copy link
Contributor

sourcery-ai bot commented Apr 19, 2025

Reviewer's Guide by Sourcery

This pull request introduces an extensions system that allows users to add custom cogs to the bot without modifying the core code. It also updates the README to include information about the new extensions system.

Sequence diagram for loading cogs with extensions

sequenceDiagram
  participant cog_loader
  participant bot

  cog_loader->>cog_loader: load_cogs_from_folder(folder_name="cogs")
  activate cog_loader
  cog_loader->>bot: Load cogs from cogs folder
  deactivate cog_loader

  cog_loader->>cog_loader: load_cogs_from_folder(folder_name="extensions")
  activate cog_loader
  cog_loader->>bot: Load cogs from extensions folder
  deactivate cog_loader
Loading

Updated class diagram for CogLoader

classDiagram
  class CogLoader {
    +load_cogs_from_folder(folder_name: str)
  }

  note for CogLoader "CogLoader now loads cogs from the extensions folder in addition to the cogs folder."
Loading

File-Level Changes

Change Details Files
Added an extensions system to load cogs from the tux/extensions folder.
  • Added a function to load cogs from the tux/extensions folder.
  • Modified the cog loader to load cogs from the tux/extensions folder after loading regular cogs.
tux/cog_loader.py
Updated the README to include the new extensions system.
  • Added a line to the README to mention the extensions system.
README.md
Added a README file for the extensions folder.
  • Created a README file in the tux/extensions folder to explain how to use the extensions system.
tux/extensions/README.md
Added the extensions folder to the .gitignore file.
  • Added the tux/extensions folder to the .gitignore file to prevent it from being committed to the repository.
.gitignore

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

@electron271 electron271 mentioned this pull request Apr 19, 2025
3 tasks
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 - here's some feedback:

Overall Comments:

  • Consider adding a check to ensure the 'extensions' folder exists before attempting to load cogs from it.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue 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.

@electron271 electron271 merged commit b731156 into main Apr 19, 2025
8 checks passed
@electron271 electron271 deleted the basic-extensions branch April 19, 2025 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: meta Relating to architecture, systems and critical functions priority: high type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant