from pyrogram.types import Message from userbot import PyroClient from userbot.modules.capture import capture_message from userbot.modules.capture.chat_meta import meta_from_chat from userbot.modules.stt import is_transcribable from userbot.modules.stt.gate import safe_transcribe @PyroClient.on_message() async def on_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 meta = meta_from_chat(message.chat, ctx.contacts.ids) toggles = ctx.resolve(meta) if not toggles.messages: return await capture_message(client, message, ctx, toggles) if ( toggles.stt and is_transcribable(message) and (message.outgoing or message.unread_media is False) ): await safe_transcribe(client, ctx, meta.chat_id, message.id) handlers = on_message.handlers