aboutsummaryrefslogtreecommitdiffstats
path: root/bot
diff options
context:
space:
mode:
authorGravatar kwzrd <[email protected]>2020-03-21 19:46:07 +0100
committerGravatar kwzrd <[email protected]>2020-03-21 19:46:07 +0100
commit9b9499824b6db37b35ee3a168bc342f9864ee944 (patch)
tree62353cde06ddd1d1ce7e630b642f6454dea62d06 /bot
parentDeseasonify: remove `season_override` env var (diff)
Deseasonify: add class for branding config
Since we'll be adding more env vars to control the branding manager, let's add a new config category. As a result, the cycle frequency constant name can be made shorter.
Diffstat (limited to 'bot')
-rw-r--r--bot/branding.py12
-rw-r--r--bot/constants.py7
2 files changed, 11 insertions, 8 deletions
diff --git a/bot/branding.py b/bot/branding.py
index b07ca4b4..690c14c1 100644
--- a/bot/branding.py
+++ b/bot/branding.py
@@ -10,7 +10,7 @@ from discord.embeds import EmptyEmbed
from discord.ext import commands
from bot.bot import SeasonalBot
-from bot.constants import Client, MODERATION_ROLES, Tokens
+from bot.constants import Branding, MODERATION_ROLES, Tokens
from bot.decorators import with_role
from bot.seasons import SeasonBase, get_current_season, get_season
@@ -155,8 +155,8 @@ class BrandingManager(commands.Cog):
info_embed.add_field(name="Available icons", value=icons, inline=False)
# Only display cycle frequency if we're actually cycling
- if len(self.available_icons) > 1 and Client.icon_cycle_frequency:
- info_embed.set_footer(text=f"Icon cycle frequency: {Client.icon_cycle_frequency}")
+ if len(self.available_icons) > 1 and Branding.cycle_frequency:
+ info_embed.set_footer(text=f"Icon cycle frequency: {Branding.cycle_frequency}")
return info_embed
@@ -169,13 +169,13 @@ class BrandingManager(commands.Cog):
Reset the `should_cycle` counter based on configured frequency.
Counter will always yield False if either holds:
- - Client.icon_cycle_frequency is falsey
+ - Branding.cycle_frequency is falsey
- There are fewer than 2 available icons for current season
Cycling can be easily turned off, and we prevent re-uploading the same icon repeatedly.
"""
- if len(self.available_icons) > 1 and Client.icon_cycle_frequency:
- wait_period = [False] * (Client.icon_cycle_frequency - 1)
+ if len(self.available_icons) > 1 and Branding.cycle_frequency:
+ wait_period = [False] * (Branding.cycle_frequency - 1)
counter = itertools.cycle(wait_period + [True])
else:
counter = itertools.cycle([False])
diff --git a/bot/constants.py b/bot/constants.py
index 9afbc604..691e7760 100644
--- a/bot/constants.py
+++ b/bot/constants.py
@@ -6,7 +6,7 @@ from typing import NamedTuple
__all__ = (
"bookmark_icon_url",
- "AdventOfCode", "Channels", "Client", "Colours", "Emojis", "Hacktoberfest", "Month", "Roles", "Tokens",
+ "AdventOfCode", "Branding", "Channels", "Client", "Colours", "Emojis", "Hacktoberfest", "Month", "Roles", "Tokens",
"WHITELISTED_CHANNELS", "STAFF_ROLES", "MODERATION_ROLES",
"POSITIVE_REPLIES", "NEGATIVE_REPLIES", "ERROR_REPLIES",
)
@@ -63,12 +63,15 @@ class Channels(NamedTuple):
hacktoberfest_2019 = 628184417646411776
+class Branding:
+ cycle_frequency = int(environ.get("CYCLE_FREQUENCY", 3)) # 0: never, 1: every day, 2: every other day, ...
+
+
class Client(NamedTuple):
guild = int(environ.get("SEASONALBOT_GUILD", 267624335836053506))
prefix = environ.get("PREFIX", ".")
token = environ.get("SEASONALBOT_TOKEN")
debug = environ.get("SEASONALBOT_DEBUG", "").lower() == "true"
- icon_cycle_frequency = 3 # 0: never, 1: every day, 2: every other day, ...
class Colours: