from pyrogram.types import Message from userbot import PyroClient from userbot.modules.capture import repository from userbot.modules.capture.chat_meta import meta_from_chat from userbot.modules.capture.message import sender_id from userbot.modules.media import capture_media, media_unique_id, self_destruct_ttl from utils.events import notify_bg_event @PyroClient.on_edited_message() async def on_edited_message(client: PyroClient, message: Message) -> None: ctx = client.capture if ctx is None or message.empty or message.chat is None or message.date is None: return chat = message.chat chat_id = chat.id or 0 meta = meta_from_chat(chat, ctx.contacts.ids) toggles = ctx.resolve(meta) if not toggles.track_edits_deletes: return changed = await repository.add_version( ctx.pool, ctx.account_id, chat_id, message.id, message.date, sender_id(message), message.text or message.caption, str(message), message.edit_date, media_unique_id(message), has_media=message.media is not None, is_self_destruct=self_destruct_ttl(message) is not None, ) if not changed: return if message.media is not None: await capture_media(client, message, ctx, chat_id, message.id, toggles) await notify_bg_event( ctx.pool, "edit", ctx.account_id, chat_id=chat_id, message_id=message.id ) handlers = on_edited_message.handlers