@@ -82,7 +82,7 @@ def __init__(
8282 self .base_url = config .data .get (CONF_URL ) or get_url (
8383 hass , require_ssl = True , allow_internal = False
8484 )
85- self .webhook_url = f" { self .base_url } { TELEGRAM_WEBHOOK_URL } "
85+ self .webhook_url = self .base_url + _get_webhook_url ( bot )
8686
8787 async def shutdown (self ) -> None :
8888 """Shutdown the app."""
@@ -98,9 +98,11 @@ async def _try_to_set_webhook(self) -> bool:
9898 api_kwargs = {"secret_token" : self .secret_token },
9999 connect_timeout = 5 ,
100100 )
101- except TelegramError :
101+ except TelegramError as err :
102102 retry_num += 1
103- _LOGGER .warning ("Error trying to set webhook (retry #%d)" , retry_num )
103+ _LOGGER .warning (
104+ "Error trying to set webhook (retry #%d)" , retry_num , exc_info = err
105+ )
104106
105107 return False
106108
@@ -143,7 +145,6 @@ class PushBotView(HomeAssistantView):
143145 """View for handling webhook calls from Telegram."""
144146
145147 requires_auth = False
146- url = TELEGRAM_WEBHOOK_URL
147148 name = "telegram_webhooks"
148149
149150 def __init__ (
@@ -160,6 +161,7 @@ def __init__(
160161 self .application = application
161162 self .trusted_networks = trusted_networks
162163 self .secret_token = secret_token
164+ self .url = _get_webhook_url (bot )
163165
164166 async def post (self , request : HomeAssistantRequest ) -> Response | None :
165167 """Accept the POST from telegram."""
@@ -183,3 +185,7 @@ async def post(self, request: HomeAssistantRequest) -> Response | None:
183185 await self .application .process_update (update )
184186
185187 return None
188+
189+
190+ def _get_webhook_url (bot : Bot ) -> str :
191+ return f"{ TELEGRAM_WEBHOOK_URL } _{ bot .id } "
0 commit comments