From a29412b4dad116c938855f17d3c6c429bedf6709 Mon Sep 17 00:00:00 2001 From: Aron Date: Thu, 25 Dec 2025 20:53:10 +0100 Subject: [PATCH] msg redesign --- monitor.py | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/monitor.py b/monitor.py index 27d6d57..b29dd55 100644 --- a/monitor.py +++ b/monitor.py @@ -513,10 +513,43 @@ Total listings tracked: {total_listings} return "" self._send_message(f"❓ Unknown command: {cmd}\n\nUse /help to see available commands.") - def _send_message(self, text): + def _send_message(self, text, company=None, auto_applied=None, details=None): + """ + Redesigned Telegram message format. + + Args: + text (str): The main message text. + company (str): The company name (e.g., Howoge, WGCompany). + auto_applied (bool): Whether auto-apply was successful. + details (dict): Additional details about the listing. + """ try: + # Construct the new message format + title = f"[{company}] " + title += "✅ Auto-applied!" if auto_applied else "❌ Auto-apply failed." + + # Add details if provided + if details: + details_text = "\n".join([ + f"🚪 {details.get('rooms', 'N/A')} Zimmer", + f"📐 {details.get('size', 'N/A')} m²", + f"💰 {details.get('price', 'N/A')} €", + f"📍 {details.get('address', 'N/A')}" + ]) + else: + details_text = "" + + # Combine title, details, and additional text + message = f"{title}\n\n{details_text}\n\n{text}" + + # Send the message via Telegram url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage" - data = {"chat_id": TELEGRAM_CHAT_ID, "text": text, "parse_mode": "HTML", "disable_web_page_preview": True} + data = { + "chat_id": TELEGRAM_CHAT_ID, + "text": message, + "parse_mode": "HTML", + "disable_web_page_preview": True + } requests.post(url, data=data) except Exception as e: logger.error(f"Failed to send Telegram message: {e}")