-
-
Notifications
You must be signed in to change notification settings - Fork 40
refactor(eight_ball): update responses for clarity and humor #873
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
Conversation
Reviewer's GuideRefactors 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
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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
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 = [ |
There was a problem hiding this comment.
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])) |
There was a problem hiding this comment.
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.
| 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:
| 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:
| 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) |
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: