aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/halloween/hacktober-issue-finder.py
diff options
context:
space:
mode:
authorGravatar Matteo Bertucci <[email protected]>2020-10-04 10:03:40 +0200
committerGravatar GitHub <[email protected]>2020-10-04 10:03:40 +0200
commit55aca971dc543545093eef8be08ee83bb5390ec8 (patch)
tree0cd5fcefec85d30723e9ce0c2820d651474ba897 /bot/exts/halloween/hacktober-issue-finder.py
parentcleaned the code (diff)
parentMerge pull request #455 from Anubhav1603/partnerzodiac (diff)
Merge branch 'master' into ec
Diffstat (limited to 'bot/exts/halloween/hacktober-issue-finder.py')
-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.")