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
|
|
|
---
|
2021-03-18 09:17:30 -04:00
|
|
|
Copyright (C) 2019-2021 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
|
|
|
|
2021-03-18 09:17:30 -04:00
|
|
|
import json
|
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
|
|
|
|
|
2021-03-18 09:17:30 -04:00
|
|
|
import data.options as opt
|
|
|
|
|
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
|
2021-03-18 09:17:30 -04:00
|
|
|
with open(cmn.paths.resources / "imgs.1.json") as file:
|
|
|
|
self.imgs: dict = json.load(file)
|
|
|
|
with open(cmn.paths.resources / "words.1.txt") 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
|
|
|
|
2021-03-28 02:38:36 -04:00
|
|
|
@commands.command(name="xkcd", aliases=["x"], category=cmn.Cats.FUN)
|
2021-03-26 08:04:54 -04:00
|
|
|
async def _xkcd(self, ctx: commands.Context, number: int):
|
2020-02-15 04:59:25 -05:00
|
|
|
"""Looks up an xkcd comic by number."""
|
2021-03-26 08:04:54 -04:00
|
|
|
await ctx.send("http://xkcd.com/" + str(number))
|
2019-10-04 20:19:31 -04:00
|
|
|
|
2021-03-28 02:38:36 -04:00
|
|
|
@commands.command(name="tar", category=cmn.Cats.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
|
|
|
|
2021-03-28 02:38:36 -04:00
|
|
|
@commands.command(name="standards", category=cmn.Cats.FUN)
|
2020-03-30 18:24:50 -04:00
|
|
|
async def _standards(self, ctx: commands.Context):
|
|
|
|
"""Returns xkcd: Standards."""
|
|
|
|
await ctx.send("http://xkcd.com/927")
|
|
|
|
|
2021-03-28 02:38:36 -04:00
|
|
|
@commands.command(name="worksplit", aliases=["split", "ft8"], category=cmn.Cats.FUN)
|
2020-09-27 16:07:21 -04:00
|
|
|
async def _worksplit(self, ctx: commands.Context):
|
|
|
|
"""Posts "Work split you lids"."""
|
|
|
|
embed = cmn.embed_factory(ctx)
|
|
|
|
embed.title = "Work Split, You Lids!"
|
2021-03-18 09:17:30 -04:00
|
|
|
embed.set_image(url=opt.resources_url + self.imgs["worksplit"])
|
|
|
|
await ctx.send(embed=embed)
|
2020-09-27 16:07:21 -04:00
|
|
|
|
2021-03-28 02:38:36 -04:00
|
|
|
@commands.command(name="xd", hidden=True, category=cmn.Cats.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
|
|
|
|
2021-03-28 02:38:36 -04:00
|
|
|
@commands.command(name="funetics", aliases=["fun"], category=cmn.Cats.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."""
|
2020-02-25 20:36:21 -05:00
|
|
|
result = ""
|
|
|
|
for char in msg.lower():
|
|
|
|
if char.isalpha():
|
|
|
|
result += random.choice([word for word in self.words if word[0] == char])
|
|
|
|
else:
|
|
|
|
result += char
|
|
|
|
result += " "
|
|
|
|
embed = cmn.embed_factory(ctx)
|
|
|
|
embed.title = f"Funetics for {msg}"
|
|
|
|
embed.description = result.title()
|
|
|
|
embed.colour = cmn.colours.good
|
2019-12-25 00:42:54 -05:00
|
|
|
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))
|