mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
feat(telegram): support custom base_url for credential proxy
When extra.base_url is set in the Telegram platform config, use it as the base URL for all Telegram API requests instead of api.telegram.org. This allows agents to route Telegram traffic through the credential proxy, which injects the real bot token — the VM never sees it. Also supports extra.base_file_url for file downloads (defaults to base_url if not set separately). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2629927032
commit
e376a9b2c9
1 changed files with 10 additions and 1 deletions
|
|
@ -518,6 +518,16 @@ class TelegramAdapter(BasePlatformAdapter):
|
|||
|
||||
# Build the application
|
||||
builder = Application.builder().token(self.config.token)
|
||||
custom_base_url = self.config.extra.get("base_url")
|
||||
if custom_base_url:
|
||||
builder = builder.base_url(custom_base_url)
|
||||
builder = builder.base_file_url(
|
||||
self.config.extra.get("base_file_url", custom_base_url)
|
||||
)
|
||||
logger.info(
|
||||
"[%s] Using custom Telegram base_url: %s",
|
||||
self.name, custom_base_url,
|
||||
)
|
||||
|
||||
# PTB defaults (pool_timeout=1s) are too aggressive on flaky networks and
|
||||
# can trigger "Pool timeout: All connections in the connection pool are occupied"
|
||||
|
|
@ -547,7 +557,6 @@ class TelegramAdapter(BasePlatformAdapter):
|
|||
for k in ("HTTPS_PROXY", "HTTP_PROXY", "ALL_PROXY", "https_proxy", "http_proxy", "all_proxy")
|
||||
)
|
||||
disable_fallback = (os.getenv("HERMES_TELEGRAM_DISABLE_FALLBACK_IPS", "").strip().lower() in ("1", "true", "yes", "on"))
|
||||
|
||||
fallback_ips = self._fallback_ips()
|
||||
if not fallback_ips:
|
||||
fallback_ips = await discover_fallback_ips()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue