Skip to content

Conversation

@electron271
Copy link
Member

@electron271 electron271 commented May 19, 2025

makes responses less biased and more humorous

Summary by Sourcery

Refactor the Magic 8 Ball command to use distinct yes/no/unsure response categories and refresh its phrasing with new humorous and varied messages.

Enhancements:

  • Split the single response list into separate yes, no, and unsure response arrays
  • Replace classic eight-ball phrases with more comedic, edgy, and varied replies
  • Update selection logic to pick a response category before choosing a specific message

@electron271 electron271 self-assigned this May 19, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented May 19, 2025

Reviewer's Guide

Refactors the eight_ball cog by replacing the single combined responses list with three categorical arrays (yes, no, unsure), populates them with updated, humorous/unfiltered strings to reduce bias, and adjusts the random selection logic to pick first a category then an entry.

File-Level Changes

Change Details Files
Categorized response lists
  • Defined yes_responses, no_responses, unsure_responses
  • Removed the old unified responses list
tux/cogs/fun/rand.py
Updated and expanded response strings
  • Replaced standard affirmations/denials with more humorous, edgy entries
  • Added profanity-laced and pop-culture references for clarity/humor
tux/cogs/fun/rand.py
Refactored choice logic
  • Switched from single-list random.choice to nested random.choice(random.choice([...]))
tux/cogs/fun/rand.py

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

@electron271 electron271 merged commit 25d7608 into main May 19, 2025
9 of 10 checks passed
@electron271 electron271 deleted the 8ball-revamp branch May 19, 2025 19:36
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:

  • The nested random.choice(random.choice([...])) is a bit obscure—consider first selecting a category (yes/no/unsure) and then picking a response for clearer intent.
  • The long comma-separated string in unsure_responses ("Probably, Maybe, Possibly…") is treated as one response—split it into individual entries for better variety.
  • A few of the added responses use strong profanity and might not suit all audiences—consider toning down or standardizing the humor level.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 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.

"Very doubtful",
"Why the hell are you asking me lmao",
"What???",
yes_responses = [
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (performance): Recreating response lists on every call

Extract these lists to module-level constants to avoid rebuilding them on every call and improve readability.

]

choice = random.choice(responses)
choice = random.choice(random.choice([yes_responses, no_responses, unsure_responses]))
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (complexity): Consider separating category selection and response selection into two steps for clarity, or flattening the lists if category distinction is unnecessary.

Suggested change
choice = random.choice(random.choice([yes_responses, no_responses, unsure_responses]))
# Instead of splitting into three separate lists and doing
# choice = random.choice(random.choice([yes_responses, no_responses, unsure_responses]))
# you can:
# 1) keep your three lists (if you need them for other logic)
# 2) pick a category in one step, then an element in another.
#
# This is clearer, avoids the hidden double‐call, and is functionally identical:
categories = [yes_responses, no_responses, unsure_responses]
category = random.choice(categories)
choice = random.choice(category)

If you don’t actually need to treat yes/no/unsure differently later, you can collapse back to a single list:

Suggested change
choice = random.choice(random.choice([yes_responses, no_responses, unsure_responses]))
# Flatten all responses and pick once:
all_responses = [
*yes_responses,
*no_responses,
*unsure_responses,
]
choice = random.choice(all_responses)

Or, if you wanted a weighted pick across categories:

Suggested change
choice = random.choice(random.choice([yes_responses, no_responses, unsure_responses]))
# Use random.choices to weight categories explicitly
categories = [yes_responses, no_responses, unsure_responses]
# e.g. equal 1/3 chance per category:
weights = [1, 1, 1]
category = random.choices(categories, weights=weights, k=1)[0]
choice = random.choice(category)

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.

2 participants