diff options
Diffstat (limited to 'bot/seasons/halloween')
| -rw-r--r-- | bot/seasons/halloween/candy_collection.py | 13 | ||||
| -rw-r--r-- | bot/seasons/halloween/hacktoberstats.py | 14 | ||||
| -rw-r--r-- | bot/seasons/halloween/halloween_facts.py | 5 | ||||
| -rw-r--r-- | bot/seasons/halloween/halloweenify.py | 4 | ||||
| -rw-r--r-- | bot/seasons/halloween/monstersurvey.py | 9 | ||||
| -rw-r--r-- | bot/seasons/halloween/scarymovie.py | 8 | ||||
| -rw-r--r-- | bot/seasons/halloween/spookyavatar.py | 5 | ||||
| -rw-r--r-- | bot/seasons/halloween/spookygif.py | 2 | ||||
| -rw-r--r-- | bot/seasons/halloween/spookyrating.py | 3 | ||||
| -rw-r--r-- | bot/seasons/halloween/spookyreact.py | 3 | ||||
| -rw-r--r-- | bot/seasons/halloween/spookysound.py | 2 | ||||
| -rw-r--r-- | bot/seasons/halloween/timeleft.py | 4 | 
12 files changed, 6 insertions, 66 deletions
diff --git a/bot/seasons/halloween/candy_collection.py b/bot/seasons/halloween/candy_collection.py index 70648e64..1f219425 100644 --- a/bot/seasons/halloween/candy_collection.py +++ b/bot/seasons/halloween/candy_collection.py @@ -36,7 +36,6 @@ class CandyCollection(commands.Cog):      @commands.Cog.listener()      async def on_message(self, message):          """Randomly adds candy or skull reaction to non-bot messages in the Event channel.""" -          # make sure its a human message          if message.author.bot:              return @@ -58,7 +57,6 @@ class CandyCollection(commands.Cog):      @commands.Cog.listener()      async def on_reaction_add(self, reaction, user):          """Add/remove candies from a person if the reaction satisfies criteria.""" -          message = reaction.message          # check to ensure the reactor is human          if user.bot: @@ -110,7 +108,6 @@ class CandyCollection(commands.Cog):          This event has a higher probability of occurring than a reaction add to a message without an          existing reaction.          """ -          if random.randint(1, ADD_SKULL_EXISTING_REACTION_CHANCE) == 1:              d = {"reaction": '\N{SKULL}', "msg_id": message.id, "won": False}              self.msg_reacted.append(d) @@ -123,7 +120,6 @@ class CandyCollection(commands.Cog):      async def ten_recent_msg(self):          """Get the last 10 messages sent in the channel.""" -          ten_recent = []          recent_msg = max(message.id for message                           in self.bot._connection._messages @@ -141,7 +137,6 @@ class CandyCollection(commands.Cog):      async def get_message(self, msg_id):          """Get the message from its ID.""" -          try:              o = discord.Object(id=msg_id + 1)              # Use history rather than get_message due to @@ -158,12 +153,10 @@ class CandyCollection(commands.Cog):      async def hacktober_channel(self):          """Get #hacktoberbot channel from its ID.""" -          return self.bot.get_channel(id=Hacktoberfest.channel_id)      async def remove_reactions(self, reaction):          """Remove all candy/skull reactions.""" -          try:              async for user in reaction.users():                  await reaction.message.remove_reaction(reaction.emoji, user) @@ -173,7 +166,6 @@ class CandyCollection(commands.Cog):      async def send_spook_msg(self, author, channel, candies):          """Send a spooky message.""" -          e = discord.Embed(colour=author.colour)          e.set_author(name="Ghosts and Ghouls and Jack o' lanterns at night; "                            f"I took {candies} candies and quickly took flight.") @@ -181,15 +173,13 @@ class CandyCollection(commands.Cog):      def save_to_json(self):          """Save JSON to a local file.""" -          with open(json_location, 'w') as outfile:              json.dump(self.candy_json, outfile)      @commands.command()      async def candy(self, ctx):          """Get the candy leaderboard and save to JSON.""" - -        # use run_in_executor to prevent blocking +        # Use run_in_executor to prevent blocking          thing = functools.partial(self.save_to_json)          await self.bot.loop.run_in_executor(None, thing) @@ -225,6 +215,5 @@ class CandyCollection(commands.Cog):  def setup(bot):      """Candy Collection game Cog load.""" -      bot.add_cog(CandyCollection(bot))      log.info("CandyCollection cog loaded") diff --git a/bot/seasons/halloween/hacktoberstats.py b/bot/seasons/halloween/hacktoberstats.py index 42623669..c30ad90f 100644 --- a/bot/seasons/halloween/hacktoberstats.py +++ b/bot/seasons/halloween/hacktoberstats.py @@ -34,7 +34,6 @@ class HacktoberStats(commands.Cog):          linked their Discord name to GitHub using .stats link. If invoked with a github_username,          get that user's contributions          """ -          if not github_username:              author_id, author_mention = HacktoberStats._author_mention_from_context(ctx) @@ -65,7 +64,6 @@ class HacktoberStats(commands.Cog):                  }              }          """ -          author_id, author_mention = HacktoberStats._author_mention_from_context(ctx)          if github_username:              if str(author_id) in self.linked_accounts.keys(): @@ -89,7 +87,6 @@ class HacktoberStats(commands.Cog):      @hacktoberstats_group.command(name="unlink")      async def unlink_user(self, ctx: commands.Context):          """Remove the invoking user's account link from the log.""" -          author_id, author_mention = HacktoberStats._author_mention_from_context(ctx)          stored_user = self.linked_accounts.pop(author_id, None) @@ -114,7 +111,6 @@ class HacktoberStats(commands.Cog):                  }              }          """ -          if self.link_json.exists():              logging.info(f"Loading linked GitHub accounts from '{self.link_json}'")              with open(self.link_json, 'r') as fID: @@ -138,7 +134,6 @@ class HacktoberStats(commands.Cog):                  }              }          """ -          logging.info(f"Saving linked_accounts to '{self.link_json}'")          with open(self.link_json, 'w') as fID:              json.dump(self.linked_accounts, fID, default=str) @@ -154,7 +149,6 @@ class HacktoberStats(commands.Cog):          Otherwise, post a helpful error message          """ -          async with ctx.typing():              prs = await self.get_october_prs(github_username) @@ -166,7 +160,6 @@ class HacktoberStats(commands.Cog):      def build_embed(self, github_username: str, prs: typing.List[dict]) -> discord.Embed:          """Return a stats embed built from github_username's PRs.""" -          logging.info(f"Building Hacktoberfest embed for GitHub user: '{github_username}'")          pr_stats = self._summarize_prs(prs) @@ -221,7 +214,6 @@ class HacktoberStats(commands.Cog):          Otherwise, return None          """ -          logging.info(f"Generating Hacktoberfest PR query for GitHub user: '{github_username}'")          base_url = "https://api.github.com/search/issues?q="          not_label = "invalid" @@ -278,7 +270,6 @@ class HacktoberStats(commands.Cog):               V               "python-discord/seasonalbot"          """ -          exp = r"https?:\/\/api.github.com\/repos\/([/\-\_\.\w]+)"          return re.findall(exp, in_url)[0] @@ -293,7 +284,6 @@ class HacktoberStats(commands.Cog):              "top5": [(repo_shortname, ncontributions), ...]              }          """ -          contributed_repos = [pr["repo_shortname"] for pr in prs]          return {"n_prs": len(prs), "top5": Counter(contributed_repos).most_common(5)} @@ -309,7 +299,6 @@ class HacktoberStats(commands.Cog):             n contribution(s) to [shortname](url)             ...          """ -          baseURL = "https://www.github.com/"          contributionstrs = []          for repo in stats['top5']: @@ -321,7 +310,6 @@ class HacktoberStats(commands.Cog):      @staticmethod      def _contributionator(n: int) -> str:          """Return "contribution" or "contributions" based on the value of n.""" -          if n == 1:              return "contribution"          else: @@ -330,7 +318,6 @@ class HacktoberStats(commands.Cog):      @staticmethod      def _author_mention_from_context(ctx: commands.Context) -> typing.Tuple:          """Return stringified Message author ID and mentionable string from commands.Context.""" -          author_id = str(ctx.message.author.id)          author_mention = ctx.message.author.mention @@ -339,6 +326,5 @@ class HacktoberStats(commands.Cog):  def setup(bot):      """Hacktoberstats Cog load.""" -      bot.add_cog(HacktoberStats(bot))      log.info("HacktoberStats cog loaded") diff --git a/bot/seasons/halloween/halloween_facts.py b/bot/seasons/halloween/halloween_facts.py index ee90dbd3..e8392b28 100644 --- a/bot/seasons/halloween/halloween_facts.py +++ b/bot/seasons/halloween/halloween_facts.py @@ -39,19 +39,16 @@ class HalloweenFacts(commands.Cog):      @commands.Cog.listener()      async def on_ready(self):          """Get event Channel object and initialize fact task loop.""" -          self.channel = self.bot.get_channel(Hacktoberfest.channel_id)          self.bot.loop.create_task(self._fact_publisher_task())      def random_fact(self):          """Return a random fact from the loaded facts.""" -          return random.choice(self.facts)      @commands.command(name="spookyfact", aliases=("halloweenfact",), brief="Get the most recent Halloween fact")      async def get_random_fact(self, ctx):          """Reply with the most recent Halloween fact.""" -          index, fact = self.random_fact()          embed = self._build_embed(index, fact)          await ctx.send(embed=embed) @@ -59,7 +56,6 @@ class HalloweenFacts(commands.Cog):      @staticmethod      def _build_embed(index, fact):          """Builds a Discord embed from the given fact and its index.""" -          emoji = random.choice(SPOOKY_EMOJIS)          title = f"{emoji} Halloween Fact #{index + 1}"          return discord.Embed(title=title, description=fact, color=PUMPKIN_ORANGE) @@ -67,6 +63,5 @@ class HalloweenFacts(commands.Cog):  def setup(bot):      """Halloween facts Cog load.""" -      bot.add_cog(HalloweenFacts(bot))      log.info("HalloweenFacts cog loaded") diff --git a/bot/seasons/halloween/halloweenify.py b/bot/seasons/halloween/halloweenify.py index ce057889..4d56e2f8 100644 --- a/bot/seasons/halloween/halloweenify.py +++ b/bot/seasons/halloween/halloweenify.py @@ -19,8 +19,7 @@ class Halloweenify(commands.Cog):      @commands.cooldown(1, 300, BucketType.user)      @commands.command()      async def halloweenify(self, ctx): -        """Change your nickname into a much spookier one.""" - +        """Change your nickname into a much spookier one!"""          async with ctx.typing():              with open(Path('bot', 'resources', 'halloween', 'halloweenify.json'), 'r') as f:                  data = load(f) @@ -49,6 +48,5 @@ class Halloweenify(commands.Cog):  def setup(bot):      """Halloweenify Cog load.""" -      bot.add_cog(Halloweenify(bot))      log.info("Halloweenify cog loaded") diff --git a/bot/seasons/halloween/monstersurvey.py b/bot/seasons/halloween/monstersurvey.py index 2ae98f6e..4e967cca 100644 --- a/bot/seasons/halloween/monstersurvey.py +++ b/bot/seasons/halloween/monstersurvey.py @@ -25,7 +25,6 @@ class MonsterSurvey(Cog):      def __init__(self, bot: Bot):          """Initializes values for the bot to use within the voting commands.""" -          self.bot = bot          self.registry_location = os.path.join(os.getcwd(), 'bot', 'resources', 'halloween', 'monstersurvey.json')          with open(self.registry_location, 'r') as jason: @@ -33,7 +32,6 @@ class MonsterSurvey(Cog):      def json_write(self):          """Write voting results to a local JSON file.""" -          log.info("Saved Monster Survey Results")          with open(self.registry_location, 'w') as jason:              json.dump(self.voter_registry, jason, indent=2) @@ -48,7 +46,6 @@ class MonsterSurvey(Cog):          :param monster: the string key of the json that represents a monster          :return: None          """ -          vr = self.voter_registry          for m in vr.keys():              if id not in vr[m]['votes'] and m == monster: @@ -59,7 +56,6 @@ class MonsterSurvey(Cog):      def get_name_by_leaderboard_index(self, n):          """Return the monster at the specified leaderboard index.""" -          n = n - 1          vr = self.voter_registry          top = sorted(vr, key=lambda k: len(vr[k]['votes']), reverse=True) @@ -72,7 +68,6 @@ class MonsterSurvey(Cog):      )      async def monster_group(self, ctx: Context):          """The base voting command. If nothing is called, then it will return an embed.""" -          if ctx.invoked_subcommand is None:              async with ctx.typing():                  default_embed = Embed( @@ -107,7 +102,6 @@ class MonsterSurvey(Cog):          Displays a list of monsters that can be voted for if one is not specified.          """ -          if name is None:              await ctx.invoke(self.monster_leaderboard)              return @@ -161,7 +155,6 @@ class MonsterSurvey(Cog):          :param name:          :return:          """ -          if name is None:              await ctx.invoke(self.monster_leaderboard)              return @@ -198,7 +191,6 @@ class MonsterSurvey(Cog):          :param ctx:          :return:          """ -          async with ctx.typing():              vr = self.voter_registry              top = sorted(vr, key=lambda k: len(vr[k]['votes']), reverse=True) @@ -225,6 +217,5 @@ class MonsterSurvey(Cog):  def setup(bot):      """Monster survey Cog load.""" -      bot.add_cog(MonsterSurvey(bot))      log.info("MonsterSurvey cog loaded") diff --git a/bot/seasons/halloween/scarymovie.py b/bot/seasons/halloween/scarymovie.py index 3878ef7f..cd95a3a2 100644 --- a/bot/seasons/halloween/scarymovie.py +++ b/bot/seasons/halloween/scarymovie.py @@ -22,7 +22,6 @@ class ScaryMovie(commands.Cog):      @commands.command(name='scarymovie', alias=['smovie'])      async def random_movie(self, ctx):          """Randomly select a scary movie and display information about it.""" -          async with ctx.typing():              selection = await self.select_movie()              movie_details = await self.format_metadata(selection) @@ -31,8 +30,7 @@ class ScaryMovie(commands.Cog):      @staticmethod      async def select_movie(): -        """Selects a random movie and returns a json of movie details from TMDb.""" - +        """Selects a random movie and returns a JSON of movie details from TMDb."""          url = 'https://api.themoviedb.org/4/discover/movie'          params = {              'with_genres': '27', @@ -65,8 +63,7 @@ class ScaryMovie(commands.Cog):      @staticmethod      async def format_metadata(movie): -        """Formats raw TMDb data to be embedded in discord chat.""" - +        """Formats raw TMDb data to be embedded in Discord chat."""          # Build the relevant URLs.          movie_id = movie.get("id")          poster_path = movie.get("poster_path") @@ -131,6 +128,5 @@ class ScaryMovie(commands.Cog):  def setup(bot):      """Scary movie Cog load.""" -      bot.add_cog(ScaryMovie(bot))      log.info("ScaryMovie cog loaded") diff --git a/bot/seasons/halloween/spookyavatar.py b/bot/seasons/halloween/spookyavatar.py index 15c7c431..4b0ba9f5 100644 --- a/bot/seasons/halloween/spookyavatar.py +++ b/bot/seasons/halloween/spookyavatar.py @@ -19,8 +19,7 @@ class SpookyAvatar(commands.Cog):          self.bot = bot      async def get(self, url): -        """Returns the contents of the supplied url.""" - +        """Returns the contents of the supplied URL."""          async with aiohttp.ClientSession() as session:              async with session.get(url) as resp:                  return await resp.read() @@ -29,7 +28,6 @@ class SpookyAvatar(commands.Cog):                        brief='Spookify an user\'s avatar.')      async def spooky_avatar(self, ctx, user: discord.Member = None):          """A command to print the user's spookified avatar.""" -          if user is None:              user = ctx.message.author @@ -50,6 +48,5 @@ class SpookyAvatar(commands.Cog):  def setup(bot):      """Spooky avatar Cog load.""" -      bot.add_cog(SpookyAvatar(bot))      log.info("SpookyAvatar cog loaded") diff --git a/bot/seasons/halloween/spookygif.py b/bot/seasons/halloween/spookygif.py index 37d46c01..ba2ad6e5 100644 --- a/bot/seasons/halloween/spookygif.py +++ b/bot/seasons/halloween/spookygif.py @@ -18,7 +18,6 @@ class SpookyGif(commands.Cog):      @commands.command(name="spookygif", aliases=("sgif", "scarygif"))      async def spookygif(self, ctx):          """Fetches a random gif from the GIPHY API and responds with it.""" -          async with ctx.typing():              async with aiohttp.ClientSession() as session:                  params = {'api_key': Tokens.giphy, 'tag': 'halloween', 'rating': 'g'} @@ -36,6 +35,5 @@ class SpookyGif(commands.Cog):  def setup(bot):      """Spooky GIF Cog load.""" -      bot.add_cog(SpookyGif(bot))      log.info("SpookyGif cog loaded") diff --git a/bot/seasons/halloween/spookyrating.py b/bot/seasons/halloween/spookyrating.py index a9cfda9b..18a963e0 100644 --- a/bot/seasons/halloween/spookyrating.py +++ b/bot/seasons/halloween/spookyrating.py @@ -31,7 +31,6 @@ class SpookyRating(commands.Cog):          Any user will always yield the same result, no matter who calls the command          """ -          if who is None:              who = ctx.author @@ -63,6 +62,6 @@ class SpookyRating(commands.Cog):  def setup(bot): -    """Cog load.""" +    """Spooky Rating Cog load."""      bot.add_cog(SpookyRating(bot))      log.info("SpookyRating cog loaded") diff --git a/bot/seasons/halloween/spookyreact.py b/bot/seasons/halloween/spookyreact.py index 9b14507a..5a086072 100644 --- a/bot/seasons/halloween/spookyreact.py +++ b/bot/seasons/halloween/spookyreact.py @@ -32,7 +32,6 @@ class SpookyReact(Cog):          Seasonalbot's own messages are ignored          """ -          for trigger in SPOOKY_TRIGGERS.keys():              trigger_test = re.search(SPOOKY_TRIGGERS[trigger][0], ctx.content.lower())              if trigger_test: @@ -52,7 +51,6 @@ class SpookyReact(Cog):            * author is the bot            * prefix is not None          """ -          # Check for self reaction          if ctx.author == self.bot.user:              logging.debug(f"Ignoring reactions on self message. Message ID: {ctx.id}") @@ -70,6 +68,5 @@ class SpookyReact(Cog):  def setup(bot):      """Spooky reaction Cog load.""" -      bot.add_cog(SpookyReact(bot))      log.info("SpookyReact cog loaded") diff --git a/bot/seasons/halloween/spookysound.py b/bot/seasons/halloween/spookysound.py index 7c4d8113..995f0403 100644 --- a/bot/seasons/halloween/spookysound.py +++ b/bot/seasons/halloween/spookysound.py @@ -26,7 +26,6 @@ class SpookySound(commands.Cog):          Cannot be used more than once in 2 minutes.          """ -          if not self.channel:              await self.bot.wait_until_ready()              self.channel = self.bot.get_channel(Hacktoberfest.voice_id) @@ -45,6 +44,5 @@ class SpookySound(commands.Cog):  def setup(bot):      """Spooky sound Cog load.""" -      bot.add_cog(SpookySound(bot))      log.info("SpookySound cog loaded") diff --git a/bot/seasons/halloween/timeleft.py b/bot/seasons/halloween/timeleft.py index 3ea2d9ad..a2b16a6c 100644 --- a/bot/seasons/halloween/timeleft.py +++ b/bot/seasons/halloween/timeleft.py @@ -15,13 +15,11 @@ class TimeLeft(commands.Cog):      @staticmethod      def in_october():          """Return True if the current month is October.""" -          return datetime.utcnow().month == 10      @staticmethod      def load_date():          """Return of a tuple of the current time and the end and start times of the next October.""" -          now = datetime.utcnow()          year = now.year          if now.month > 10: @@ -38,7 +36,6 @@ class TimeLeft(commands.Cog):          Whilst in October, displays the days, hours and minutes left.          Only displays the days left until the beginning and end whilst in a different month          """ -          now, end, start = self.load_date()          diff = end - now          days, seconds = diff.days, diff.seconds @@ -58,6 +55,5 @@ class TimeLeft(commands.Cog):  def setup(bot):      """Cog load.""" -      bot.add_cog(TimeLeft(bot))      log.info("TimeLeft cog loaded")  |