trakcer now calculates offline hours
This commit is contained in:
parent
029e596dbc
commit
bae08a3a92
@ -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
|
||||
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)
|
||||
if "online" in text.lower():
|
||||
elif "online" in text.lower():
|
||||
return now
|
||||
return None
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user