2019-10-04 20:19:31 -04:00
|
|
|
"""
|
2019-12-07 17:26:55 -05:00
|
|
|
Fun extension for qrm
|
2019-10-04 20:19:31 -04:00
|
|
|
---
|
2020-01-06 23:27:48 -05:00
|
|
|
Copyright (C) 2019-2020 Abigail Gold, 0x5c
|
2019-10-04 20:19:31 -04:00
|
|
|
|
2020-02-15 06:27:48 -05:00
|
|
|
This file is part of qrm2 and is released under the terms of
|
2020-01-31 06:50:50 -05:00
|
|
|
the GNU General Public License, version 2.
|
2019-10-04 20:19:31 -04:00
|
|
|
"""
|
|
|
|
|
2020-01-31 06:50:50 -05:00
|
|
|
|
2019-12-25 00:42:54 -05:00
|
|
|
import random
|
|
|
|
|
2019-10-04 20:19:31 -04:00
|
|
|
import discord.ext.commands as commands
|
|
|
|
|
2019-12-06 01:19:42 -05:00
|
|
|
import common as cmn
|
|
|
|
|
2019-10-04 20:19:31 -04:00
|
|
|
|
|
|
|
class FunCog(commands.Cog):
|
2019-10-18 08:27:05 -04:00
|
|
|
def __init__(self, bot: commands.Bot):
|
2019-10-04 20:19:31 -04:00
|
|
|
self.bot = bot
|
2020-01-30 06:15:42 -05:00
|
|
|
with open("resources/words") as words_file:
|
2019-12-25 00:42:54 -05:00
|
|
|
self.words = words_file.read().lower().splitlines()
|
2019-10-04 20:19:31 -04:00
|
|
|
|
2020-01-30 06:15:42 -05:00
|
|
|
@commands.command(name="xkcd", aliases=["x"], category=cmn.cat.fun)
|
2019-12-06 01:19:42 -05:00
|
|
|
async def _xkcd(self, ctx: commands.Context, number: str):
|
2020-02-15 04:59:25 -05:00
|
|
|
"""Looks up an xkcd comic by number."""
|
2020-01-30 06:15:42 -05:00
|
|
|
await ctx.send("http://xkcd.com/" + number)
|
2019-10-04 20:19:31 -04:00
|
|
|
|
2019-12-06 01:19:42 -05:00
|
|
|
@commands.command(name="tar", category=cmn.cat.fun)
|
2019-10-18 08:27:05 -04:00
|
|
|
async def _tar(self, ctx: commands.Context):
|
2020-02-15 04:59:25 -05:00
|
|
|
"""Returns xkcd: tar."""
|
2020-01-30 06:15:42 -05:00
|
|
|
await ctx.send("http://xkcd.com/1168")
|
2019-10-04 20:19:31 -04:00
|
|
|
|
2019-12-06 01:19:42 -05:00
|
|
|
@commands.command(name="xd", hidden=True, category=cmn.cat.fun)
|
2019-10-18 08:27:05 -04:00
|
|
|
async def _xd(self, ctx: commands.Context):
|
2020-01-30 06:15:42 -05:00
|
|
|
"""ecks dee"""
|
|
|
|
await ctx.send("ECKS DEE :smirk:")
|
2019-10-04 20:19:31 -04:00
|
|
|
|
2020-01-30 06:15:42 -05:00
|
|
|
@commands.command(name="funetics", aliases=["fun"], category=cmn.cat.fun)
|
2019-12-25 00:42:54 -05:00
|
|
|
async def _funetics_lookup(self, ctx: commands.Context, *, msg: str):
|
2020-02-15 04:59:25 -05:00
|
|
|
"""Generates fun/wacky phonetics for a word or phrase."""
|
2019-12-25 00:42:54 -05:00
|
|
|
with ctx.typing():
|
2020-01-30 06:15:42 -05:00
|
|
|
result = ""
|
2019-12-25 00:42:54 -05:00
|
|
|
for char in msg.lower():
|
|
|
|
if char.isalpha():
|
|
|
|
result += random.choice([word for word in self.words if word[0] == char])
|
|
|
|
else:
|
|
|
|
result += char
|
2020-01-30 06:15:42 -05:00
|
|
|
result += " "
|
2019-12-25 00:42:54 -05:00
|
|
|
embed = cmn.embed_factory(ctx)
|
2020-01-30 06:15:42 -05:00
|
|
|
embed.title = f"Funetics for {msg}"
|
2019-12-25 00:42:54 -05:00
|
|
|
embed.description = result.title()
|
|
|
|
embed.colour = cmn.colours.good
|
|
|
|
await ctx.send(embed=embed)
|
|
|
|
|
2019-10-04 20:19:31 -04:00
|
|
|
|
2019-10-18 08:27:05 -04:00
|
|
|
def setup(bot: commands.Bot):
|
2019-10-04 20:19:31 -04:00
|
|
|
bot.add_cog(FunCog(bot))
|