diff --git a/hikka/inline/gallery.py b/hikka/inline/gallery.py index c3033a5..abaa4ce 100644 --- a/hikka/inline/gallery.py +++ b/hikka/inline/gallery.py @@ -24,7 +24,7 @@ from aiogram.types import ( InputMediaAnimation, InputMediaPhoto, ) -from aiogram.utils.exceptions import BadRequest, InvalidHTTPUrlContent, RetryAfter +from aiogram.utils.exceptions import BadRequest, RetryAfter from telethon.tl.types import Message from telethon.errors.rpcerrorlist import ChatSendInlineForbiddenError @@ -512,7 +512,7 @@ class Gallery(InlineUnit): media=self._get_current_media(unit_id), reply_markup=self._gallery_markup(unit_id), ) - except (InvalidHTTPUrlContent, BadRequest): + except BadRequest: logger.debug("Error fetching photo content, attempting load next one") del self._units[unit_id]["photos"][self._units[unit_id]["current_index"]] self._units[unit_id]["current_index"] -= 1 diff --git a/hikka/modules/hikka_info.py b/hikka/modules/hikka_info.py index d774f9d..2a522d4 100755 --- a/hikka/modules/hikka_info.py +++ b/hikka/modules/hikka_info.py @@ -14,7 +14,7 @@ import git from telethon.tl.types import Message from telethon.utils import get_display_name -from .. import loader, main, utils, version +from .. import loader, utils, version from ..inline.types import InlineQuery logger = logging.getLogger(__name__) diff --git a/hikka/tl_cache.py b/hikka/tl_cache.py index 8d34ed0..23251fe 100644 --- a/hikka/tl_cache.py +++ b/hikka/tl_cache.py @@ -51,6 +51,7 @@ class CustomTelegramClient(TelegramClient): self._hikka_fullchannel_cache = {} self._hikka_fulluser_cache = {} self.__forbidden_constructors = [] + asyncio.ensure_future(self.cleaner()) async def force_get_entity(self, *args, **kwargs): return await self.get_entity(*args, force=True, **kwargs) @@ -394,27 +395,27 @@ class CustomTelegramClient(TelegramClient): def forbid_joins(self): self.__forbidden_constructors.extend([615851205, 1817183516]) - async def cleaner(client: TelegramClient): + async def cleaner(self): while True: - for record, record_data in client._hikka_entity_cache.copy().items(): + for record, record_data in self._hikka_entity_cache.copy().items(): if record_data.expired(): - del client._hikka_entity_cache[record] + del self._hikka_entity_cache[record] logger.debug(f"Cleaned outdated cache {record=}") - for chat, chat_data in client._hikka_perms_cache.copy().items(): + for chat, chat_data in self._hikka_perms_cache.copy().items(): for user, user_data in chat_data.copy().items(): if user_data.expired(): - del client._hikka_perms_cache[chat][user] + del self._hikka_perms_cache[chat][user] logger.debug(f"Cleaned outdated perms cache {chat=} {user=}") - for channel_id, record in client._hikka_fullchannel_cache.copy().items(): + for channel_id, record in self._hikka_fullchannel_cache.copy().items(): if record.expired(): - del client._hikka_fullchannel_cache[channel_id] + del self._hikka_fullchannel_cache[channel_id] logger.debug(f"Cleaned outdated fullchannel cache {channel_id=}") - for user_id, record in client._hikka_fulluser_cache.copy().items(): + for user_id, record in self._hikka_fulluser_cache.copy().items(): if record.expired(): - del client._hikka_fulluser_cache[user_id] + del self._hikka_fulluser_cache[user_id] logger.debug(f"Cleaned outdated fulluser cache {user_id=}") await asyncio.sleep(3)