Files
beavergram/backend/src/userbot/handlers/raw/read_receipts.py
T

31 lines
822 B
Python

from datetime import UTC, datetime
from pyrogram import raw, utils
from userbot import PyroClient
from userbot.modules.read_receipts import repository
from utils.events import notify_bg_event
HANDLES = (raw.types.UpdateReadHistoryOutbox,)
async def handle(
client: PyroClient, update: raw.base.Update, _users: dict, _chats: dict
) -> None:
ctx = client.capture
if ctx is None or not isinstance(update, raw.types.UpdateReadHistoryOutbox):
return
chat_id = utils.get_peer_id(update.peer)
await repository.insert_read(
ctx.pool,
ctx.account_id,
chat_id,
chat_id,
datetime.now(UTC),
update.max_id,
str(update),
)
await notify_bg_event(
ctx.pool, "receipt", ctx.account_id, chat_id=chat_id, message_id=update.max_id
)