bot initialization

pull/138/head
ZetGo | Aleksej K. 2025-05-22 20:26:01 +03:00
parent e2e888120d
commit 4af888e534
1 changed files with 8 additions and 8 deletions

View File

@ -21,6 +21,7 @@ import typing
from aiogram import Bot, Dispatcher from aiogram import Bot, Dispatcher
from aiogram.enums import ParseMode from aiogram.enums import ParseMode
from aiogram.exceptions import TelegramNetworkError, TelegramUnauthorizedError from aiogram.exceptions import TelegramNetworkError, TelegramUnauthorizedError
from aiogram.client.default import DefaultBotProperties
from herokutl.errors.rpcerrorlist import InputUserDeactivatedError, YouBlockedUserError from herokutl.errors.rpcerrorlist import InputUserDeactivatedError, YouBlockedUserError
from herokutl.tl.functions.contacts import UnblockRequest from herokutl.tl.functions.contacts import UnblockRequest
from herokutl.tl.types import Message from herokutl.tl.types import Message
@ -128,10 +129,9 @@ class InlineManager(
self.init_complete = True self.init_complete = True
self.bot = Bot(token=self._token, parse_mode=ParseMode.HTML) self.bot = Bot(token=self._token, default=DefaultBotProperties(parse_mode=ParseMode.HTML))
Bot.set_current(self.bot)
self._bot = self.bot self._bot = self.bot
self._dp = Dispatcher(self.bot) self._dp = Dispatcher()
try: try:
bot_me = await self.bot.get_me() bot_me = await self.bot.get_me()
@ -140,7 +140,7 @@ class InlineManager(
except TelegramUnauthorizedError: except TelegramUnauthorizedError:
logger.critical("Token expired, revoking...") logger.critical("Token expired, revoking...")
return await self._dp_revoke_token(False) return await self._dp_revoke_token(False)
logger.debug(f"Initialized {self.bot_username}")
try: try:
m = await self._client.send_message(self.bot_username, "/start heroku init") m = await self._client.send_message(self.bot_username, "/start heroku init")
except (InputUserDeactivatedError, ValueError): except (InputUserDeactivatedError, ValueError):
@ -168,22 +168,22 @@ class InlineManager(
await self._client.delete_messages(self.bot_username, m) await self._client.delete_messages(self.bot_username, m)
self._dp.register_inline_handler( self._dp.inline_query.register(
self._inline_handler, self._inline_handler,
lambda _: True, lambda _: True,
) )
self._dp.register_callback_query_handler( self._dp.callback_query.register(
self._callback_query_handler, self._callback_query_handler,
lambda _: True, lambda _: True,
) )
self._dp.register_chosen_inline_handler( self._dp.chosen_inline_result.register(
self._chosen_inline_handler, self._chosen_inline_handler,
lambda _: True, lambda _: True,
) )
self._dp.register_message_handler( self._dp.message.register(
self._message_handler, self._message_handler,
lambda *_: True, lambda *_: True,
content_types=["any"], content_types=["any"],