From 0bd59ddb4a8dcd14964cbfdd1c1f17035ef2a388 Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 28 Jul 2025 01:12:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=BF=D0=B8=D1=81=D0=BA?= =?UTF-8?q?=D0=B8=20Webhook=20=D0=BF=D1=80=D0=B8=20start=5Fpolling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maxapi/dispatcher.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/maxapi/dispatcher.py b/maxapi/dispatcher.py index 5d5cd29..ce5403c 100644 --- a/maxapi/dispatcher.py +++ b/maxapi/dispatcher.py @@ -75,6 +75,7 @@ class Dispatcher: self.bot: Optional[Bot] = None self.webhook_app: Optional[FastAPI] = None self.on_started_func: Optional[Callable] = None + self.polling = False self.message_created = Event(update_type=UpdateType.MESSAGE_CREATED, router=self) self.bot_added = Event(update_type=UpdateType.BOT_ADDED, router=self) @@ -153,6 +154,13 @@ class Dispatcher: self.bot = bot + if self.polling and self.bot.auto_check_subscriptions: + response = await self.bot.get_subscriptions() + + if response.subscriptions: + logger_subscriptions_text = ', '.join([s.url for s in response.subscriptions]) + logger_dp.warning('БОТ ИГНОРИРУЕТ POLLING! Обнаружены установленные подписки: %s', logger_subscriptions_text) + await self.check_me() self.routers += [self] @@ -271,12 +279,14 @@ class Dispatcher: :param bot: Экземпляр бота. """ + self.polling = True + await self.__ready(bot) + + if self.bot is None: + raise RuntimeError('Bot не инициализирован') - while True: - - if self.bot is None: - raise RuntimeError('Bot не инициализирован') + while self.polling: try: events: Dict = await self.bot.get_updates()