Skip to content

Conversation

@Atmois
Copy link
Contributor

@Atmois Atmois commented Aug 22, 2024

Unfinished as going to add more fun facts.

Summary by Sourcery

Add a new command to the bot that delivers random fun facts about Linux, enhancing user engagement with interesting trivia.

New Features:

  • Introduce a new 'fun fact' command in the bot that provides users with random Linux-related fun facts.

@Atmois Atmois self-assigned this Aug 22, 2024
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Aug 22, 2024

Reviewer's Guide by Sourcery

This pull request adds a new 'fun fact' command to the bot, which provides users with random Linux-related trivia. The implementation includes a new Python file with a Fact class that inherits from commands.Cog, containing a list of Linux facts and a command to display a random fact using Discord embeds.

File-Level Changes

Change Details Files
Implement a new 'fun fact' command
  • Create a Fact class that inherits from commands.Cog
  • Initialize a list of Linux-related fun facts
  • Implement a hybrid command 'fact' with alias 'funfact'
  • Use EmbedCreator to create an info embed for displaying the fact
  • Set up an author field in the embed with a link to submit more facts
  • Implement the setup function to add the Fact cog to the bot
tux/cogs/fun/fact.py

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

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 @Atmois - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues 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 to tell me if it was helpful.

"Linux's 1.0 release was in March 1994.",
"Less than 1% of the latest kernel release includes code written by Linus Torvalds.",
"Linux is used by every major space programme in the world.",
"Approximatly 13.3% of the latest Linux kernel is made up of blank lines.",
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (typo): Correct the spelling of 'Approximately' in the fact.

Ensuring accuracy in the facts presented enhances the credibility and professionalism of the bot.

"95% of the Linux kernel is written in the C programming Language. Assembly language is the second most used language for Linux at 2.8%.",
"The first kernel version - Version 0.01 - contained about 10,000 lines of code.",
"96.3% of the top 1,000,000 web servers were reported to run on Linux.",
"In the early 2000's Steve Jobs - The then CEO of Apple - offered a job to Linux Torvalds which Torvalds declined.",
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (typo): Correct 'Linux Torvalds' to 'Linus Torvalds' and consider rephrasing for clarity.

This fact contains a typo in Linus Torvalds' name and could be rephrased for better readability. Consider: 'In the early 2000s, Steve Jobs, then CEO of Apple, offered a job to Linus Torvalds, which Torvalds declined.'

Suggested change
"In the early 2000's Steve Jobs - The then CEO of Apple - offered a job to Linux Torvalds which Torvalds declined.",
"In the early 2000s, Steve Jobs, then CEO of Apple, offered a job to Linus Torvalds, which Torvalds declined.",

@Atmois Atmois changed the title Add fun fact command [Unfinished] Add fun fact command Aug 22, 2024
@Atmois Atmois marked this pull request as draft August 22, 2024 16:29
@HikariNee
Copy link
Contributor

You can add this too.
https://news.ycombinator.com/item?id=8641073

@electron271 electron271 self-assigned this Aug 26, 2024
@electron271 electron271 marked this pull request as ready for review August 26, 2024 20:10
@electron271 electron271 marked this pull request as draft August 26, 2024 20:11
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 @Atmois - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider completing the feature before submitting the PR, or provide more details about the remaining work in the PR description.
  • To improve scalability and maintainability, consider moving the list of facts to a separate file or database.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues 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 to tell me if it was helpful.

@electron271
Copy link
Member

@Atmois is it fine if i can unmark as draft or should i wait until you add more facts

@Atmois
Copy link
Contributor Author

Atmois commented Aug 27, 2024

Go ahead

@Atmois Atmois changed the title [Unfinished] Add fun fact command Add fun fact command Aug 27, 2024
@electron271 electron271 marked this pull request as ready for review August 27, 2024 15:32
@electron271 electron271 merged commit b7719f4 into main Aug 27, 2024
@electron271 electron271 deleted the funfacts branch August 27, 2024 15:32
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 @Atmois - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider completing the feature before submitting a pull request, as indicated by the 'Unfinished' note in the description.
  • For better maintainability, consider moving the list of facts to a separate configuration file or database in the future, especially if you plan to add more facts.
Here's what I looked at during the review
  • 🟡 General issues: 4 issues 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 to tell me if it was helpful.

"96.3% of the top 1,000,000 web servers were reported to run on Linux.",
"In the early 2000s, Steve Jobs, who at the time was the CEO of Apple, offered a job to Linus Torvalds to work on OSX which Torvalds declined.",
"Linus Torvalds said that he would have never created Linux if FreeBSD had been available at the time.",
"Linux is used by every major space programme in the world including NASA, SpaceX, and the European Space Agency.",
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Remove redundant fact

This fact is a duplicate of the one on line 8. Consider removing one of these instances to avoid repetition.

Suggested change
"Linux is used by every major space programme in the world including NASA, SpaceX, and the European Space Agency.",
# Removed duplicate fact about space programs using Linux



class Fact(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
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): Optimize fact selection for better distribution

Consider shuffling the facts list in the __init__ method and selecting facts from the first 75% of the list in the fact method. This approach would provide a good balance between randomness and ensuring all facts are seen before repeats occur.

    def __init__(self, bot: commands.Bot) -> None:
        self.bot = bot
        self.facts = []
        self.load_and_shuffle_facts()

    def load_and_shuffle_facts(self) -> None:
        self.facts = [...]  # Load facts here
        random.shuffle(self.facts)
        self.fact_index = 0

name="fact",
aliases=["funfact"],
)
async def fact(self, ctx: commands.Context[commands.Bot]) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Improve or remove method comment

The current comment doesn't provide much additional information. Consider either removing it or expanding it to include more meaningful details about the method's behavior or purpose.

Suggested change
async def fact(self, ctx: commands.Context[commands.Bot]) -> None:
async def fact(self, ctx: commands.Context[commands.Bot]) -> None:
"""
Fetch and send a random fun fact to the user.
This command retrieves a fact from an external API or database
and posts it in the channel where the command was invoked.
"""

class Fact(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot
self.facts = [
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): Consider scalability for fact storage

If there are plans to significantly expand the fact list in the future, you might want to consider a more scalable solution for storing and retrieving facts, such as loading from a file or database.

        self.facts = self.load_facts_from_file('facts.json')

    def load_facts_from_file(self, filename):
        with open(filename, 'r') as file:
            return json.load(file)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get a random linux fun fact command

4 participants