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 option to not Input data during login and raise TwitterException #284

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
27 changes: 16 additions & 11 deletions twikit/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ async def login(
auth_info_1: str,
auth_info_2: str | None = None,
password: str,
totp_secret: str | None = None
totp_secret: str | None = None,
input_for_login: bool = True
) -> dict:
"""
Logs into the account using the specified login information.
Expand All @@ -311,6 +312,8 @@ async def login(
totp_secret : :class:`str`
The TOTP (Time-Based One-Time Password) secret key used for
two-factor authentication (2FA).
input_for_login : :class:`bool`, default=True
Whether to prompt for input when the account is locked.

Examples
--------
Expand Down Expand Up @@ -425,16 +428,18 @@ async def login(
raise TwitterException(flow.response['subtasks'][0]['cta']['secondary_text']['text'])

if flow.task_id == 'LoginAcid':
print(find_dict(flow.response, 'secondary_text', find_one=True)[0]['text'])

await flow.execute_task({
'subtask_id': 'LoginAcid',
'enter_text': {
'text': input('>>> '),
'link': 'next_link'
}
})
return flow.response
if input_for_login:
print(find_dict(flow.response, 'secondary_text', find_one=True)[0]['text'])
await flow.execute_task({
sourcery-ai[bot] marked this conversation as resolved.
Show resolved Hide resolved
'subtask_id': 'LoginAcid',
'enter_text': {
'text': input('>>> '),
'link': 'next_link'
}
})
return flow.response

raise TwitterException(flow.response['subtasks'][0]['cta']['secondary_text']['text'])

await flow.execute_task({
'subtask_id': 'AccountDuplicationCheck',
Expand Down