From 8c779f8ccd59283746eaa217bc6592e00d7aa75e Mon Sep 17 00:00:00 2001 From: Atmois Date: Thu, 22 Aug 2024 17:25:49 +0100 Subject: [PATCH 1/4] Add fun fact command --- tux/cogs/fun/fact.py | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tux/cogs/fun/fact.py diff --git a/tux/cogs/fun/fact.py b/tux/cogs/fun/fact.py new file mode 100644 index 000000000..903c61b56 --- /dev/null +++ b/tux/cogs/fun/fact.py @@ -0,0 +1,49 @@ +import random + +from discord.ext import commands + +from tux.utils.embeds import EmbedCreator + + +class Fact(commands.Cog): + def __init__(self, bot: commands.Bot) -> None: + self.bot = bot + self.facts = [ + "The Linux kernel has over 36 million lines of code in its Git repository.", + "The vast majority of the world's supercomputers run on Linux.", + "Linux 1.0 was launched on September 17, 1991 featuring 176,250 lines of code.", + "There's an easter egg in `apt` if you enter `apt moo`.", + "Linus Torvalds was around 22 years old when he started work on the Linux Kernel in 1991. In the same year, he also released prototypes of the kernel publicly.", + "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.", + "Vim has various easter eggs. A notable one is found by typing :help 42 into the command bar.", + "Slackware is the oldest active linux distribution being released on the 17th July 1993.", + "Freax was the original planned name for Linux.", + "The first GUI that ran on Linux was X Window System. It ran on Linux Kernel version 0.95.", + "The Linux Kernel was the first OS kernel to support x86-64 in 2001.", + "Over 14,600 individual developers from over 1,300 different companies have contributed to the kernel.", + "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.", + ] + + @commands.hybrid_group( + name="fact", + aliases=["facts"], + usage="fact", + ) + async def fact(self, ctx: commands.Context[commands.Bot]) -> None: + embed = EmbedCreator.create_info_embed( + title="Fun Fact", + description=random.choice(self.facts), + ctx=ctx, + ) + + await ctx.send(embed=embed) + + +async def setup(bot: commands.Bot) -> None: + await bot.add_cog(Fact(bot)) From dc81d10d38d016d2de2af0a40324d0a00716049a Mon Sep 17 00:00:00 2001 From: Atmois Date: Thu, 22 Aug 2024 17:28:33 +0100 Subject: [PATCH 2/4] grammer fixes --- tux/cogs/fun/fact.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tux/cogs/fun/fact.py b/tux/cogs/fun/fact.py index 903c61b56..63b10048e 100644 --- a/tux/cogs/fun/fact.py +++ b/tux/cogs/fun/fact.py @@ -17,7 +17,7 @@ def __init__(self, bot: commands.Bot) -> None: "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.", + "Approximately 13.3% of the latest Linux kernel is made up of blank lines.", "Vim has various easter eggs. A notable one is found by typing :help 42 into the command bar.", "Slackware is the oldest active linux distribution being released on the 17th July 1993.", "Freax was the original planned name for Linux.", @@ -27,7 +27,7 @@ def __init__(self, bot: commands.Bot) -> None: "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.", + "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.", ] @commands.hybrid_group( From 2552bc0e91934844f0a04cdca9a6b157e8efb94b Mon Sep 17 00:00:00 2001 From: electron271 <66094410+electron271@users.noreply.github.com> Date: Mon, 26 Aug 2024 15:10:07 -0500 Subject: [PATCH 3/4] finish and fix fun facts command --- tux/cogs/fun/fact.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tux/cogs/fun/fact.py b/tux/cogs/fun/fact.py index 63b10048e..41207001d 100644 --- a/tux/cogs/fun/fact.py +++ b/tux/cogs/fun/fact.py @@ -28,20 +28,37 @@ def __init__(self, bot: commands.Bot) -> None: "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 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.", ] - @commands.hybrid_group( + @commands.hybrid_command( name="fact", - aliases=["facts"], + aliases=["funfact"], usage="fact", ) async def fact(self, ctx: commands.Context[commands.Bot]) -> None: + """ + Get a random fun fact. + + Parameters + ---------- + ctx : commands.Context[commands.Bot] + The context object for the command. + """ embed = EmbedCreator.create_info_embed( title="Fun Fact", description=random.choice(self.facts), ctx=ctx, ) + # set author + embed.set_author( + name="Submit more facts here!", + url="https://github.com/allthingslinux/tux/blob/main/tux/cogs/fun/fact.py", + icon_url="https://github.com/allthingslinux/tux/blob/main/assets/emojis/tux_info.png?raw=true", + ) + await ctx.send(embed=embed) From 2463358dea10b3085ee055b205fe5a129d78c54b Mon Sep 17 00:00:00 2001 From: electron271 <66094410+electron271@users.noreply.github.com> Date: Mon, 26 Aug 2024 15:14:43 -0500 Subject: [PATCH 4/4] sourcery suggestion --- tux/cogs/fun/fact.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tux/cogs/fun/fact.py b/tux/cogs/fun/fact.py index 41207001d..c38b1a6eb 100644 --- a/tux/cogs/fun/fact.py +++ b/tux/cogs/fun/fact.py @@ -35,7 +35,6 @@ def __init__(self, bot: commands.Bot) -> None: @commands.hybrid_command( name="fact", aliases=["funfact"], - usage="fact", ) async def fact(self, ctx: commands.Context[commands.Bot]) -> None: """