feat: add SST

This commit is contained in:
hh committed 2026-05-29 20:45:02 +02:00
1 parent 51093da660
commit bfd16ab02c
11 files changed
+196 -4

No files matched your search

@@ -0,0 +1,34 @@
from pyrogram import raw, utils
from userbot import PyroClient
from userbot.modules.capture.chat_meta import meta_from_chat_id
from userbot.modules.stt import repository
from userbot.modules.stt.gate import safe_transcribe
HANDLES = (
raw.types.UpdateReadMessagesContents,
raw.types.UpdateChannelReadMessagesContents,
)
async def handle(
client: PyroClient, update: raw.base.Update, _users: dict, _chats: dict
) -> None:
ctx = client.capture
if ctx is None:
return
if isinstance(update, raw.types.UpdateChannelReadMessagesContents):
chat_id = utils.get_peer_id(raw.types.PeerChannel(channel_id=update.channel_id))
candidates = await repository.pending_voice_reads(
ctx.pool, ctx.account_id, update.messages, chat_id=chat_id
)
elif isinstance(update, raw.types.UpdateReadMessagesContents):
candidates = await repository.pending_voice_reads(
ctx.pool, ctx.account_id, update.messages
)
else:
return
for cand_chat_id, message_id in candidates:
meta = meta_from_chat_id(cand_chat_id, ctx.contacts.ids)
if ctx.resolve(meta).stt:
await safe_transcribe(client, ctx, cand_chat_id, message_id)