aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/constants.py37
-rw-r--r--bot/exts/holidays/easter/earth_photos.py6
-rw-r--r--bot/exts/utilities/wolfram.py4
3 files changed, 31 insertions, 16 deletions
diff --git a/bot/constants.py b/bot/constants.py
index b17fc920..5f853521 100644
--- a/bot/constants.py
+++ b/bot/constants.py
@@ -293,17 +293,32 @@ class _Roles(EnvConfig):
Roles = _Roles()
-class Tokens(NamedTuple):
- giphy = environ.get("GIPHY_TOKEN")
- aoc_session_cookie = environ.get("AOC_SESSION_COOKIE")
- omdb = environ.get("OMDB_API_KEY")
- youtube = environ.get("YOUTUBE_API_KEY")
- tmdb = environ.get("TMDB_API_KEY")
- nasa = environ.get("NASA_API_KEY")
- igdb_client_id = environ.get("IGDB_CLIENT_ID")
- igdb_client_secret = environ.get("IGDB_CLIENT_SECRET")
- github = environ.get("GITHUB_TOKEN")
- unsplash_access_key = environ.get("UNSPLASH_KEY")
+class _Tokens(EnvConfig):
+ EnvConfig.Config.env_prefix = "tokens_"
+
+ giphy = ""
+ aoc_session_cookie = ""
+ omdb = ""
+ youtube = ""
+ tmdb = ""
+ nasa = ""
+ igdb_client_id = ""
+ igdb_client_secret = ""
+ github = ""
+ unsplash = ""
+ wolfram = ""
+
+
+Tokens = _Tokens()
+
+
+class _Wolfram(EnvConfig):
+ EnvConfig.Config.env_prefix = "wolfram_"
+ user_limit_day = 10
+ guild_limit_day = 67
+
+
+Wolfram = _Wolfram()
class Wolfram(NamedTuple):
diff --git a/bot/exts/holidays/easter/earth_photos.py b/bot/exts/holidays/easter/earth_photos.py
index e60e2626..5008b24d 100644
--- a/bot/exts/holidays/easter/earth_photos.py
+++ b/bot/exts/holidays/easter/earth_photos.py
@@ -23,7 +23,7 @@ class EarthPhotos(commands.Cog):
async with ctx.typing():
async with self.bot.http_session.get(
API_URL,
- params={"query": "planet_earth", "client_id": Tokens.unsplash_access_key}
+ params={"query": "planet_earth", "client_id": Tokens.unsplash}
) as r:
jsondata = await r.json()
linksdata = jsondata.get("urls")
@@ -37,7 +37,7 @@ class EarthPhotos(commands.Cog):
rf = "?utm_source=Sir%20Lancebot&utm_medium=referral"
async with self.bot.http_session.get(
downloadlinksdata.get("download_location"),
- params={"client_id": Tokens.unsplash_access_key}
+ params={"client_id": Tokens.unsplash}
) as _:
pass
@@ -59,7 +59,7 @@ class EarthPhotos(commands.Cog):
async def setup(bot: Bot) -> None:
"""Load the Earth Photos cog."""
- if not Tokens.unsplash_access_key:
+ if not Tokens.unsplash:
log.warning("No Unsplash access key found. Cog not loading.")
return
await bot.add_cog(EarthPhotos(bot))
diff --git a/bot/exts/utilities/wolfram.py b/bot/exts/utilities/wolfram.py
index a2f1228a..7dc4d7c3 100644
--- a/bot/exts/utilities/wolfram.py
+++ b/bot/exts/utilities/wolfram.py
@@ -10,12 +10,12 @@ from discord.ext import commands
from discord.ext.commands import BucketType, Cog, Context, check, group
from bot.bot import Bot
-from bot.constants import Colours, STAFF_ROLES, Wolfram
+from bot.constants import Colours, STAFF_ROLES, Tokens, Wolfram
from bot.utils.pagination import ImagePaginator
log = logging.getLogger(__name__)
-APPID = Wolfram.key
+APPID = Tokens.wolfram
DEFAULT_OUTPUT_FORMAT = "JSON"
QUERY = "http://api.wolframalpha.com/v2/{request}"
WOLF_IMAGE = "https://www.symbols.com/gi.php?type=1&id=2886&i=1"