From 262f3a8df49fc7bbf8b76956e981a00a38bd65d6 Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Tue, 9 Apr 2019 13:26:58 +0100 Subject: Created the spooky8ball command and the corresponding .json responses file. --- bot/resources/halloween/responses.json | 14 ++++++++++++ bot/seasons/halloween/8ball.py | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 bot/resources/halloween/responses.json create mode 100644 bot/seasons/halloween/8ball.py (limited to 'bot') diff --git a/bot/resources/halloween/responses.json b/bot/resources/halloween/responses.json new file mode 100644 index 00000000..99c64750 --- /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 to locate 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 word...", "...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 word...", "...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 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/halloween/8ball.py b/bot/seasons/halloween/8ball.py new file mode 100644 index 00000000..6f89375e --- /dev/null +++ b/bot/seasons/halloween/8ball.py @@ -0,0 +1,39 @@ +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 EightBall(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) + if len(choice) == 1: + await ctx.send(choice[0]) + else: + for x in choice: + await ctx.send(x) + asyncio.sleep(random.randint(2, 5)) + await ctx.send(x) + + +def setup(bot): + """Conversation starters Cog load.""" + + bot.add_cog(EightBall(bot)) + log.info("8Ball cog loaded") -- cgit v1.2.3 From 9118e595c3511ea0c23166329af1491fac35e23b Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Wed, 10 Apr 2019 11:57:32 +0100 Subject: Change a string to a tuple. --- bot/seasons/halloween/8ball.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/halloween/8ball.py b/bot/seasons/halloween/8ball.py index 6f89375e..485112bd 100644 --- a/bot/seasons/halloween/8ball.py +++ b/bot/seasons/halloween/8ball.py @@ -18,7 +18,7 @@ class EightBall(commands.Cog): def __init__(self, bot): self.bot = bot - @commands.command(aliases=('spooky8ball')) + @commands.command(aliases=('spooky8ball',)) async def spookyeightball(self, ctx, question: str): """Responds with a random response to a question.""" -- cgit v1.2.3 From 958adba6a80397d505b939b82b2a31f752ac42d3 Mon Sep 17 00:00:00 2001 From: Olson J Date: Wed, 10 Apr 2019 09:43:22 -0400 Subject: updated responses.json Change a few wording, as they were minor, linguistically speaking. --- bot/resources/halloween/responses.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bot') diff --git a/bot/resources/halloween/responses.json b/bot/resources/halloween/responses.json index 99c64750..c0f24c1a 100644 --- a/bot/resources/halloween/responses.json +++ b/bot/resources/halloween/responses.json @@ -3,12 +3,12 @@ ["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 to locate an answer."], + ["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 word...", "...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 word...", "...the great cauldron can only confirm that the answer to your question is no."], + ["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 certainty, under the watch of the Pumpkin King, I can confirm your suspicions."], + ["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."] ]} -- cgit v1.2.3 From acc8ce5f9a2dbc5b4470fa54abf28220220e1d82 Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Wed, 10 Apr 2019 16:19:31 +0100 Subject: Updated the docstring --- bot/seasons/halloween/8ball.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/halloween/8ball.py b/bot/seasons/halloween/8ball.py index 485112bd..750b489f 100644 --- a/bot/seasons/halloween/8ball.py +++ b/bot/seasons/halloween/8ball.py @@ -13,7 +13,7 @@ with open(Path('bot', 'resources', 'halloween', 'responses.json'), 'r', encoding class EightBall(commands.Cog): - """Spooky Eightball answers.""" + """Spooky Eightball - upon use of the command the user receives a randomised response to their question!""" def __init__(self, bot): self.bot = bot -- cgit v1.2.3 From 225ff72c0c37035122b017c9af2dd71dd4d7f115 Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Sat, 11 May 2019 12:23:33 +0100 Subject: Added embed to stop double message confusion and fixed sleep to asyncio.sleep() --- bot/seasons/halloween/8ball.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'bot') diff --git a/bot/seasons/halloween/8ball.py b/bot/seasons/halloween/8ball.py index 750b489f..de30fa78 100644 --- a/bot/seasons/halloween/8ball.py +++ b/bot/seasons/halloween/8ball.py @@ -1,4 +1,5 @@ import asyncio +import discord import json import logging import random @@ -13,27 +14,29 @@ with open(Path('bot', 'resources', 'halloween', 'responses.json'), 'r', encoding class EightBall(commands.Cog): - """Spooky Eightball - upon use of the command the user receives a randomised response to their question!""" + """Spooky Eightball answers.""" def __init__(self, bot): self.bot = bot @commands.command(aliases=('spooky8ball',)) - async def spookyeightball(self, ctx, question: str): + async def spookyeightball(self, ctx, *, question: str): """Responds with a random response to a question.""" - - choice = random.choice(responses) + choice = random.choice(responses['responses']) if len(choice) == 1: await ctx.send(choice[0]) else: - for x in choice: - await ctx.send(x) - asyncio.sleep(random.randint(2, 5)) - await ctx.send(x) + emb = discord.Embed(colour=0x00f2ff) + emb.add_field(name=f'Question from {ctx.author.name}', value=question) + emb.add_field(name='Answer', value=choice[0]) + msg = await ctx.send(embed=emb) + await asyncio.sleep(random.randint(2, 5)) + emb.set_field_at(1, name='Answer', value=f'{choice[0]} \n {choice[1]}') + await msg.edit(embed=emb) def setup(bot): - """Conversation starters Cog load.""" + """Spooky Eight Ball Cog Load.""" bot.add_cog(EightBall(bot)) log.info("8Ball cog loaded") -- cgit v1.2.3 From fb3a0fd2dbb12d614d2eb2c929948b3260f4ab11 Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Sat, 11 May 2019 12:30:35 +0100 Subject: Lint issues - fixed import orders --- bot/seasons/halloween/8ball.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/halloween/8ball.py b/bot/seasons/halloween/8ball.py index de30fa78..b5be7cc6 100644 --- a/bot/seasons/halloween/8ball.py +++ b/bot/seasons/halloween/8ball.py @@ -1,10 +1,10 @@ import asyncio -import discord import json import logging import random from pathlib import Path +import discord from discord.ext import commands log = logging.getLogger(__name__) -- cgit v1.2.3 From 31af0606ee094aa97d3bed3a4e4b2d379d9cbd6e Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Sat, 11 May 2019 19:25:32 +0100 Subject: Update bot/seasons/halloween/8ball.py Co-Authored-By: S. Co1 --- bot/seasons/halloween/8ball.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/halloween/8ball.py b/bot/seasons/halloween/8ball.py index b5be7cc6..8dff454f 100644 --- a/bot/seasons/halloween/8ball.py +++ b/bot/seasons/halloween/8ball.py @@ -13,7 +13,7 @@ with open(Path('bot', 'resources', 'halloween', 'responses.json'), 'r', encoding responses = json.load(f) -class EightBall(commands.Cog): +class SpookyEightBall(commands.Cog): """Spooky Eightball answers.""" def __init__(self, bot): -- cgit v1.2.3 From 07e7a8f133c55c356554aea03fe8b9ba12e90407 Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Sat, 11 May 2019 19:26:26 +0100 Subject: Update bot/seasons/halloween/8ball.py Co-Authored-By: S. Co1 --- bot/seasons/halloween/8ball.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/halloween/8ball.py b/bot/seasons/halloween/8ball.py index 8dff454f..c2f560a7 100644 --- a/bot/seasons/halloween/8ball.py +++ b/bot/seasons/halloween/8ball.py @@ -38,5 +38,5 @@ class SpookyEightBall(commands.Cog): def setup(bot): """Spooky Eight Ball Cog Load.""" - bot.add_cog(EightBall(bot)) + bot.add_cog(SpookyEightBall(bot)) log.info("8Ball cog loaded") -- cgit v1.2.3 From dc24705222dc6e9f6b40267571d23a95a0c4145f Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Sat, 11 May 2019 19:26:41 +0100 Subject: Update bot/seasons/halloween/8ball.py Co-Authored-By: S. Co1 --- bot/seasons/halloween/8ball.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/halloween/8ball.py b/bot/seasons/halloween/8ball.py index c2f560a7..40463bb7 100644 --- a/bot/seasons/halloween/8ball.py +++ b/bot/seasons/halloween/8ball.py @@ -39,4 +39,4 @@ def setup(bot): """Spooky Eight Ball Cog Load.""" bot.add_cog(SpookyEightBall(bot)) - log.info("8Ball cog loaded") + log.info("SpookyEightBall cog loaded") -- cgit v1.2.3 From 7fb510b12d671be074b94ece0e456b5f114d288b Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Sat, 11 May 2019 19:52:35 +0100 Subject: Removed embed, condensed code. --- bot/seasons/halloween/8ball.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'bot') diff --git a/bot/seasons/halloween/8ball.py b/bot/seasons/halloween/8ball.py index 40463bb7..cdd37a5a 100644 --- a/bot/seasons/halloween/8ball.py +++ b/bot/seasons/halloween/8ball.py @@ -23,16 +23,10 @@ class SpookyEightBall(commands.Cog): async def spookyeightball(self, ctx, *, question: str): """Responds with a random response to a question.""" choice = random.choice(responses['responses']) - if len(choice) == 1: - await ctx.send(choice[0]) - else: - emb = discord.Embed(colour=0x00f2ff) - emb.add_field(name=f'Question from {ctx.author.name}', value=question) - emb.add_field(name='Answer', value=choice[0]) - msg = await ctx.send(embed=emb) + msg = await ctx.send(choice[0]) + if len(choice) > 1: await asyncio.sleep(random.randint(2, 5)) - emb.set_field_at(1, name='Answer', value=f'{choice[0]} \n {choice[1]}') - await msg.edit(embed=emb) + await msg.edit(content=f"{choice[0]} \n{choice[1]}") def setup(bot): -- cgit v1.2.3 From 1922bf2dffa041841e76411ee84bd43c8d77c97f Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Sat, 11 May 2019 19:55:36 +0100 Subject: Removed unused import. --- bot/seasons/halloween/8ball.py | 1 - 1 file changed, 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/halloween/8ball.py b/bot/seasons/halloween/8ball.py index cdd37a5a..af037e53 100644 --- a/bot/seasons/halloween/8ball.py +++ b/bot/seasons/halloween/8ball.py @@ -4,7 +4,6 @@ import logging import random from pathlib import Path -import discord from discord.ext import commands log = logging.getLogger(__name__) -- cgit v1.2.3 From bf1901eba73f7f7d3ea39cf3db6c1ecf5195e321 Mon Sep 17 00:00:00 2001 From: sco1 Date: Sat, 11 May 2019 21:24:26 -0400 Subject: Fix broken help getter patterns Utilize new ctx.send_help coro Bump d.py minor version & relock --- Pipfile | 2 +- Pipfile.lock | 6 +++--- bot/seasons/christmas/adventofcode.py | 2 +- bot/seasons/evergreen/snakes/snakes_cog.py | 9 +-------- bot/seasons/season.py | 2 +- bot/seasons/valentines/be_my_valentine.py | 2 +- 6 files changed, 8 insertions(+), 15 deletions(-) (limited to 'bot') diff --git a/Pipfile b/Pipfile index ef683ce4..85f8dc87 100644 --- a/Pipfile +++ b/Pipfile @@ -10,7 +10,7 @@ aiodns = "*" pillow = "*" pytz = "*" fuzzywuzzy = "*" -discord-py = "==1.1" +discord-py = "~=1.1" [dev-packages] "flake8" = "*" diff --git a/Pipfile.lock b/Pipfile.lock index b9018ed2..1cf9e44a 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "d6e5b54c2ad1f624aa119ba76fec878eeb7e0d10db6bc19e6a42f6b65f762638" + "sha256": "0e7e34beb8c746a91b7e2209586e5c93663bae113b2989af8a0df849cf0d7dc7" }, "pipfile-spec": 6, "requires": { @@ -124,10 +124,10 @@ }, "discord-py": { "hashes": [ - "sha256:da6f783d130ae4dff7cca59d9038460ac9fe964a56d1b96e6d4a4a6255b5bb00" + "sha256:d0ab22f1fee1fcc02ac50a67ff49a5d1f6d7bc7eba77e34e35bd160b3ad3d7e8" ], "index": "pypi", - "version": "==1.1" + "version": "==1.1.1" }, "fuzzywuzzy": { "hashes": [ diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py index 5d05dce6..075c5606 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/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/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 55c4adb1..5ff5857b 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): -- cgit v1.2.3 From 9890f64206771d715b7f3829f4d5a8d60c256631 Mon Sep 17 00:00:00 2001 From: sco1 Date: Sat, 11 May 2019 22:12:44 -0400 Subject: Fix broken avatar URL getter patterns avatar_url_as now returns an Asset object, which cannot be passed directly to aiohttp since it's expecting a string. Asset objects also provide a read method, returning the bytes directly so the aiohttp call is no longer necessary. --- bot/seasons/easter/avatar_easterifier.py | 3 +-- bot/seasons/evergreen/snakes/utils.py | 14 ++++++-------- bot/seasons/halloween/spookyavatar.py | 5 +++-- 3 files changed, 10 insertions(+), 12 deletions(-) (limited to 'bot') 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/snakes/utils.py b/bot/seasons/evergreen/snakes/utils.py index e2ed60bd..01e527ca 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,18 +479,17 @@ 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): """ Handle players joining the game. - Prevent player joining if they have already joined, if the game is full, or if the game is + Prevent player joining if they have already cccccckgctrfebkrntucrvrktivvefvdjvnnniiehbde + joined, if the game is full, or if the game is in a waiting state. """ 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') -- cgit v1.2.3 From 4d250ffa79562034993bf29c6c27ed9df755f264 Mon Sep 17 00:00:00 2001 From: sco1 Date: Sat, 11 May 2019 23:44:36 -0400 Subject: Revert cat-induced programming trauma --- bot/seasons/evergreen/snakes/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/seasons/evergreen/snakes/utils.py b/bot/seasons/evergreen/snakes/utils.py index 01e527ca..a7cb70a7 100644 --- a/bot/seasons/evergreen/snakes/utils.py +++ b/bot/seasons/evergreen/snakes/utils.py @@ -488,8 +488,7 @@ class SnakeAndLaddersGame: """ Handle players joining the game. - Prevent player joining if they have already cccccckgctrfebkrntucrvrktivvefvdjvnnniiehbde - joined, if the game is full, or if the game is + Prevent player joining if they have already joined, if the game is full, or if the game is in a waiting state. """ -- cgit v1.2.3 From b1fb0a451c90984c0be96894b3cd1b0f0551fecf Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Mon, 13 May 2019 14:53:58 +0100 Subject: Created showprojects cog to add reactions to all messages in the show your projects channel. --- bot/seasons/evergreen/showprojects.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 bot/seasons/evergreen/showprojects.py (limited to 'bot') diff --git a/bot/seasons/evergreen/showprojects.py b/bot/seasons/evergreen/showprojects.py new file mode 100644 index 00000000..018bf461 --- /dev/null +++ b/bot/seasons/evergreen/showprojects.py @@ -0,0 +1,34 @@ +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.id != 528937022996611082 \ + 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") -- cgit v1.2.3 From 0a26ef46dd4b610d8d7474e70fce4dbafc0279a9 Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Mon, 13 May 2019 14:54:13 +0100 Subject: Added the show projects channels to the constants file. --- bot/constants.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'bot') diff --git a/bot/constants.py b/bot/constants.py index bf542daf..f424f943 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -18,6 +18,7 @@ class AdventOfCode: leaderboard_join_code = str(environ.get("AOC_JOIN_CODE", None)) leaderboard_max_displayed_members = 10 year = 2018 + channel_id = int(environ.get("AOC_CHANNEL_ID", 517745814039166986)) role_id = int(environ.get("AOC_ROLE_ID", 518565788744024082)) @@ -28,7 +29,7 @@ class Channels(NamedTuple): bot = 267659945086812160 checkpoint_test = 422077681434099723 devalerts = 460181980097675264 - devlog = int(environ.get('CHANNEL_DEVLOG', 548438471685963776)) + devlog = int(environ.get('CHANNEL_DEVLOG', 409308876241108992)) devtest = 414574275865870337 help_0 = 303906576991780866 help_1 = 303906556754395136 @@ -45,29 +46,27 @@ class Channels(NamedTuple): off_topic_2 = 463035268514185226 python = 267624335836053506 reddit = 458224812528238616 - seasonalbot_chat = int(environ.get('CHANNEL_SEASONALBOT_CHAT', 542272993192050698)) staff_lounge = 464905259261755392 verification = 352442727016693763 - python_discussion = 267624335836053506 + show_your_projects = 303934982764625920 + show_your_projects_discussion = 360148304664723466 class Client(NamedTuple): guild = int(environ.get('SEASONALBOT_GUILD', 267624335836053506)) - prefix = environ.get("PREFIX", ".") + prefix = "." token = environ.get('SEASONALBOT_TOKEN') debug = environ.get('SEASONALBOT_DEBUG', '').lower() == 'true' season_override = environ.get('SEASON_OVERRIDE') class Colours: - blue = 0x0279fd + soft_red = 0xcd6d6d + soft_green = 0x68c290 bright_green = 0x01d277 dark_green = 0x1f8b4c orange = 0xe67e22 pink = 0xcf84e0 - soft_green = 0x68c290 - soft_red = 0xcd6d6d - yellow = 0xf9f586 class Emojis: @@ -84,10 +83,12 @@ class Emojis: class Lovefest: + channel_id = int(environ.get("LOVEFEST_CHANNEL_ID", 542272993192050698)) role_id = int(environ.get("LOVEFEST_ROLE_ID", 542431903886606399)) class Hacktoberfest(NamedTuple): + channel_id = 498804484324196362 voice_id = 514420006474219521 -- cgit v1.2.3 From 7593eafd8ca2b5dfda66fa78cfe6fc0646ceeb65 Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Mon, 13 May 2019 15:42:52 +0100 Subject: Fixed broken constants commit with accidental changes. --- bot/constants.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'bot') diff --git a/bot/constants.py b/bot/constants.py index f424f943..211abf9e 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -18,7 +18,6 @@ class AdventOfCode: leaderboard_join_code = str(environ.get("AOC_JOIN_CODE", None)) leaderboard_max_displayed_members = 10 year = 2018 - channel_id = int(environ.get("AOC_CHANNEL_ID", 517745814039166986)) role_id = int(environ.get("AOC_ROLE_ID", 518565788744024082)) @@ -29,7 +28,7 @@ class Channels(NamedTuple): bot = 267659945086812160 checkpoint_test = 422077681434099723 devalerts = 460181980097675264 - devlog = int(environ.get('CHANNEL_DEVLOG', 409308876241108992)) + devlog = int(environ.get('CHANNEL_DEVLOG', 548438471685963776)) devtest = 414574275865870337 help_0 = 303906576991780866 help_1 = 303906556754395136 @@ -46,27 +45,31 @@ class Channels(NamedTuple): off_topic_2 = 463035268514185226 python = 267624335836053506 reddit = 458224812528238616 + seasonalbot_chat = int(environ.get('CHANNEL_SEASONALBOT_CHAT', 542272993192050698)) staff_lounge = 464905259261755392 verification = 352442727016693763 + python_discussion = 267624335836053506 show_your_projects = 303934982764625920 show_your_projects_discussion = 360148304664723466 class Client(NamedTuple): guild = int(environ.get('SEASONALBOT_GUILD', 267624335836053506)) - prefix = "." + prefix = environ.get("PREFIX", ".") token = environ.get('SEASONALBOT_TOKEN') debug = environ.get('SEASONALBOT_DEBUG', '').lower() == 'true' season_override = environ.get('SEASON_OVERRIDE') class Colours: - soft_red = 0xcd6d6d - soft_green = 0x68c290 + blue = 0x0279fd bright_green = 0x01d277 dark_green = 0x1f8b4c orange = 0xe67e22 pink = 0xcf84e0 + soft_green = 0x68c290 + soft_red = 0xcd6d6d + yellow = 0xf9f586 class Emojis: @@ -83,12 +86,10 @@ class Emojis: class Lovefest: - channel_id = int(environ.get("LOVEFEST_CHANNEL_ID", 542272993192050698)) role_id = int(environ.get("LOVEFEST_ROLE_ID", 542431903886606399)) class Hacktoberfest(NamedTuple): - channel_id = 498804484324196362 voice_id = 514420006474219521 @@ -129,4 +130,4 @@ ERROR_REPLIES = [ ] -bot = SeasonalBot(command_prefix=Client.prefix) +bot = SeasonalBot(command_prefix=Client.prefix) \ No newline at end of file -- cgit v1.2.3 From 48ec21106e54f9b1bae99a7700bd3c7523a8e2f0 Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Tue, 14 May 2019 18:09:43 +0100 Subject: Update bot/constants.py Co-Authored-By: Daniel Brown --- bot/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/constants.py b/bot/constants.py index 211abf9e..67dd9328 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -130,4 +130,4 @@ ERROR_REPLIES = [ ] -bot = SeasonalBot(command_prefix=Client.prefix) \ No newline at end of file +bot = SeasonalBot(command_prefix=Client.prefix) -- cgit v1.2.3 From 1d5d30790801a7e9f8b345b63b3119bb4b30df10 Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Tue, 14 May 2019 19:01:10 +0100 Subject: Changed comparison from Bot ID to d.py inbuilt bot filter. --- bot/seasons/evergreen/showprojects.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/seasons/evergreen/showprojects.py b/bot/seasons/evergreen/showprojects.py index 018bf461..bb92cb50 100644 --- a/bot/seasons/evergreen/showprojects.py +++ b/bot/seasons/evergreen/showprojects.py @@ -19,13 +19,18 @@ class ShowProjects(commands.Cog): """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.id != 528937022996611082 \ - and message.author.id != self.lastPoster: + 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 + @commands.command() + async def testcomm(self, ctx): + await ctx.send("test") + def setup(bot): """Show Projects Reaction Cog""" -- cgit v1.2.3 From fa16be77cefcadf8ed8965d67704156665c8dd93 Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Tue, 14 May 2019 19:03:48 +0100 Subject: Removed test method I left in by mistake! --- bot/seasons/evergreen/showprojects.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'bot') diff --git a/bot/seasons/evergreen/showprojects.py b/bot/seasons/evergreen/showprojects.py index bb92cb50..d6223690 100644 --- a/bot/seasons/evergreen/showprojects.py +++ b/bot/seasons/evergreen/showprojects.py @@ -27,10 +27,6 @@ class ShowProjects(commands.Cog): self.lastPoster = message.author.id - @commands.command() - async def testcomm(self, ctx): - await ctx.send("test") - def setup(bot): """Show Projects Reaction Cog""" -- cgit v1.2.3