from pyrogram.types import User from userbot.modules.jobs.context import JobContext from userbot.modules.jobs.registry import register from userbot.modules.profiles.snapshots import save_user @register("sync_contacts") async def sync_contacts(ctx: JobContext) -> None: client = ctx.client if client is None: return capture = getattr(client, "capture", None) if capture is None: return contacts = await client.get_contacts() processed = 0 for user in contacts: if not isinstance(user, User): continue await save_user(capture, user) processed += 1 await capture.contacts.refresh() await ctx.report_progress({"processed": processed, "done": True})