feat: log presence, read receipts, group leaves, links, profiles, stories
This commit is contained in:
1 parent
bfd16ab02c
commit
bcb94b6474
31 files changed
+1298
-19
No files matched your search
@@ -1,7 +1,10 @@
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from pyrogram import raw, utils
|
||||
|
||||
from userbot import PyroClient
|
||||
from userbot.modules.capture.chat_meta import meta_from_chat_id
|
||||
from userbot.modules.read_receipts import repository as receipts
|
||||
from userbot.modules.stt import repository
|
||||
from userbot.modules.stt.gate import safe_transcribe
|
||||
|
||||
@@ -19,16 +22,30 @@ async def handle(
|
||||
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(
|
||||
candidates = await repository.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(
|
||||
candidates = await repository.voice_reads(
|
||||
ctx.pool, ctx.account_id, update.messages
|
||||
)
|
||||
else:
|
||||
return
|
||||
for cand_chat_id, message_id in candidates:
|
||||
self_id = client.me.id if client.me else None
|
||||
for cand_chat_id, message_id, sender_id, untranscribed in candidates:
|
||||
if sender_id is not None and sender_id == self_id:
|
||||
await receipts.insert_listened(
|
||||
ctx.pool,
|
||||
ctx.account_id,
|
||||
cand_chat_id,
|
||||
cand_chat_id,
|
||||
datetime.now(UTC),
|
||||
message_id,
|
||||
str(update),
|
||||
)
|
||||
continue
|
||||
if not untranscribed:
|
||||
continue
|
||||
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)
|
||||
Reference in new issue
Block a user