- Attempt a different time pattern if failing first

This commit is contained in:
trigg 2021-10-18 19:50:31 +01:00
parent 5d5a2e0e9c
commit da08e30fa9

View file

@ -150,8 +150,15 @@ class DiscordConnector:
"""
Add line of text to text list. Assumes the message is from the correct room
"""
utc_time = time.strptime(
message["timestamp"], "%Y-%m-%dT%H:%M:%S.%f%z")
utc_time = None
try:
utc_time = time.strptime(
message["timestamp"], "%Y-%m-%dT%H:%M:%S.%f%z")
except ValueError:
utc_time = time.strptime(
message["timestamp"], "%Y-%m-%dT%H:%M:%S%z")
epoch_time = calendar.timegm(utc_time)
username = message["author"]["username"]
if("nick" in message and message['nick'] and len(message["nick"]) > 1