From 01c701b7229cadd14ab7f06dcf35e81c6a3a7016 Mon Sep 17 00:00:00 2001 From: prithajnath Date: Sun, 25 Mar 2018 16:14:09 -0400 Subject: [PATCH 1/4] Add Zen of Python --- bot/cogs/resources/zen.json | 20 +++++++++++++++----- bot/cogs/snakes.py | 27 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/bot/cogs/resources/zen.json b/bot/cogs/resources/zen.json index ad2398c1..f573fe08 100644 --- a/bot/cogs/resources/zen.json +++ b/bot/cogs/resources/zen.json @@ -7,10 +7,8 @@ "Flat is better than nested.", "Sparse is better than dense.", "Readability counts.", - "Special cases aren't special enough to break the rules.", - "Although practicality beats purity.", - "Errors should never pass silently.", - "Unless explicitly silenced.", + "Special cases aren't special enough to break the rules. Although practicality beats purity.", + "Errors should never pass silently. Unless explicitly silenced.", "In the face of ambiguity, refuse the temptation to guess.", "There should be one-- and preferably only one --obvious way to do it.", "Although that way may not be obvious at first unless you're Dutch.", @@ -19,5 +17,17 @@ "If the implementation is hard to explain, it's a bad idea.", "If the implementation is easy to explain, it may be a good idea.", "Namespaces are one honking great idea -- let's do more of those!" + ], + + "gif":[ + "https://media.giphy.com/media/jCodV34MoczjW/giphy.gif", + "https://media.giphy.com/media/ZLF9Loju0q3MA/giphy.gif", + "https://media.giphy.com/media/v4NCChJtoH076/giphy.gif", + "https://media.giphy.com/media/3o6Ztfi66HECEU0Z4k/giphy.gif", + "https://media.giphy.com/media/HNSv7wrNUK5Ko/giphy.gif", + "https://media.giphy.com/media/3oFzmdjqH15YebLQ52/giphy.gif", + "https://media.giphy.com/media/2PIjvGv9DKtJ6/giphy.gif", + "https://media.giphy.com/media/26DN0U3SqKDG2fTFe/giphy.gif", + "https://media.giphy.com/media/3o6EhXODzc79cnZfRC/giphy.gif" ] -} \ No newline at end of file +} diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 92e4e307..4b210b4f 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -178,6 +178,33 @@ async def get(self, ctx: Context, name: str = None): # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! + @command(aliases=["t"]) + async def this(self, ctx: Context): + """ + Gets a random fact about snakes + :param ctx: Context object passed from discord.py + """ + + em = discord.Embed(color=0x399600) + with open('bot/cogs/resources/zen.json', 'r', encoding="utf8") as f: + data = json.load(f) + zen_quote = random.choice(data['zen']) + a = zen_quote.split() + b = ["..."*random.randint(1,3)+"..*hi"+"s"*random.randint(3,7)+"*"+"..."*random.randint(1,3) for _ in range(len(a))] + message = ''.join(list(map(lambda x:x[0]+x[1],list(zip(a,b))))) + + em.add_field( + name="The Zen of Python says...", + value=message, + inline=False + ) + + em.set_image(url=random.choice(data['gif'])) + await ctx.channel.send( + content=ctx.message.author.mention, + embed=em + ) + @command(aliases=["f"]) async def fact(self, ctx: Context): """ From f1b7a2cf759ac7b23ee146becacde164e4cd5392 Mon Sep 17 00:00:00 2001 From: prithajnath Date: Sun, 25 Mar 2018 16:38:26 -0400 Subject: [PATCH 2/4] Add alias for this --- bot/cogs/snakes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 4b210b4f..602a3975 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -178,7 +178,7 @@ async def get(self, ctx: Context, name: str = None): # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! - @command(aliases=["t"]) + @command(aliases=["t","zen"]) async def this(self, ctx: Context): """ Gets a random fact about snakes From ff361b8ad649d6028a424bbdec4a5c25f66bec73 Mon Sep 17 00:00:00 2001 From: prithajnath Date: Sun, 25 Mar 2018 16:40:31 -0400 Subject: [PATCH 3/4] Add descp for zen --- bot/cogs/snakes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 602a3975..396b8de7 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -181,7 +181,7 @@ async def get(self, ctx: Context, name: str = None): @command(aliases=["t","zen"]) async def this(self, ctx: Context): """ - Gets a random fact about snakes + Gets a random qoute from the Zen of Python. Inspired by the Python this module :param ctx: Context object passed from discord.py """ From e0d2bf20b974e565cfa3cded7fb9446a28d37123 Mon Sep 17 00:00:00 2001 From: Andrew Schwartz Date: Sun, 25 Mar 2018 16:04:43 -0600 Subject: [PATCH 4/4] lint, fix spelling --- bot/cogs/snakes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 396b8de7..8b3940ea 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -178,10 +178,10 @@ async def get(self, ctx: Context, name: str = None): # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! - @command(aliases=["t","zen"]) + @command(aliases=["t", "zen"]) async def this(self, ctx: Context): """ - Gets a random qoute from the Zen of Python. Inspired by the Python this module + Gets a random quote from the Zen of Python. Inspired by the Python this module :param ctx: Context object passed from discord.py """