Farid Karimli
commited on
Commit
·
d6bff98
1
Parent(s):
6e8c4c9
No previous message bug fix
Browse files- apps/ai_tutor/helpers.py +7 -3
apps/ai_tutor/helpers.py
CHANGED
@@ -19,9 +19,13 @@ async def check_user_cooldown(
|
|
19 |
last_message_time_str = user_info["metadata"].get("last_message_time")
|
20 |
|
21 |
# Convert from ISO format string to datetime object and ensure UTC timezone
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
current_time = datetime.fromisoformat(current_time).replace(tzinfo=timezone.utc)
|
26 |
|
27 |
# Calculate the elapsed time
|
|
|
19 |
last_message_time_str = user_info["metadata"].get("last_message_time")
|
20 |
|
21 |
# Convert from ISO format string to datetime object and ensure UTC timezone
|
22 |
+
try:
|
23 |
+
last_message_time = datetime.fromisoformat(last_message_time_str).replace(
|
24 |
+
tzinfo=timezone.utc
|
25 |
+
)
|
26 |
+
except Exception as e: # this probably means the user has never sent a message before
|
27 |
+
return False, None
|
28 |
+
|
29 |
current_time = datetime.fromisoformat(current_time).replace(tzinfo=timezone.utc)
|
30 |
|
31 |
# Calculate the elapsed time
|