fix a bug

This commit is contained in:
xtaodada 2024-06-23 00:26:36 +08:00
parent 9aef99fd1a
commit b3b849e55b
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 4 additions and 0 deletions

View File

@ -199,6 +199,7 @@ class Application(Singleton):
if application_config.bot.is_webhook and application_config.webserver.enable:
await self.bot.set_webhook(application_config.bot.webhook_url)
else:
await self.bot.delete_webhook()
await self.telegram.updater.start_polling(
error_callback=error_callback, allowed_updates=Update.ALL_TYPES
)

View File

@ -60,6 +60,9 @@ class RateLimiter(BaseRateLimiter[int]):
await self._on_called_api(endpoint, data, result)
return result
except RetryAfter as exc:
if endpoint == "setWebhook" and exc.retry_after == 1:
# webhook 已被正确设置
return True
logger.warning("chat_id[%s] 触发洪水限制 当前被服务器限制 retry_after[%s]秒", chat_id, exc.retry_after)
self._limiter_info[chat_id] = time + (exc.retry_after * 2)
sleep = exc.retry_after + 0.1