diff options
Diffstat (limited to '')
| -rw-r--r-- | bot/exts/utils/pep.py | 10 | 
1 files changed, 9 insertions, 1 deletions
| diff --git a/bot/exts/utils/pep.py b/bot/exts/utils/pep.py index d642c902a..df9ad2ba9 100644 --- a/bot/exts/utils/pep.py +++ b/bot/exts/utils/pep.py @@ -8,6 +8,7 @@ from discord import Colour, Embed  from discord.ext.commands import Cog, Context, command  from bot.bot import Bot +from bot.constants import Keys  from bot.utils.cache import AsyncCache  log = logging.getLogger(__name__) @@ -16,6 +17,10 @@ ICON_URL = "https://www.python.org/static/opengraph-icon-200x200.png"  pep_cache = AsyncCache() +GITHUB_API_HEADERS = {} +if Keys.github: +    GITHUB_API_HEADERS["Authorization"] = f"token {Keys.github}" +  class PythonEnhancementProposals(Cog):      """Cog for displaying information about PEPs.""" @@ -38,7 +43,10 @@ class PythonEnhancementProposals(Cog):          log.trace("Started refreshing PEP URLs.")          self.last_refreshed_peps = datetime.now() -        async with self.bot.http_session.get(self.PEPS_LISTING_API_URL) as resp: +        async with self.bot.http_session.get( +            self.PEPS_LISTING_API_URL, +            headers=GITHUB_API_HEADERS +        ) as resp:              if resp.status != 200:                  log.warning(f"Fetching PEP URLs from GitHub API failed with code {resp.status}")                  return | 
