diff options
author | 2019-03-30 20:34:00 +1000 | |
---|---|---|
committer | 2019-03-30 20:34:00 +1000 | |
commit | c4c03ee851495793d7371af1bc36d2d4c8672aab (patch) | |
tree | 1f16534efd66a9c4efc39036fa9f8db6a7463c7a | |
parent | Update docstrings for new linting (diff) | |
parent | Merge pull request #163 from python-discord/easter_announce (diff) |
Merge branch 'master' into flake8-docstring
-rw-r--r-- | bot/seasons/easter/__init__.py | 22 | ||||
-rw-r--r-- | bot/seasons/season.py | 56 |
2 files changed, 49 insertions, 29 deletions
diff --git a/bot/seasons/easter/__init__.py b/bot/seasons/easter/__init__.py index c1de5811..4d7e8467 100644 --- a/bot/seasons/easter/__init__.py +++ b/bot/seasons/easter/__init__.py @@ -1,18 +1,32 @@ +from bot.constants import Colours from bot.seasons import SeasonBase class Easter(SeasonBase): """ - Easter is a beautiful time of the year often celebrated after the first Full Moon of the new spring season. + Here at Python Discord, we celebrate our version of Easter during the entire month of April. + While this celebration takes place, you'll notice a few changes: - This time is quite beautiful due to the colorful flowers coming out to greet us. So let's greet Spring - in an Easter celebration of contributions. + • The server icon has changed to our Easter icon. Thanks to <@140605665772175361> for the + design! + + • [Easter issues now available for SeasonalBot on the repo](https://git.io/fjkvQ). + + • You may see stuff like an Easter themed esoteric challenge, a celebration of Earth Day, or + Easter-related micro-events for you to join. Stay tuned! + + If you'd like to contribute, head on over to <#542272993192050698> and we will help you get + started. It doesn't matter if you're new to open source or Python, if you'd like to help, we + will find you a task and teach you what you need to know. """ name = "easter" bot_name = "BunnyBot" - greeting = "Happy Easter to us all!" + greeting = "Happy Easter!" # Duration of season start_date = "01/04" end_date = "30/04" + + colour = Colours.pink + icon = "/logos/logo_seasonal/easter/easter.png" diff --git a/bot/seasons/season.py b/bot/seasons/season.py index 9dac51e2..a64f6ca6 100644 --- a/bot/seasons/season.py +++ b/bot/seasons/season.py @@ -17,6 +17,8 @@ from bot.decorators import with_role log = logging.getLogger(__name__) +ICON_BASE_URL = "https://raw.githubusercontent.com/python-discord/branding/master" + def get_seasons() -> List[str]: """Returns all the Season objects located in /bot/seasons/.""" @@ -150,12 +152,11 @@ class SeasonBase: e.g. `/logos/logo_seasonal/valentines/loved_up.png` """ - base_url = "https://raw.githubusercontent.com/python-discord/branding/master" if avatar: icon = self.bot_icon or self.icon else: icon = self.icon - full_url = base_url + icon + full_url = ICON_BASE_URL + icon log.debug(f"Getting icon from: {full_url}") async with bot.http_session.get(full_url) as resp: return await resp.read() @@ -269,7 +270,21 @@ class SeasonBase: channel = guild.get_channel(Channels.announcements) mention = f"<@&{Roles.announcements}>" - # collect seasonal cogs + # build cog info output + doc = inspect.getdoc(self) + announce = "\n\n".join(l.replace("\n", " ") for l in doc.split("\n\n")) + + # no announcement message found + if not doc: + return + + embed = discord.Embed(description=f"{announce}\n\n", colour=self.colour or guild.me.colour) + embed.set_author(name=self.greeting) + + if self.icon: + embed.set_image(url=ICON_BASE_URL+self.icon) + + # find any seasonal commands cogs = [] for cog in bot.cogs.values(): if "evergreen" in cog.__module__: @@ -278,30 +293,21 @@ class SeasonBase: if cog_name != "SeasonManager": cogs.append(cog_name) - # no cogs, so no seasonal commands - if not cogs: - return - - # build cog info output - doc = inspect.getdoc(self) - announce_text = doc + "\n\n" if doc else "" + if cogs: + def cog_name(cog): + return type(cog).__name__ - def cog_name(cog): - return type(cog).__name__ - - cog_info = [] - for cog in sorted(cogs, key=cog_name): - doc = inspect.getdoc(bot.get_cog(cog)) - if doc: - cog_info.append(f"**{cog}**\n*{doc}*") - else: - cog_info.append(f"**{cog}**") + cog_info = [] + for cog in sorted(cogs, key=cog_name): + doc = inspect.getdoc(bot.get_cog(cog)) + if doc: + cog_info.append(f"**{cog}**\n*{doc}*") + else: + cog_info.append(f"**{cog}**") - embed = discord.Embed(description=announce_text, colour=self.colour or guild.me.colour) - embed.set_author(name=self.greeting) - cogs_text = "\n".join(cog_info) - embed.add_field(name="New Command Categories", value=cogs_text) - embed.set_footer(text="To see the new commands, use .help Category") + cogs_text = "\n".join(cog_info) + embed.add_field(name="New Command Categories", value=cogs_text) + embed.set_footer(text="To see the new commands, use .help Category") await channel.send(mention, embed=embed) |