diff --git a/application_handler.py b/application_handler.py
index 65f3d83..4721c40 100644
--- a/application_handler.py
+++ b/application_handler.py
@@ -67,34 +67,40 @@ class ApplicationHandler:
Send a Telegram notification for each new listing.
Includes application result if autopilot was enabled.
"""
- if not new_listings:
- return
-
for listing in new_listings:
link = listing.get('link', 'https://www.inberlinwohnen.de/wohnungsfinder/')
- # Detect company for header
company = self._detect_company(link)
+ if company == "wgcompany":
+ continue # skip WGCompany listings for main handler
company_label = company.capitalize() if company != "unknown" else "Wohnung"
message = (
- f"š [{company_label}] Neue Wohnung!\n\n"
- f"šŖ {listing['rooms']}\n"
- f"š {listing['size']}\n"
- f"š° {listing['price']}\n"
- f"š {listing['address']}\n\n"
- f"š Alle Details"
+ f"\ud83c\udfe0 [{company_label}] Neue Wohnung!\n\n"
+ f"\ud83d\udeaa {listing['rooms']}\n"
+ f"\ud83d\udcd0 {listing['size']}\n"
+ f"\ud83d\udcb0 {listing['price']}\n"
+ f"\ud83d\udccd {listing['address']}\n\n"
+ f"\ud83d\udc49 Alle Details"
)
- # Add autopilot/apply status if attempted
- if application_results and listing["id"] in application_results:
- result = application_results[listing["id"]]
- if result["success"]:
- message += f"\n\nš¤ Auto-applied! ({result['company']})"
- if result["message"]:
- message += f"\n{result['message']}"
+ # Always show autopilot/apply status for clarity
+ if application_results is not None:
+ if listing["id"] in application_results:
+ result = application_results[listing["id"]]
+ if result["success"]:
+ message += f"\n\n\ud83e\udd16 Auto-applied! ({result['company']})"
+ if result["message"]:
+ message += f"\n{result['message']}"
+ else:
+ # Handler attempted but failed
+ fail_msg = result.get("message") or "Unknown error during application."
+ message += f"\n\n\u26a0\ufe0f Auto-apply failed ({result['company']})"
+ message += f"\nReason: {html.escape(fail_msg)}"
else:
- message += f"\n\nā ļø Auto-apply failed ({result['company']})"
- if result["message"]:
- message += f"\n{result['message']}"
+ # Should not happen if logic is correct, but fallback
+ message += "\n\n\u2139\ufe0f No application attempted (internal logic error)"
+ else:
+ # Autopilot was off or not attempted at all
+ message += "\n\n\u2139\ufe0f No application attempted (autopilot off)"
# Send via TelegramBot if available
if hasattr(self, 'telegram_bot') and self.telegram_bot:
@@ -102,6 +108,9 @@ class ApplicationHandler:
self.telegram_bot._send_message(message)
else:
logger.info(f"[TELEGRAM] Would send message for: {listing['address']} ({listing['rooms']}, {listing['size']}, {listing['price']})")
+ self.telegram_bot._send_message(message)
+ else:
+ logger.info(f"[TELEGRAM] Would send message for: {listing['address']} ({listing['rooms']}, {listing['size']}, {listing['price']})")
async def apply_to_listings(self, listings: list[dict]) -> dict:
"""