feat: geo location as Google Maps link in Telegram notifications
When signal has geo, show clickable Google Maps link instead of raw coordinates. Without geo, show "Гео нету". Added parse_mode=HTML to send_message for link rendering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
04f7bd79e2
commit
47b89ded8d
4 changed files with 8 additions and 8 deletions
|
|
@ -223,9 +223,9 @@ async def signal(
|
|||
|
||||
ts = datetime.fromtimestamp(body.timestamp / 1000, tz=timezone.utc)
|
||||
geo_info = (
|
||||
f"📍 {lat}, {lon} (±{accuracy}м)"
|
||||
f"📍 <a href=\"https://maps.google.com/maps?q={lat},{lon}\">{lat}, {lon}</a> (±{accuracy:.0f}м)"
|
||||
if geo
|
||||
else "Без геолокации"
|
||||
else "Гео нету"
|
||||
)
|
||||
text = (
|
||||
f"🚨 Сигнал от {user_name}\n"
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ async def send_message(text: str) -> None:
|
|||
url = _TELEGRAM_API.format(token=config.BOT_TOKEN, method="sendMessage")
|
||||
async with httpx.AsyncClient(timeout=10) as client:
|
||||
for attempt in range(3):
|
||||
resp = await client.post(url, json={"chat_id": config.CHAT_ID, "text": text})
|
||||
resp = await client.post(url, json={"chat_id": config.CHAT_ID, "text": text, "parse_mode": "HTML"})
|
||||
if resp.status_code == 429:
|
||||
retry_after = resp.json().get("parameters", {}).get("retry_after", 30)
|
||||
sleep = retry_after * (attempt + 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue