Skip to content

Commit

Permalink
add safety check
Browse files Browse the repository at this point in the history
  • Loading branch information
itsthejoker committed Aug 19, 2022
1 parent 0910bf9 commit 881c4e3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions bubbles/commands/periodic/transcription_check_ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,9 @@ def _get_check_username(message: Dict) -> Optional[str]:
:returns: The username, or None if it couldn't be found.
"""
text = _extract_check_text(message)
try:
username_match = USERNAME_REGEX.search(text)
return username_match.group("username") if username_match else None
except TypeError:
print(f"Could not parse username. Value of `text`: {text}")

username_match = USERNAME_REGEX.search(text)
return username_match.group("username") if username_match else None


def _get_check_status(message: Dict) -> Tuple[CheckStatus, Optional[str]]:
Expand Down Expand Up @@ -158,6 +156,7 @@ def _get_check_time(message: Dict) -> datetime:

def _get_check_data(message: Dict) -> CheckData:
"""Extract the data from a given check message."""

user = _get_check_username(message)
status, mod = _get_check_status(message)
link = _get_check_link(message)
Expand All @@ -184,6 +183,10 @@ def _extract_open_checks(messages: List[Dict]) -> List[CheckData]:
if not _is_check_message(message):
continue

# sanity check, make sure the message is valid
if not _extract_check_text(message):
continue

check = _get_check_data(message)

# We don't need to handle resolved checks
Expand Down

0 comments on commit 881c4e3

Please sign in to comment.