Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions scripts/telegram_bot_handle_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
if TOKEN:
TOKEN = TOKEN.strip()

if (
API_URL := pyscript.config.get("telegram_bot_api_url") # noqa: F821 # ty:ignore[unresolved-reference]
or "https://api.telegram.org"
):
API_URL = API_URL.strip().rstrip("/")
API_URL = "https://api.telegram.org"

_session: httpx.AsyncClient | None = None
_session_lock = asyncio.Lock()
Expand Down Expand Up @@ -132,11 +128,7 @@ async def _get_file(client: httpx.AsyncClient, file_id: str) -> tuple[str | None
if not resp.is_success or not result.get("ok"):
description = result.get("description") or resp.reason_phrase or f"HTTP {resp.status_code}"
if "file is too big" in description.lower():
return (
None,
f"File size exceeds Telegram Bot API 20MB download limit for public servers ({description}). "
"To download files up to 2GB, configure a local Telegram Bot API server via 'telegram_bot_api_url'.",
)
return (None, f"File size exceeds Telegram Bot API 20MB download limit for public servers ({description}).")
return None, f"Telegram API error ({resp.status_code}): {description}"
if file_path := result.get("result", {}).get("file_path"):
return file_path, None
Expand Down
1 change: 0 additions & 1 deletion send_to_telegram_full_llm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ blueprint:
allow_all_imports: true
hass_is_global: true
telegram_bot_token: !secret telegram_bot_token
telegram_bot_api_url: http://localhost:8081 # Optional: local Telegram Bot API server for downloading/uploading files up to 2GB
```

```
Expand Down
1 change: 0 additions & 1 deletion telegram_bot_webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ blueprint:
allow_all_imports: true
hass_is_global: true
telegram_bot_token: !secret telegram_bot_token
telegram_bot_api_url: http://localhost:8081 # Optional: local Telegram Bot API server for downloading/uploading files up to 2GB
```

```
Expand Down