Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add two-step verification #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions download_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from telethon.tl.types import DocumentAttributeFilename
from telethon.tl.types import Document
from telethon.utils import get_input_media
from telethon.errors.rpc_error_list import LocationInvalidError
from telethon.errors.rpc_error_list import LocationInvalidError, SessionPasswordNeededError
# from telegram_client_x import TelegramClientX
from telethon.telegram_client import TelegramClient
from telethon.tl.types import Message
Expand Down Expand Up @@ -68,7 +68,12 @@ def write(self, *args):
if not client.is_user_authorized():
phone = input('Enter phone: ')
client.send_code_request(phone)
client.sign_in(phone, input('Enter code: '))
try:
client.sign_in(phone, input('Enter code: '))
except SessionPasswordNeededError:
client.sign_in(password=input('Enter password:'))


def on_download_progress(recv_bytes, total_bytes):
global last_call_time_receive
if time.time() - last_call_time_receive < 1:
Expand Down