diff options
Diffstat (limited to 'bot')
| -rw-r--r-- | bot/constants.py | 2 | ||||
| -rw-r--r-- | bot/resources/halloween/responses.json | 14 | ||||
| -rw-r--r-- | bot/seasons/christmas/adventofcode.py | 2 | ||||
| -rw-r--r-- | bot/seasons/easter/avatar_easterifier.py | 3 | ||||
| -rw-r--r-- | bot/seasons/evergreen/showprojects.py | 35 | ||||
| -rw-r--r-- | bot/seasons/evergreen/snakes/snakes_cog.py | 9 | ||||
| -rw-r--r-- | bot/seasons/evergreen/snakes/utils.py | 11 | ||||
| -rw-r--r-- | bot/seasons/halloween/8ball.py | 35 | ||||
| -rw-r--r-- | bot/seasons/halloween/spookyavatar.py | 5 | ||||
| -rw-r--r-- | bot/seasons/season.py | 2 | ||||
| -rw-r--r-- | bot/seasons/valentines/be_my_valentine.py | 2 | 
11 files changed, 98 insertions, 22 deletions
| diff --git a/bot/constants.py b/bot/constants.py index bf542daf..67dd9328 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -49,6 +49,8 @@ class Channels(NamedTuple):      staff_lounge = 464905259261755392      verification = 352442727016693763      python_discussion = 267624335836053506 +    show_your_projects = 303934982764625920 +    show_your_projects_discussion = 360148304664723466  class Client(NamedTuple): diff --git a/bot/resources/halloween/responses.json b/bot/resources/halloween/responses.json new file mode 100644 index 00000000..c0f24c1a --- /dev/null +++ b/bot/resources/halloween/responses.json @@ -0,0 +1,14 @@ +{ +  "responses": [ +    ["No."], +    ["Yes."], +    ["I will seek and answer from the devil...", "...after requesting the devils knowledge the answer is far more complicated than a simple yes or no."], +    ["This knowledge is not available to me, I will seek the answers from someone far more powerful...", "...there is no answer to this question, not even the Grim Reaper could find an answer."], +    ["The ghosts I summoned have confirmed that is is certain."], +    ["Double, double, toil and trouble,\nFire burn and cauldron bubble.\nCool it with a baboon's blood,\nand tell me the answer to his question...", "...the great cauldron can only confirm your beliefs."], +    ["Double, double, toil and trouble,\nFire burn and cauldron bubble.\nCool it with a baboon's blood,\nand tell me the answer to his question...", "...the great cauldron can only confirm that the answer to your question is no."], +    ["If I tell you I will have to kill you..."], +    ["I swear on my spider that you are correct."], +    ["With great certainty, under the watch of the Pumpkin King, I can confirm your suspicions."], +    ["The undead have sworn me to secrecy. I can not answer your question."] +]} diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py index 32858673..440484b4 100644 --- a/bot/seasons/christmas/adventofcode.py +++ b/bot/seasons/christmas/adventofcode.py @@ -132,7 +132,7 @@ class AdventOfCode(commands.Cog):      async def adventofcode_group(self, ctx: commands.Context):          """All of the Advent of Code commands.""" -        await ctx.invoke(self.bot.get_command("help"), "adventofcode") +        await ctx.send_help(ctx.command)      @adventofcode_group.command(          name="subscribe", diff --git a/bot/seasons/easter/avatar_easterifier.py b/bot/seasons/easter/avatar_easterifier.py index 9f7ea271..a84e5eb4 100644 --- a/bot/seasons/easter/avatar_easterifier.py +++ b/bot/seasons/easter/avatar_easterifier.py @@ -71,8 +71,7 @@ class AvatarEasterifier(commands.Cog):          async with ctx.typing():              # Grabs image of avatar -            async with self.bot.http_session.get(ctx.author.avatar_url_as(size=256)) as resp: -                image_bytes = await resp.read() +            image_bytes = await ctx.author.avatar_url_as(size=256).read()              old = Image.open(BytesIO(image_bytes))              old = old.convert("RGBA") diff --git a/bot/seasons/evergreen/showprojects.py b/bot/seasons/evergreen/showprojects.py new file mode 100644 index 00000000..d6223690 --- /dev/null +++ b/bot/seasons/evergreen/showprojects.py @@ -0,0 +1,35 @@ +import logging + +from discord.ext import commands + +from bot.constants import Channels + +log = logging.getLogger(__name__) + + +class ShowProjects(commands.Cog): +    """Cog that reacts to posts in the #show-your-projects""" + +    def __init__(self, bot): +        self.bot = bot +        self.lastPoster = 0  # Given 0 as the default last poster ID as no user can actually have 0 assigned to them + +    @commands.Cog.listener() +    async def on_message(self, message): +        """Adds reactions to posts in #show-your-projects""" + +        reactions = ["\U0001f44d", "\U00002764", "\U0001f440", "\U0001f389", "\U0001f680", "\U00002b50", "\U0001f6a9"] +        if (message.channel.id == Channels.show_your_projects +                and message.author.bot is False +                and message.author.id != self.lastPoster): +            for reaction in reactions: +                await message.add_reaction(reaction) + +        self.lastPoster = message.author.id + + +def setup(bot): +    """Show Projects Reaction Cog""" + +    bot.add_cog(ShowProjects(bot)) +    log.info("ShowProjects cog loaded") diff --git a/bot/seasons/evergreen/snakes/snakes_cog.py b/bot/seasons/evergreen/snakes/snakes_cog.py index 3ffdf1bf..b5fb2881 100644 --- a/bot/seasons/evergreen/snakes/snakes_cog.py +++ b/bot/seasons/evergreen/snakes/snakes_cog.py @@ -458,7 +458,7 @@ class Snakes(Cog):      async def snakes_group(self, ctx: Context):          """Commands from our first code jam.""" -        await ctx.invoke(self.bot.get_command("help"), "snake") +        await ctx.send_help(ctx.command)      @bot_has_permissions(manage_messages=True)      @snakes_group.command(name='antidote') @@ -1055,13 +1055,6 @@ class Snakes(Cog):          )          await ctx.channel.send(embed=embed) -    @snakes_group.command(name='help') -    async def help_command(self, ctx: Context): -        """Invokes the help command for the Snakes Cog.""" - -        log.debug(f"{ctx.author} requested info about the snakes cog") -        return await ctx.invoke(self.bot.get_command("help"), "Snakes") -      @snakes_group.command(name='snakify')      async def snakify_command(self, ctx: Context, *, message: str = None):          """ diff --git a/bot/seasons/evergreen/snakes/utils.py b/bot/seasons/evergreen/snakes/utils.py index e2ed60bd..a7cb70a7 100644 --- a/bot/seasons/evergreen/snakes/utils.py +++ b/bot/seasons/evergreen/snakes/utils.py @@ -8,7 +8,6 @@ from itertools import product  from pathlib import Path  from typing import List, Tuple -import aiohttp  from PIL import Image  from PIL.ImageDraw import ImageDraw  from discord import File, Member, Reaction @@ -480,12 +479,10 @@ class SnakeAndLaddersGame:      async def _add_player(self, user: Member):          self.players.append(user)          self.player_tiles[user.id] = 1 -        avatar_url = user.avatar_url_as(format='jpeg', size=PLAYER_ICON_IMAGE_SIZE) -        async with aiohttp.ClientSession() as session: -            async with session.get(avatar_url) as res: -                avatar_bytes = await res.read() -                im = Image.open(io.BytesIO(avatar_bytes)).resize((BOARD_PLAYER_SIZE, BOARD_PLAYER_SIZE)) -                self.avatar_images[user.id] = im + +        avatar_bytes = await user.avatar_url_as(format='jpeg', size=PLAYER_ICON_IMAGE_SIZE).read() +        im = Image.open(io.BytesIO(avatar_bytes)).resize((BOARD_PLAYER_SIZE, BOARD_PLAYER_SIZE)) +        self.avatar_images[user.id] = im      async def player_join(self, user: Member):          """ diff --git a/bot/seasons/halloween/8ball.py b/bot/seasons/halloween/8ball.py new file mode 100644 index 00000000..af037e53 --- /dev/null +++ b/bot/seasons/halloween/8ball.py @@ -0,0 +1,35 @@ +import asyncio +import json +import logging +import random +from pathlib import Path + +from discord.ext import commands + +log = logging.getLogger(__name__) + +with open(Path('bot', 'resources', 'halloween', 'responses.json'), 'r', encoding="utf8") as f: +    responses = json.load(f) + + +class SpookyEightBall(commands.Cog): +    """Spooky Eightball answers.""" + +    def __init__(self, bot): +        self.bot = bot + +    @commands.command(aliases=('spooky8ball',)) +    async def spookyeightball(self, ctx, *, question: str): +        """Responds with a random response to a question.""" +        choice = random.choice(responses['responses']) +        msg = await ctx.send(choice[0]) +        if len(choice) > 1: +            await asyncio.sleep(random.randint(2, 5)) +            await msg.edit(content=f"{choice[0]} \n{choice[1]}") + + +def setup(bot): +    """Spooky Eight Ball Cog Load.""" + +    bot.add_cog(SpookyEightBall(bot)) +    log.info("SpookyEightBall cog loaded") diff --git a/bot/seasons/halloween/spookyavatar.py b/bot/seasons/halloween/spookyavatar.py index 15c7c431..2cc81da8 100644 --- a/bot/seasons/halloween/spookyavatar.py +++ b/bot/seasons/halloween/spookyavatar.py @@ -37,8 +37,9 @@ class SpookyAvatar(commands.Cog):              embed = discord.Embed(colour=0xFF0000)              embed.title = "Is this you or am I just really paranoid?"              embed.set_author(name=str(user.name), icon_url=user.avatar_url) -            resp = await self.get(user.avatar_url) -            im = Image.open(BytesIO(resp)) + +            image_bytes = await ctx.author.avatar_url.read() +            im = Image.open(BytesIO(image_bytes))              modified_im = spookifications.get_random_effect(im)              modified_im.save(str(ctx.message.id)+'.png')              f = discord.File(str(ctx.message.id)+'.png') diff --git a/bot/seasons/season.py b/bot/seasons/season.py index 6d992276..6d99b77f 100644 --- a/bot/seasons/season.py +++ b/bot/seasons/season.py @@ -442,7 +442,7 @@ class SeasonManager(commands.Cog):      async def refresh(self, ctx):          """Refreshes certain seasonal elements without reloading seasons."""          if not ctx.invoked_subcommand: -            await ctx.invoke(bot.get_command("help"), "refresh") +            await ctx.send_help(ctx.command)      @refresh.command(name="avatar")      async def refresh_avatar(self, ctx): diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index 19788577..8340d7fa 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -42,7 +42,7 @@ class BeMyValentine(commands.Cog):          2) use the command \".lovefest unsub\" to get rid of the lovefest role.          """ -        await ctx.invoke(self.bot.get_command("help"), "lovefest") +        await ctx.send_help(ctx.command)      @lovefest_role.command(name="sub")      async def add_role(self, ctx): | 
