diff --git a/README.md b/README.md index b0b58d2..7a8f4eb 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,10 @@ OverUB is a modular Telegram userbot built around a plugin-first architecture. - Optional for QR display: `pip install qrcode` 2. Edit `config/config.yml` 3. Run: `python -m __main__` -4. Optional: set `bot.login_mode` to `qr` for QR login +4. Optional login modes: + - `phone` (default) + - `qr` (QR login) + - `sms` (force SMS code) ## CLI - `python -m __main__ create-plugin ` diff --git a/core/client.py b/core/client.py index 29f13c1..93920a3 100644 --- a/core/client.py +++ b/core/client.py @@ -52,6 +52,22 @@ class ClientWrapper: except SessionPasswordNeededError: password = await self._prompt("Two-step verification enabled. Enter password: ") await self.client.sign_in(password=password) + elif login_mode in {"sms", "code"}: + if not phone: + raise RuntimeError("Phone number required for login") + await self.client.connect() + if await self.client.is_user_authorized(): + logger.info("Telethon client already authorized") + return + sent = await self.client.send_code_request(phone, force_sms=login_mode == "sms") + code_type = getattr(sent, "type", None) + logger.info("Login code type: %s", type(code_type).__name__ if code_type else "unknown") + code = await self._prompt("Please enter the code you received: ") + try: + await self.client.sign_in(phone=phone, code=code, phone_code_hash=sent.phone_code_hash) + except SessionPasswordNeededError: + password = await self._prompt("Two-step verification enabled. Enter password: ") + await self.client.sign_in(password=password) else: await self.client.start(phone=phone) logger.info("Telethon client connected")