feat: add realtime capturing

This commit is contained in:
h
2026-05-29 18:19:06 +02:00
parent 920a0235e2
commit 3c1a12750c
29 changed files with 967 additions and 47 deletions
@@ -0,0 +1,3 @@
from userbot.modules.contacts.cache import ContactCache
__all__ = ["ContactCache"]
@@ -0,0 +1,20 @@
from pyrogram import Client
from utils.logging import logger
class ContactCache:
def __init__(self, client: Client) -> None:
self._client = client
self.ids: set[int] = set()
async def refresh(self) -> None:
contacts = await self._client.get_contacts()
self.ids = {user.id for user in contacts}
logger.info(f"[green]Contacts cached:[/] {len(self.ids)}")
def mark(self, user_id: int, *, is_contact: bool) -> None:
if is_contact:
self.ids.add(user_id)
else:
self.ids.discard(user_id)