diff --git a/backend/src/userbot/handlers/deletes.py b/backend/src/userbot/handlers/deletes.py index 984835a..2d9384f 100644 --- a/backend/src/userbot/handlers/deletes.py +++ b/backend/src/userbot/handlers/deletes.py @@ -30,4 +30,4 @@ async def on_deleted_messages(client: PyroClient, messages: list[Message]) -> No ) -handlers = on_deleted_messages.handlers +handlers = on_deleted_messages.handlers # ty: ignore[unresolved-attribute] diff --git a/backend/src/userbot/handlers/edits.py b/backend/src/userbot/handlers/edits.py index 1afe136..396b940 100644 --- a/backend/src/userbot/handlers/edits.py +++ b/backend/src/userbot/handlers/edits.py @@ -49,4 +49,4 @@ async def on_edited_message(client: PyroClient, message: Message) -> None: ) -handlers = on_edited_message.handlers +handlers = on_edited_message.handlers # ty: ignore[unresolved-attribute] diff --git a/backend/src/userbot/handlers/messages.py b/backend/src/userbot/handlers/messages.py index be9998e..5e2bd53 100644 --- a/backend/src/userbot/handlers/messages.py +++ b/backend/src/userbot/handlers/messages.py @@ -36,4 +36,4 @@ async def on_message(client: PyroClient, message: Message) -> None: await safe_transcribe(client, ctx, meta.chat_id, message.id) -handlers = on_message.handlers +handlers = on_message.handlers # ty: ignore[unresolved-attribute] diff --git a/backend/src/userbot/handlers/presence.py b/backend/src/userbot/handlers/presence.py index 1b29c48..439d9d0 100644 --- a/backend/src/userbot/handlers/presence.py +++ b/backend/src/userbot/handlers/presence.py @@ -27,4 +27,4 @@ async def on_user_status(client: PyroClient, user: User) -> None: await notify_bg_event(ctx.pool, "presence", ctx.account_id, chat_id=user.id) -handlers = on_user_status.handlers +handlers = on_user_status.handlers # ty: ignore[unresolved-attribute] diff --git a/backend/src/userbot/handlers/raw/dispatcher.py b/backend/src/userbot/handlers/raw/dispatcher.py index c6e3e31..32e0bde 100644 --- a/backend/src/userbot/handlers/raw/dispatcher.py +++ b/backend/src/userbot/handlers/raw/dispatcher.py @@ -38,4 +38,4 @@ async def dispatch( await handler(client, update, users, chats) -handlers = dispatch.handlers +handlers = dispatch.handlers # ty: ignore[unresolved-attribute] diff --git a/backend/src/userbot/handlers/raw/profiles.py b/backend/src/userbot/handlers/raw/profiles.py index 5e76d87..2d8fd1f 100644 --- a/backend/src/userbot/handlers/raw/profiles.py +++ b/backend/src/userbot/handlers/raw/profiles.py @@ -21,7 +21,7 @@ async def _handle_user( raw_user = users.get(update.user_id) if raw_user is None: return - fields, photo_file_id, photo_unique_id = snapshot_from_user(client, raw_user) + fields, photo_file_id, photo_unique_id = await snapshot_from_user(client, raw_user) current = await get_peer(ctx.pool, ctx.account_id, update.user_id) if current == fields: return diff --git a/backend/src/userbot/handlers/stories.py b/backend/src/userbot/handlers/stories.py index 93385de..fa2eda6 100644 --- a/backend/src/userbot/handlers/stories.py +++ b/backend/src/userbot/handlers/stories.py @@ -11,4 +11,4 @@ async def on_story(client: PyroClient, story: Story) -> None: await save_story(client, client.capture, story) -handlers = on_story.handlers +handlers = on_story.handlers # ty: ignore[unresolved-attribute] diff --git a/backend/src/userbot/modules/jobs/handlers/enrich_chat.py b/backend/src/userbot/modules/jobs/handlers/enrich_chat.py index 2d52fd2..69008a7 100644 --- a/backend/src/userbot/modules/jobs/handlers/enrich_chat.py +++ b/backend/src/userbot/modules/jobs/handlers/enrich_chat.py @@ -36,6 +36,8 @@ async def _save_user(ctx: CaptureContext, user: User) -> None: async def _enrich_chat_meta(client: Client, ctx: CaptureContext, chat_id: int) -> None: chat = await client.get_chat(chat_id) + if chat is None: + return photo = chat.photo photo_unique_id = photo.big_photo_unique_id if photo else None photo_file_id = photo.big_file_id if photo else None diff --git a/backend/src/userbot/modules/jobs/handlers/fetch_avatar.py b/backend/src/userbot/modules/jobs/handlers/fetch_avatar.py index a95c2ed..816edaf 100644 --- a/backend/src/userbot/modules/jobs/handlers/fetch_avatar.py +++ b/backend/src/userbot/modules/jobs/handlers/fetch_avatar.py @@ -12,7 +12,7 @@ STALE_FILE_ID = (FileIdInvalid, FileReferenceExpired, FileReferenceInvalid) async def _fresh_file_id(client: Client, owner_id: int, unique_id: str) -> str | None: chat = await client.get_chat(owner_id) - photo = chat.photo + photo = chat.photo if chat else None if photo and photo.big_photo_unique_id == unique_id: return photo.big_file_id photos = client.get_chat_photos(owner_id) diff --git a/backend/src/userbot/modules/jobs/handlers/search_peers.py b/backend/src/userbot/modules/jobs/handlers/search_peers.py index 388cec3..acefbbe 100644 --- a/backend/src/userbot/modules/jobs/handlers/search_peers.py +++ b/backend/src/userbot/modules/jobs/handlers/search_peers.py @@ -46,7 +46,7 @@ async def _save_found( source = _source(peer, users, chats) if source is None: return None - chat = Chat._parse_chat(client, source) # noqa: SLF001 + chat = await Chat._parse_chat(client, source) # noqa: SLF001 if chat is None or chat.id is None: return None await save_chat(ctx, chat) diff --git a/backend/src/userbot/modules/profiles/parse.py b/backend/src/userbot/modules/profiles/parse.py index 7625c32..a52cd45 100644 --- a/backend/src/userbot/modules/profiles/parse.py +++ b/backend/src/userbot/modules/profiles/parse.py @@ -21,10 +21,10 @@ def active_username(usernames: list[raw.types.Username]) -> str | None: return usernames[0].username if usernames else None -def snapshot_from_user( +async def snapshot_from_user( client: Client, raw_user: raw.types.User ) -> tuple[ProfileFields, str | None, str | None]: - user = User._parse(client, raw_user) # noqa: SLF001 + user = await User._parse(client, raw_user) # noqa: SLF001 photo = user.photo if user else None photo_unique_id = photo.big_photo_unique_id if photo else None photo_file_id = photo.big_file_id if photo else None