Skip to content

Commit

Permalink
Update message.py (#173)
Browse files Browse the repository at this point in the history
Fixed bug that was causing TypeScript errors for Time Stamps
  • Loading branch information
MuratDoganer authored Dec 16, 2023
1 parent 2af14e4 commit 887b81a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions slackviewer/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ def username(self):

@property
def time(self):
# Handle this: "ts": "1456427378.000002"
tsepoch = float(self._message["ts"].split(".")[0])
return str(datetime.datetime.fromtimestamp(tsepoch)).split('.')[0]
# Check if 'ts' key exists in the dictionary
if "ts" in self._message:
# Handle this: "ts": "1456427378.000002"
tsepoch = float(self._message["ts"].split(".")[0])
return str(datetime.datetime.fromtimestamp(tsepoch)).split('.')[0]
else:
return None # or return a suitable default value

@property
def attachments(self):
Expand Down

0 comments on commit 887b81a

Please sign in to comment.