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:
|
def parse_last_seen(text: str) -> datetime | None:
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
if "Visto por última vez" in text:
|
if "Visto por última vez" in text:
|
||||||
|
hours_match = re.search(r"(\d+) horas", text)
|
||||||
minutes_match = re.search(r"(\d+) minutos", text)
|
minutes_match = re.search(r"(\d+) minutos", text)
|
||||||
if not minutes_match:
|
if hours_match:
|
||||||
return None
|
hours_ago = int(hours_match.group(1))
|
||||||
|
return now - timedelta(hours=hours_ago)
|
||||||
|
if minutes_match:
|
||||||
minutes_ago = int(minutes_match.group(1))
|
minutes_ago = int(minutes_match.group(1))
|
||||||
return now - timedelta(minutes=minutes_ago)
|
return now - timedelta(minutes=minutes_ago)
|
||||||
if "online" in text.lower():
|
elif "online" in text.lower():
|
||||||
return now
|
return now
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user