diff options
author | 2021-04-05 16:43:28 +0200 | |
---|---|---|
committer | 2021-04-05 16:43:28 +0200 | |
commit | 0e2422f7caaec73fbee9708c507d9be23635dd78 (patch) | |
tree | ee0baf66c59ca92686675c57d581bd1ce53ec00b /bot/exts/evergreen/issues.py | |
parent | Issues: remove duplicates (diff) |
Issues: limit results to 5
Diffstat (limited to 'bot/exts/evergreen/issues.py')
-rw-r--r-- | bot/exts/evergreen/issues.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/bot/exts/evergreen/issues.py b/bot/exts/evergreen/issues.py index d7e29a90..afaa7012 100644 --- a/bot/exts/evergreen/issues.py +++ b/bot/exts/evergreen/issues.py @@ -15,8 +15,6 @@ BAD_RESPONSE = { 404: "Issue/pull request not located! Please enter a valid number!", 403: "Rate limit has been hit! Please try again later!" } - -MAX_REQUESTS = 10 REQUEST_HEADERS = dict() REPOS_API = "https://api.github.com/orgs/{org}/repos" @@ -33,6 +31,9 @@ CODE_BLOCK_RE = re.compile( re.DOTALL | re.MULTILINE ) +# Maximum number of issues in one message +MAXIMUM_ISSUES = 5 + class FetchIssueErrors(Enum): """Errors returned in fetch issues.""" @@ -83,7 +84,7 @@ class Issues(commands.Cog): if not numbers: return FetchIssueErrors.value_error - if len(numbers) > MAX_REQUESTS: + if len(numbers) > MAXIMUM_ISSUES: return FetchIssueErrors.max_requests for number in numbers: @@ -162,7 +163,7 @@ class Issues(commands.Cog): embed = discord.Embed( title=random.choice(ERROR_REPLIES), color=Colours.soft_red, - description=f"Too many issues/PRs! (maximum of {MAX_REQUESTS})" + description=f"Too many issues/PRs! (maximum of {MAXIMUM_ISSUES})" ) await ctx.send(embed=embed) @@ -184,6 +185,15 @@ class Issues(commands.Cog): # Remove duplicates message_repo_issue_map = set(message_repo_issue_map) + if len(message_repo_issue_map) > MAXIMUM_ISSUES: + embed = discord.Embed( + title=random.choice(ERROR_REPLIES), + color=Colours.soft_red, + description=f"Too many issues/PRs! (maximum of {MAXIMUM_ISSUES})" + ) + await message.channel.send(embed=embed) + return + for repo_issue in message_repo_issue_map: if not self.check_in_block(message, " ".join(repo_issue)): result = await self.fetch_issues({repo_issue[1]}, repo_issue[0], "python-discord") |