aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Gallardo <[email protected]>2020-10-01 16:18:06 -0700
committerGravatar GitHub <[email protected]>2020-10-01 16:18:06 -0700
commit8060d2cba865b031fd909727bfd72407b54ce11b (patch)
tree2ab3b8e1961e0ca130d8cba87c7a73da076f3f0e
parentAdd Cog and add a couple responses (diff)
parentAuthenticate GitHub API requests for the Hacktoberfest issue finder. (diff)
Merge branch 'master' into save_the_planet
-rw-r--r--bot/exts/halloween/hacktober-issue-finder.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/bot/exts/halloween/hacktober-issue-finder.py b/bot/exts/halloween/hacktober-issue-finder.py
index b5ad1c4f..78acf391 100644
--- a/bot/exts/halloween/hacktober-issue-finder.py
+++ b/bot/exts/halloween/hacktober-issue-finder.py
@@ -7,13 +7,19 @@ import aiohttp
import discord
from discord.ext import commands
-from bot.constants import Month
+from bot.constants import Month, Tokens
from bot.utils.decorators import in_month
log = logging.getLogger(__name__)
URL = "https://api.github.com/search/issues?per_page=100&q=is:issue+label:hacktoberfest+language:python+state:open"
-HEADERS = {"Accept": "application / vnd.github.v3 + json"}
+
+REQUEST_HEADERS = {
+ "User-Agent": "Python Discord Hacktoberbot",
+ "Accept": "application / vnd.github.v3 + json"
+}
+if GITHUB_TOKEN := Tokens.github:
+ REQUEST_HEADERS["Authorization"] = f"token {GITHUB_TOKEN}"
class HacktoberIssues(commands.Cog):
@@ -66,7 +72,7 @@ class HacktoberIssues(commands.Cog):
url += f"&page={page}"
log.debug(f"making api request to url: {url}")
- async with session.get(url, headers=HEADERS) as response:
+ async with session.get(url, headers=REQUEST_HEADERS) as response:
if response.status != 200:
log.error(f"expected 200 status (got {response.status}) from the GitHub api.")
await ctx.send(f"ERROR: expected 200 status (got {response.status}) from the GitHub api.")