diff --git a/tuhmayto/tracker.py b/tuhmayto/tracker.py index c68d649..0792673 100644 --- a/tuhmayto/tracker.py +++ b/tuhmayto/tracker.py @@ -33,12 +33,15 @@ def log_activity(timestamp: str) -> None: def parse_last_seen(text: str) -> datetime | None: now = datetime.now() if "Visto por Ășltima vez" in text: + hours_match = re.search(r"(\d+) horas", text) minutes_match = re.search(r"(\d+) minutos", text) - if not minutes_match: - return None - minutes_ago = int(minutes_match.group(1)) - return now - timedelta(minutes=minutes_ago) - if "online" in text.lower(): + if hours_match: + hours_ago = int(hours_match.group(1)) + return now - timedelta(hours=hours_ago) + if minutes_match: + minutes_ago = int(minutes_match.group(1)) + return now - timedelta(minutes=minutes_ago) + elif "online" in text.lower(): return now return None