feat: log presence, read receipts, group leaves, links, profiles, stories
This commit is contained in:
1 parent
bfd16ab02c
commit
bcb94b6474
31 files changed
+1298
-19
No files matched your search
@@ -0,0 +1,40 @@
|
||||
from io import BytesIO
|
||||
|
||||
from pyrogram import Client
|
||||
|
||||
from userbot.modules.avatars import repository
|
||||
from userbot.modules.capture.context import CaptureContext
|
||||
|
||||
|
||||
async def capture_avatar( # noqa: PLR0913
|
||||
client: Client,
|
||||
ctx: CaptureContext,
|
||||
owner_id: int,
|
||||
owner_kind: str,
|
||||
file_id: str,
|
||||
unique_id: str,
|
||||
raw: str,
|
||||
) -> None:
|
||||
if await repository.avatar_exists(ctx.pool, ctx.account_id, owner_id, unique_id):
|
||||
return
|
||||
storage_key: str | None = None
|
||||
file_size: int | None = None
|
||||
downloaded = False
|
||||
buffer = await client.download_media(file_id, in_memory=True)
|
||||
if isinstance(buffer, BytesIO):
|
||||
data = buffer.getvalue()
|
||||
storage_key = ctx.storage.put(data)
|
||||
file_size = len(data)
|
||||
downloaded = True
|
||||
await repository.insert_avatar(
|
||||
ctx.pool,
|
||||
ctx.account_id,
|
||||
owner_id,
|
||||
owner_kind,
|
||||
unique_id,
|
||||
storage_key,
|
||||
file_size,
|
||||
None,
|
||||
raw,
|
||||
downloaded=downloaded,
|
||||
)
|
||||
Reference in new issue
Block a user