diff options
| author | 2020-10-10 09:43:12 +0300 | |
|---|---|---|
| committer | 2020-10-10 09:43:12 +0300 | |
| commit | 24072097a284fb188f1e47c4646c6ed645201158 (patch) | |
| tree | 3039a1a297e596fe8c537c579919ad3a2f4d4326 /bot/exts/halloween/hacktober-issue-finder.py | |
| parent | Tictactoe: Fix docstrings formatting (diff) | |
| parent | PR #492: Fix & improve snake video command (diff) | |
Merge branch 'master' into tic-tac-toe
Diffstat (limited to 'bot/exts/halloween/hacktober-issue-finder.py')
| -rw-r--r-- | bot/exts/halloween/hacktober-issue-finder.py | 14 | 
1 files changed, 10 insertions, 4 deletions
| diff --git a/bot/exts/halloween/hacktober-issue-finder.py b/bot/exts/halloween/hacktober-issue-finder.py index b5ad1c4f..9deadde9 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.") @@ -97,7 +103,7 @@ class HacktoberIssues(commands.Cog):          labels = [label["name"] for label in issue["labels"]]          embed = discord.Embed(title=title) -        embed.description = body +        embed.description = body[:500] + '...' if len(body) > 500 else body          embed.add_field(name="labels", value="\n".join(labels))          embed.url = issue_url          embed.set_footer(text=issue_url) | 
