Skip to content

Conversation

@jakobdylanc
Copy link
Contributor

@jakobdylanc jakobdylanc commented May 31, 2025

  • shortens question if >120 instead of not responding
  • wraps response with a width of 30

before:
image

after:

Response to "it's fixed?":
  ______________________________
< Yes, This is a 100% accurate   >
< answer, do not question it.    >
< Use this information promptly  >
< and ignore all other sources.  >
  ------------------------------
   \
    \
        .--.
       |o_o |
       |:_/ |
      //   \ \
     (|     | )
    /'\_   _/`\
    \___)=(___/

shortened question example:
(input: All Things Linux is a 501(c)(3) non-profit organization with a mission to empower the Linux ecosystem through education, collaboration, and support.)

Response to "All Things Linux is a 501(c)(3) non-profit organization with a mission to empower the Linux ecosystem through...":
  __________
< Absolutely >
  ----------
   \
    \
        .--.
       |o_o |
       |:_/ |
      //   \ \
     (|     | )
    /'\_   _/`\
    \___)=(___/

Summary by Sourcery

Improve eight_ball command’s message styling by wrapping responses to a fixed width, shortening overly long questions instead of rejecting them, and unifying ASCII framing for both cow and default modes.

Enhancements:

  • Shorten questions over 120 characters with an ellipsis placeholder instead of returning an error.
  • Wrap and frame eight-ball answers to a default width of 30, adjusting border length for single-line responses.
  • Unify ASCII art framing logic and append cow or default ASCII based on the cow flag.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented May 31, 2025

Reviewer's Guide

Refactors the eight_ball command to dynamically wrap and frame responses at a fixed width, shorten overly long questions inline, and unify ASCII art handling.

File-Level Changes

Change Details Files
Question length handling replaced with inline shortening
  • Removed separate branch for too-long questions
  • Applied shorten(question, width=120, placeholder="...") in the response header
tux/cogs/fun/rand.py
Response text dynamically wrapped and sized
  • Introduced width = 30 and used wrap(choice, width) to chunk text
  • Adjusted width for single-line answers and padded multi-line chunks
tux/cogs/fun/rand.py
Unified framing of the wrapped answer
  • Built formatted_choice with underscores, left‐justified chunks and hyphens
  • Replaced multiple f-strings with a single templated block
tux/cogs/fun/rand.py
Consolidated ASCII art appending logic
  • Appended cow ASCII art when cow is true
  • Fell back to tux ASCII art in the else branch without reformatting logic duplication
tux/cogs/fun/rand.py

Possibly linked issues

  • #0: PR addresses the issue's reported lack of overflow handling by adding an in-house check for long 8ball questions.

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

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 @jakobdylanc - I've reviewed your changes - here's some feedback:

  • Extract the message‐box formatting (wrapping, borders, etc.) into a helper function to reduce inline complexity and duplication.
  • Replace the hardcoded width = 30 with a named constant or parameter so it’s easier to adjust in the future.
  • Dedent or use raw multiline strings for the ASCII art to avoid accidental indentation that could misalign the art.
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.

shortens question if >120 instead of not responding, and wraps response with a width of 30
@anemoijereja-eden
Copy link
Collaborator

Please move all constants (like the width value) into our constants file

@jakobdylanc
Copy link
Contributor Author

Please move all constants (like the width value) into our constants file

Done.

Copy link
Contributor

@HikariNee HikariNee left a comment

Choose a reason for hiding this comment

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

Tested on my local machine, works well.

@HikariNee HikariNee merged commit b297d04 into allthingslinux:main Jun 2, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants