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

Enabling usage with password protected accounts #8

Open
wants to merge 1 commit into
base: main
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
13 changes: 9 additions & 4 deletions api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.functions.photos import GetUserPhotosRequest
from telethon.tl.functions.stats import GetBroadcastStatsRequest
from telethon.errors.rpcerrorlist import SessionPasswordNeededError
from getpass import getpass


'''
Expand All @@ -29,10 +31,13 @@ async def get_connection(session_file, api_id, api_hash, phone):
else:
print ('> Not Authorized! Sending code request...')
await client.send_code_request(phone)
await client.sign_in(
phone,
input('Enter the code: ')
)
try:
await client.sign_in(
phone,
input('Enter the code: ')
)
except SessionPasswordNeededError:
await client.sign_in(password=getpass("Enter password: "))

return client

Expand Down