aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2020-11-17 16:34:16 +0200
committerGravatar ks129 <[email protected]>2020-11-17 16:34:16 +0200
commitf12ee976561b3cd474794c5e0230854b8d368a32 (patch)
treebe45f181d1d7b426482c71aca1ad3278d01e1b22
parentPort branding management to this bot from SeasonalBot (diff)
Move GitHub API key to better location
-rw-r--r--bot/constants.py7
-rw-r--r--bot/exts/backend/branding.py6
-rw-r--r--config-default.yml5
3 files changed, 5 insertions, 13 deletions
diff --git a/bot/constants.py b/bot/constants.py
index 57d8928fa..20e8c4b83 100644
--- a/bot/constants.py
+++ b/bot/constants.py
@@ -491,6 +491,7 @@ class Keys(metaclass=YAMLGetter):
section = "keys"
site_api: Optional[str]
+ github: Optional[str]
class URLs(metaclass=YAMLGetter):
@@ -617,12 +618,6 @@ class Branding(metaclass=YAMLGetter):
cycle_frequency: int
-class Tokens(metaclass=YAMLGetter):
- section = "tokens"
-
- github: str
-
-
class Event(Enum):
"""
Event names. This does not include every event (for example, raw
diff --git a/bot/exts/backend/branding.py b/bot/exts/backend/branding.py
index 286b6e0b1..268f5dd48 100644
--- a/bot/exts/backend/branding.py
+++ b/bot/exts/backend/branding.py
@@ -12,7 +12,7 @@ from async_rediscache import RedisCache
from discord.ext import commands
from bot.bot import Bot
-from bot.constants import AssetType, Branding, Colours, Emojis, Guild, MODERATION_ROLES, Tokens
+from bot.constants import AssetType, Branding, Colours, Emojis, Guild, Keys, MODERATION_ROLES
from bot.seasons import SeasonBase, get_all_seasons, get_current_season, get_season
from bot.decorators import in_whitelist, mock_in_debug
from bot.errors import BrandingError
@@ -32,8 +32,8 @@ HEADERS = {"Accept": "application/vnd.github.v3+json"} # Ensure we use API v3
# A GitHub token is not necessary for the cog to operate,
# unauthorized requests are however limited to 60 per hour
-if Tokens.github:
- HEADERS["Authorization"] = f"token {Tokens.github}"
+if Keys.github:
+ HEADERS["Authorization"] = f"token {Keys.github}"
class GitHubFile(t.NamedTuple):
diff --git a/config-default.yml b/config-default.yml
index e7163fbe0..a9bbb144e 100644
--- a/config-default.yml
+++ b/config-default.yml
@@ -321,6 +321,7 @@ filter:
keys:
site_api: !ENV "BOT_API_KEY"
+ github: !ENV "GITHUB_TOKEN"
urls:
@@ -535,9 +536,5 @@ branding:
cycle_frequency: 3 # How many days bot wait before refreshing server icon
-tokens:
- github: !ENV "GITHUB_TOKEN"
-
-
config:
required_keys: ['bot.token']