fix non-deactivating error

This commit is contained in:
Aron Petau 2026-01-01 22:14:55 +01:00
parent df33dcd00c
commit c45c6992ae
8 changed files with 18 additions and 13 deletions

View file

@ -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) status - Show current status and statistics (autopilot state, application counts by company)
plot - Show weekly listing patterns (image) plot - Show weekly listing patterns (image)
errorrate - Show autopilot success vs failure plot (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) resetlistings - Delete all seen listings (forces re-check of all flats, does not affect stats or WGcompany)
help - Show help and command usage help - Show help and command usage

View file

@ -272,7 +272,7 @@ flowchart TD
SelectHandler --> OpenPage[Open Listing Page] SelectHandler --> OpenPage[Open Listing Page]
OpenPage --> Check404{404 or Deactivated?} OpenPage --> Check404{404 or Deactivated?}
Check404 -- Yes --> MarkPermanent[Mark permanent_fail] Check404 -- Yes --> MarkPermanent[Mark deactivated]
MarkPermanent --> SaveFail[Save to applications.json] MarkPermanent --> SaveFail[Save to applications.json]
SaveFail --> NotifyFail[Notify: Application Failed] SaveFail --> NotifyFail[Notify: Application Failed]

View file

@ -29,8 +29,7 @@ class DegewoHandler(BaseHandler):
logger.warning(f"[DEGEWO] Listing is down (404): {listing['link']}") logger.warning(f"[DEGEWO] Listing is down (404): {listing['link']}")
result["success"] = False result["success"] = False
result["message"] = "Listing is no longer available (404). Application impossible. Will not retry." 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 return result
# Check for 'INSERAT DEAKTIVIERT' (deactivated listing) # Check for 'INSERAT DEAKTIVIERT' (deactivated listing)

View file

@ -26,7 +26,7 @@ class GesobauHandler(BaseHandler):
logger.warning(f"[GESOBAU] Listing is down (404): {listing['link']}") logger.warning(f"[GESOBAU] Listing is down (404): {listing['link']}")
result["success"] = False result["success"] = False
result["message"] = "Listing is no longer available (404). Application impossible. Will not retry." result["message"] = "Listing is no longer available (404). Application impossible. Will not retry."
result["permanent_fail"] = True result["deactivated"] = True
await page.close() await page.close()
return result return result
@ -34,9 +34,9 @@ class GesobauHandler(BaseHandler):
await self.handle_cookies(page) await self.handle_cookies(page)
await self.handle_consent(page) await self.handle_consent(page)
# Save HTML after modal handling for debugging # Save HTML after modal handling for debugging and check for deactivation
html_content = await page.content()
try: try:
html_content = await page.content()
with open(DATA_DIR / "gesobau_debug.html", "w", encoding="utf-8") as f: with open(DATA_DIR / "gesobau_debug.html", "w", encoding="utf-8") as f:
f.write(html_content) f.write(html_content)
except Exception as e: except Exception as e:
@ -45,8 +45,9 @@ class GesobauHandler(BaseHandler):
# Tailored 404 detection: Angebot nicht mehr verfügbar # Tailored 404 detection: Angebot nicht mehr verfügbar
if "Angebot nicht mehr verfügbar" in html_content: if "Angebot nicht mehr verfügbar" in html_content:
logger.warning("[GESOBAU] Permanent fail: Angebot nicht mehr verfügbar") logger.warning("[GESOBAU] Permanent fail: Angebot nicht mehr verfügbar")
result["permanent_fail"] = True result["deactivated"] = True
result["message"] = "Listing is no longer available (Angebot nicht mehr verfügbar). Marked as permanent fail." result["message"] = "Listing is no longer available (Angebot nicht mehr verfügbar). Marked as deactivated."
await page.close()
return result return result
# Look for application button # Look for application button

View file

@ -26,7 +26,7 @@ class GewobagHandler(BaseHandler):
logger.warning(f"[GEWOBAG] Listing is down (404): {listing['link']}") logger.warning(f"[GEWOBAG] Listing is down (404): {listing['link']}")
result["success"] = False result["success"] = False
result["message"] = "Listing is no longer available (404). Application impossible. Will not retry." result["message"] = "Listing is no longer available (404). Application impossible. Will not retry."
result["permanent_fail"] = True result["deactivated"] = True
return result return result
# Always handle cookies and consent before anything else # Always handle cookies and consent before anything else

View file

@ -27,7 +27,7 @@ class HowogeHandler(BaseHandler):
logger.warning(f"[HOWOGE] Listing is down (404): {listing['link']}") logger.warning(f"[HOWOGE] Listing is down (404): {listing['link']}")
result["success"] = False result["success"] = False
result["message"] = "Listing is no longer available (404). Application impossible. Will not retry." result["message"] = "Listing is no longer available (404). Application impossible. Will not retry."
result["permanent_fail"] = True result["deactivated"] = True
await page.close() await page.close()
return result return result

View file

@ -43,7 +43,7 @@ class WBMHandler(BaseHandler):
if page_text: if page_text:
for err in error_texts: for err in error_texts:
if err in page_text: if err in page_text:
result["permanent_fail"] = True result["deactivated"] = True
result["message"] = "Listing is no longer available (404 detected on WBM)." result["message"] = "Listing is no longer available (404 detected on WBM)."
logger.warning(f"[WBM] Permanent fail: {err}") logger.warning(f"[WBM] Permanent fail: {err}")
await page.close() await page.close()

View file

@ -168,7 +168,12 @@ class TelegramBot:
for handler in self.app_handler.handlers.values(): for handler in self.app_handler.handlers.values():
handler.context = self.app_handler.context handler.context = self.app_handler.context
applications = self.app_handler.load_applications() 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})...") await self._send_message(f"🔄 Retrying {len(failed)} failed applications (max retries: {max_retries})...")
if not failed: if not failed:
await self._send_message("✅ No failed applications to retry (or all reached max retries).") await self._send_message("✅ No failed applications to retry (or all reached max retries).")