From 0e81321ff2be0e0c77d3f1b8cd63d6333ece7a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Sat, 27 Aug 2022 21:54:39 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=B7=BB=E5=8A=A0=E9=80=9F?= =?UTF-8?q?=E7=8E=87=E9=99=90=E5=88=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 461e6266..ecc9098d 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,7 @@ import asyncio from warnings import filterwarnings import pytz -from telegram.ext import Application, Defaults +from telegram.ext import Application, Defaults, AIORateLimiter from telegram.warnings import PTBUserWarning from config import config @@ -46,11 +46,13 @@ def main() -> None: Log.info("构建BOT") defaults = Defaults(tzinfo=pytz.timezone("Asia/Shanghai")) + rate_limiter = AIORateLimiter() - application = Application\ - .builder()\ - .token(config.bot_token)\ - .defaults(defaults)\ + application = Application \ + .builder() \ + .token(config.bot_token) \ + .defaults(defaults) \ + .rate_limiter(rate_limiter) \ .build() register_plugin_handlers(application)