Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncation of comment body and changes to matching of comic numbers #26

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,14 @@ def handle_comment(self, comment, strict_match=True):
return

comment_id = comment.id
body = comment.body
body = comment.body[:5_000]
comic_ids = self.match_numbers(body, strict_match)
comic_titles = self.match_titles(body)
responses = []

for comic_id in comic_ids:
if len(responses) > RESPONSE_COUNT_LIMIT:
logger.warning(
f"Exceeded the reponse count limit of {RESPONSE_COUNT_LIMIT} responses")
logger.warning(f"Exceeded the reponse count limit of {RESPONSE_COUNT_LIMIT} responses")
break

comic = self.get_comic(comic_id)
Expand All @@ -126,8 +125,7 @@ def handle_comment(self, comment, strict_match=True):
seen = set()
for comic_title in comic_titles:
if len(responses) > RESPONSE_COUNT_LIMIT:
logger.warning(
f"Exceeded the reponse count limit of {RESPONSE_COUNT_LIMIT} responses")
logger.warning(f"Exceeded the reponse count limit of {RESPONSE_COUNT_LIMIT} responses")
break

comic = self.get_comic_by_title(comic_title)
Expand Down Expand Up @@ -267,7 +265,7 @@ def remove_duplicates(numbers):

def get_range_numbers(body, strict_match):
"""Matches all comic id ranges and returns a list of all the numbers in those ranges."""
ranges = self.match_token(r"\d+\.{3}\d+", body, strict_match)
ranges = self.match_token(r"\d{1,6}\.{3}\d{1,6}", body, strict_match)

ret = []
for range_ in ranges:
Expand All @@ -288,7 +286,7 @@ def get_range_numbers(body, strict_match):

return ret

numbers = self.match_token(r"\d+", body, strict_match)
numbers = self.match_token(r"\d{1,6}", body, strict_match)
numbers.extend(get_range_numbers(body, strict_match))
stripped_numbers = strip_leading_zeroes(numbers)

Expand Down