diff options
| author | 2019-04-09 13:26:58 +0100 | |
|---|---|---|
| committer | 2019-04-09 13:26:58 +0100 | |
| commit | 262f3a8df49fc7bbf8b76956e981a00a38bd65d6 (patch) | |
| tree | 7811922b6f295d431a9793aace96c78a15e49df3 | |
| parent | Merge pull request #1 from python-discord/master (diff) | |
Created the spooky8ball command and the corresponding .json responses file.
| -rw-r--r-- | bot/resources/halloween/responses.json | 14 | ||||
| -rw-r--r-- | bot/seasons/halloween/8ball.py | 39 | 
2 files changed, 53 insertions, 0 deletions
| 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") | 
