feat: add realtime capturing

This commit is contained in:
hh
2026-05-29 18:19:06 +02:00
parent 920a0235e2
commit 3c1a12750c
29 changed files with 967 additions and 47 deletions
+28
View File
@@ -0,0 +1,28 @@
from pyrogram.types import Message
from userbot import PyroClient
from userbot.modules.capture import repository
from userbot.modules.capture.repository import CHANNEL_ID_THRESHOLD
@PyroClient.on_deleted_messages()
async def on_deleted_messages(client: PyroClient, messages: list[Message]) -> None:
ctx = client.capture
if ctx is None:
return
box: list[int] = []
channels: dict[int, list[int]] = {}
for message in messages:
chat = message.chat
chat_id = chat.id if chat is not None else None
if chat_id is None or chat_id > CHANNEL_ID_THRESHOLD:
box.append(message.id)
else:
channels.setdefault(chat_id, []).append(message.id)
if box:
await repository.mark_deleted_box(ctx.pool, ctx.account_id, box)
for chat_id, ids in channels.items():
await repository.mark_deleted_channel(ctx.pool, ctx.account_id, chat_id, ids)
handlers = on_deleted_messages.handlers