msg redesign
This commit is contained in:
parent
d33b6c4226
commit
a29412b4da
1 changed files with 35 additions and 2 deletions
37
monitor.py
37
monitor.py
|
|
@ -513,10 +513,43 @@ Total listings tracked: {total_listings}
|
|||
return ""
|
||||
self._send_message(f"❓ Unknown command: <code>{cmd}</code>\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}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue