feat(wiki): Add subcommand to search wikipedia
Add subcommand to search wikipedia
Summary by Sourcery
Add support for searching Wikipedia from the wiki command by adding a new 'wikipedia' subcommand, configuring its API endpoint, and extending URL generation for Wikipedia results.
New Features:
- Add 'wikipedia' subcommand (alias 'wp') to the wiki cog for searching Wikipedia
Enhancements:
- Introduce wikipedia_api_url and set up usage for the new subcommand
- Update query_wiki to construct Wikipedia article URLs when using the Wikipedia API
Reviewer's Guide
This PR extends the existing wiki cog by integrating a new Wikipedia subcommand: it registers the Wikipedia API URL, updates URL routing logic to support Wikipedia articles, and adds the wikipedia (alias wp) command that queries and renders Wikipedia pages in embeds.
Sequence diagram for the new Wikipedia subcommand flow
sequenceDiagram
actor User
participant Bot
participant WikiCog
User->>Bot: !wiki wikipedia <query>
Bot->>WikiCog: wikipedia(ctx, query)
WikiCog->>WikiCog: query_wiki(wikipedia_api_url, query)
WikiCog->>WikiCog: create_embed(title, ctx)
WikiCog->>Bot: send(embed)
Bot->>User: Display Wikipedia result embed
Class diagram for updated Wiki cog with Wikipedia support
classDiagram
class Wiki {
- bot: Tux
- arch_wiki_api_url: str
- atl_wiki_api_url: str
- wikipedia_api_url: str
+ __init__(bot: Tux)
+ create_embed(title: tuple[str, str], ctx: commands.Context[Tux]) : discord.Embed
+ query_wiki(base_url: str, search_term: str) : tuple[str, str]
+ arch_wiki(ctx: commands.Context[Tux], query: str)
+ atl_wiki(ctx: commands.Context[Tux], query: str)
+ wikipedia(ctx: commands.Context[Tux], query: str) <<added>>
}
Wiki : +wikipedia_api_url <<added>>
Wiki : +wikipedia(ctx, query) <<added>>
File-Level Changes
| Change | Details | Files |
|---|---|---|
| Initialize Wikipedia integration in constructor |
|
tux/cogs/utility/wiki.py |
| Handle Wikipedia URLs in query_wiki logic |
|
tux/cogs/utility/wiki.py |
Implement wikipedia subcommand |
|
tux/cogs/utility/wiki.py |
Possibly linked issues
- #0: The PR adds a Wikipedia subcommand, directly implementing the issue's suggestion for wiki command additions.
Tips and commands
Interacting with Sourcery
-
Trigger a new review: Comment
@sourcery-ai reviewon 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 issueto create an issue from it. -
Generate a pull request title: Write
@sourcery-aianywhere in the pull request title to generate a title at any time. You can also comment@sourcery-ai titleon the pull request to (re-)generate the title at any time. -
Generate a pull request summary: Write
@sourcery-ai summaryanywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment@sourcery-ai summaryon the pull request to (re-)generate the summary at any time. -
Generate reviewer's guide: Comment
@sourcery-ai guideon the pull request to (re-)generate the reviewer's guide at any time. -
Resolve all Sourcery comments: Comment
@sourcery-ai resolveon 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 dismisson 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 reviewto 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
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
Dependency Review
✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned Files
None
Codecov Report
Attention: Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
Project coverage is 9.29%. Comparing base (
3e4f69e) to head (97c3f9d). Report is 2 commits behind head on main.
:white_check_mark: All tests successful. No failed tests found.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| tux/cogs/utility/wiki.py | 0.00% | 9 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #975 +/- ##
========================================
+ Coverage 9.26% 9.29% +0.03%
========================================
Files 123 123
Lines 10390 10399 +9
Branches 1276 1277 +1
========================================
+ Hits 963 967 +4
- Misses 9325 9328 +3
- Partials 102 104 +2
| Flag | Coverage Δ | *Carryforward flag | |
|---|---|---|---|
| database | 0.31% <ø> (ø) |
Carriedforward from 3e4f69e | |
| integration | 5.85% <0.00%> (-0.01%) |
:arrow_down: | |
| unit | 6.30% <0.00%> (-0.01%) |
:arrow_down: |
*This pull request uses carry forward flags. Click here to find out more.
| Components | Coverage Δ | |
|---|---|---|
| Core Bot Infrastructure | 16.45% <ø> (ø) |
|
| Database Layer | 0.00% <ø> (ø) |
|
| Bot Commands & Features | 0.00% <0.00%> (ø) |
|
| Event & Error Handling | ∅ <ø> (∅) |
|
| Utilities & Helpers | ∅ <ø> (∅) |
|
| User Interface Components | 0.00% <ø> (ø) |
|
| CLI Interface | ∅ <ø> (∅) |
|
| External Service Wrappers | ∅ <ø> (∅) |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Deploying tux with
Cloudflare Pages
| Latest commit: |
97c3f9d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9817e2a3.tux-afh.pages.dev |
| Branch Preview URL: | https://wikicmd.tux-afh.pages.dev |