Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions bot/cogs/resources/zen.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand All @@ -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"
]
}
}
27 changes: 27 additions & 0 deletions bot/cogs/snakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "zen"])
async def this(self, ctx: Context):
"""
Gets a random quote from the Zen of Python. Inspired by the Python this module
: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):
"""
Expand Down