LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!

Home Page:https://docs.telethon.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SendConfirmPhoneCodeRequest successful run but not code is received

et-ness opened this issue · comments

Code that causes the issue

with TelegramClient(name, api_id, api_hash) as client:
    result = await client(functions.account.SendConfirmPhoneCodeRequest(
        hash=params['hash'][0],
        settings=types.CodeSettings(
            allow_flashcall=False,
            allow_app_hash=False,
            allow_firebase=False,
            unknown_number=True,
            current_number=True,
            allow_missed_call=True,
        )
    ))
    print(result)

Expected behavior

I should receive sms code

Actual behavior

I don't receive sms, while with official client works.

Here debug log:

DEBUG:telethon.network.mtprotosender:Receiving items from the network...
DEBUG:telethon.extensions.messagepacker:Assigned msg_id = 7367711563743xxxxxxxxxx to SendConfirmPhoneCodeRequest (7f5977918950)
DEBUG:telethon.network.mtprotosender:Encrypting 1 message(s) in 48 bytes for sending
DEBUG:telethon.network.mtprotosender:Encrypted messages put in a queue to be sent
DEBUG:telethon.network.mtprotosender:Waiting for messages to send...
DEBUG:telethon.extensions.messagepacker:Assigned msg_id = 736771156374xxxxxxxxx to MsgsAck (7f5977913690)
DEBUG:telethon.network.mtprotosender:Encrypting 1 message(s) in 36 bytes for sending
DEBUG:telethon.network.mtprotosender:Encrypted messages put in a queue to be sent
DEBUG:telethon.network.mtprotosender:Waiting for messages to send...
DEBUG:telethon.network.mtprotosender:Handling RPC result for message 7367711563743xxxxxxxxx
DEBUG:telethon.network.mtprotosender:Receiving items from the network...
SentCode(type=SentCodeTypeSms(length=5), phone_code_hash='xxxxxxxxxxxxxxxxx', next_type=CodeTypeCall(), timeout=75)

SentCode is the print of result.

Traceback

No response

Telethon version

1.35.0

Python version

3.11.2

Operating system (including distribution name and version)

Linux Debina 12.5

Other details

No response

Checklist

  • The error is in the library's code, and not in my own.
  • I have searched for this issue before posting it and there isn't an open duplicate.
  • I ran pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip and triggered the bug in the latest version.

I used this code and works:

with TelegramClient(name, api_id, api_hash) as client:
    result = await client(functions.account.SendConfirmPhoneCodeRequest(
        hash = params['hash'][0],
        settings = types.CodeSettings( )
    ))
    print(result)

flags should be 0 but when I set the parameters flags is not 0.
From mtp debug log:

      { core_message
        msg_id: 7367746340xxxxxxxxxxx [LONG],
        seq_no: 145 [INT],
        bytes: 32 [INT],
        body: { account_sendConfirmPhoneCode
          hash: "xxxxxxxxxxxxxxxxx" [STRING],
          settings: { codeSettings
            flags: 0 [INT],
            allow_flashcall: [ SKIPPED BY BIT 0 IN FIELD flags ],
            current_number: [ SKIPPED BY BIT 1 IN FIELD flags ],
            allow_app_hash: [ SKIPPED BY BIT 4 IN FIELD flags ],
            allow_missed_call: [ SKIPPED BY BIT 5 IN FIELD flags ],
            allow_firebase: [ SKIPPED BY BIT 7 IN FIELD flags ],
            unknown_number: [ SKIPPED BY BIT 9 IN FIELD flags ],
            logout_tokens: [ SKIPPED BY BIT 6 IN FIELD flags ],
            token: [ SKIPPED BY BIT 8 IN FIELD flags ],
            app_sandbox: [ SKIPPED BY BIT 8 IN FIELD flags ],
          },
        },
      },