msg Tweaks

This commit is contained in:
lda
2026-05-13 22:03:31 +07:00 Verified
parent c22b4f6952
commit cf57fcadd3
+20 -10
View File
@@ -1,7 +1,8 @@
import os
from pathlib import Path
import random
import time
from typing import TYPE_CHECKING, cast
from typing import TYPE_CHECKING
from playwright.sync_api import (
sync_playwright,
@@ -28,13 +29,15 @@ def launch_context(p, *, headless: bool):
)
def print_and_notif(msg: str, title: str = "Endfield Login"):
def print_and_notif(msg: str, title: str = "Login"):
print(f"{title}: {msg}")
appname = "lda's ef sign-in helper"
# big Windows will disregard the app_name. Format the title instead
wintitle = f"{appname}: {title}"
notification.notify(
title=title,
title=wintitle if os.name == "nt" else title,
message=msg,
app_name="lda's Endfield Login", # this shit doesnt work! always "python"
app_name=appname, # big Windows will not care
ticker=msg,
timeout=5,
)
@@ -57,6 +60,8 @@ def main():
if login_form.first.is_visible():
print_and_notif(
"Please log in manually, then close the browser window."
" You have 4 minutes.",
title="Manual Login Required",
)
context.close()
@@ -72,10 +77,13 @@ def main():
timeout=LOGIN_TIMEOUT_MS,
)
print_and_notif("Browser closed. Please rerun the script.")
print_and_notif("Browser closed. Please rerun the script.", title="Browser Closed")
except PlaywrightTimeoutError:
print_and_notif("Login timeout reached.")
print_and_notif(
"Login timeout reached. Please rerun the script.",
title="Login Timeout",
)
headful.close()
break
@@ -88,7 +96,7 @@ def main():
delay=random.randint(100, 300),
)
print_and_notif("Login successful.")
print_and_notif("Claimed successfully.", title="Success")
break
except (PlaywrightTimeoutError, PlaywrightError) as e:
@@ -98,7 +106,9 @@ def main():
"intercepts pointer events" in msg
and "completed-overlay" in msg
):
print_and_notif("Work already completed elsewhere.")
print_and_notif(
"Work already completed elsewhere.", title="Already Claimed"
)
break
raise # re-raise other exceptions
@@ -107,7 +117,7 @@ def main():
try:
context.close()
except:
except PlaywrightError: # ignore if already closed
pass