fix non-deactivating error
This commit is contained in:
parent
df33dcd00c
commit
c45c6992ae
8 changed files with 18 additions and 13 deletions
|
|
@ -7,7 +7,7 @@ autopilot - Enable or disable automatic applications. Usage: autopilot on or aut
|
|||
status - Show current status and statistics (autopilot state, application counts by company)
|
||||
plot - Show weekly listing patterns (image)
|
||||
errorrate - Show autopilot success vs failure plot (image)
|
||||
retryfailed - Retry all failed applications up to 3 times
|
||||
retryfailed - Retry all failed applications up to 3 times (excludes deactivated listings)
|
||||
resetlistings - Delete all seen listings (forces re-check of all flats, does not affect stats or WGcompany)
|
||||
help - Show help and command usage
|
||||
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ flowchart TD
|
|||
SelectHandler --> OpenPage[Open Listing Page]
|
||||
OpenPage --> Check404{404 or Deactivated?}
|
||||
|
||||
Check404 -- Yes --> MarkPermanent[Mark permanent_fail]
|
||||
Check404 -- Yes --> MarkPermanent[Mark deactivated]
|
||||
MarkPermanent --> SaveFail[Save to applications.json]
|
||||
SaveFail --> NotifyFail[Notify: Application Failed]
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@ class DegewoHandler(BaseHandler):
|
|||
logger.warning(f"[DEGEWO] Listing is down (404): {listing['link']}")
|
||||
result["success"] = False
|
||||
result["message"] = "Listing is no longer available (404). Application impossible. Will not retry."
|
||||
result["permanent_fail"] = True
|
||||
await page.close()
|
||||
result["deactivated"] = True
|
||||
return result
|
||||
|
||||
# Check for 'INSERAT DEAKTIVIERT' (deactivated listing)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class GesobauHandler(BaseHandler):
|
|||
logger.warning(f"[GESOBAU] Listing is down (404): {listing['link']}")
|
||||
result["success"] = False
|
||||
result["message"] = "Listing is no longer available (404). Application impossible. Will not retry."
|
||||
result["permanent_fail"] = True
|
||||
result["deactivated"] = True
|
||||
await page.close()
|
||||
return result
|
||||
|
||||
|
|
@ -34,9 +34,9 @@ class GesobauHandler(BaseHandler):
|
|||
await self.handle_cookies(page)
|
||||
await self.handle_consent(page)
|
||||
|
||||
# Save HTML after modal handling for debugging
|
||||
try:
|
||||
# Save HTML after modal handling for debugging and check for deactivation
|
||||
html_content = await page.content()
|
||||
try:
|
||||
with open(DATA_DIR / "gesobau_debug.html", "w", encoding="utf-8") as f:
|
||||
f.write(html_content)
|
||||
except Exception as e:
|
||||
|
|
@ -45,8 +45,9 @@ class GesobauHandler(BaseHandler):
|
|||
# Tailored 404 detection: Angebot nicht mehr verfügbar
|
||||
if "Angebot nicht mehr verfügbar" in html_content:
|
||||
logger.warning("[GESOBAU] Permanent fail: Angebot nicht mehr verfügbar")
|
||||
result["permanent_fail"] = True
|
||||
result["message"] = "Listing is no longer available (Angebot nicht mehr verfügbar). Marked as permanent fail."
|
||||
result["deactivated"] = True
|
||||
result["message"] = "Listing is no longer available (Angebot nicht mehr verfügbar). Marked as deactivated."
|
||||
await page.close()
|
||||
return result
|
||||
|
||||
# Look for application button
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class GewobagHandler(BaseHandler):
|
|||
logger.warning(f"[GEWOBAG] Listing is down (404): {listing['link']}")
|
||||
result["success"] = False
|
||||
result["message"] = "Listing is no longer available (404). Application impossible. Will not retry."
|
||||
result["permanent_fail"] = True
|
||||
result["deactivated"] = True
|
||||
return result
|
||||
|
||||
# Always handle cookies and consent before anything else
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class HowogeHandler(BaseHandler):
|
|||
logger.warning(f"[HOWOGE] Listing is down (404): {listing['link']}")
|
||||
result["success"] = False
|
||||
result["message"] = "Listing is no longer available (404). Application impossible. Will not retry."
|
||||
result["permanent_fail"] = True
|
||||
result["deactivated"] = True
|
||||
await page.close()
|
||||
return result
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class WBMHandler(BaseHandler):
|
|||
if page_text:
|
||||
for err in error_texts:
|
||||
if err in page_text:
|
||||
result["permanent_fail"] = True
|
||||
result["deactivated"] = True
|
||||
result["message"] = "Listing is no longer available (404 detected on WBM)."
|
||||
logger.warning(f"[WBM] Permanent fail: {err}")
|
||||
await page.close()
|
||||
|
|
|
|||
|
|
@ -168,7 +168,12 @@ class TelegramBot:
|
|||
for handler in self.app_handler.handlers.values():
|
||||
handler.context = self.app_handler.context
|
||||
applications = self.app_handler.load_applications()
|
||||
failed = [app for app in applications.values() if not app.get("success") and app.get("retries", 0) < max_retries]
|
||||
failed = [
|
||||
app for app in applications.values()
|
||||
if not app.get("success")
|
||||
and app.get("retries", 0) < max_retries
|
||||
and not app.get("deactivated", False)
|
||||
]
|
||||
await self._send_message(f"🔄 Retrying {len(failed)} failed applications (max retries: {max_retries})...")
|
||||
if not failed:
|
||||
await self._send_message("✅ No failed applications to retry (or all reached max retries).")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue