Initial authentication: sending `auth.sendCode` and getting` msg_container` instead of `auth.SentCode` in python

I downloaded the CLI version of Telegram ( https://telegram.org/ ). The Not-So-Complete version of this CLI was downloaded from: https://github.com/griganton/telepy

Authentication is now completely working fine, but there are 0 actual functions.

so I modified JASON-Scheme a bit and added the necessary functionality needed for initial authentication

{'id': '1988976461',
 'method': 'sendCode',
 'params': [{'name': 'phone_number', 'type': 'string'},
            {'name': 'sms_type', 'type': 'int'},
            {'name': 'api_id', 'type': 'int'},
            {'name': 'api_hash', 'type': 'string'},
            {'name': 'lang_code', 'type': 'string'}],
 'type': 'SentCode'}

      

as stated in the documentation https://core.telegram.org/method/auth.sendCode

Now that I don't, according to the documentation, it looks like after sending a message requesting an SMS code, I should receive auth.SentCode

with a hexadecimal code at the beginning of the packet 0xEFED51D9

, but instead I'm getting something like a response from the server msg_container73f1f8dc

that doesn't seem to be related with what ever was for my request.

This all seems very annoying and odd, I don't know what could lead to the whole thing I followed the documentation and tried to implement as requested.

The package I am sending looks good and I do get SmsCode on my phone .. but the answer I get is bad / incomprehensible for some reason.

I am calling a function implemented in JSON like this:

auth = Session.method_call('sendCode', phone_number=PHONE_NUMBER, sms_type=0, api_id=MY_API_ID, api_hash=MY_API_HASH, lang_code="en")

      

so it works .. but i need it phone_code_hash

. Note that for some reason the documentation of Telegram itself is also weird. Looking at the example request they gave, the numbers just don't match what the documentation says (quoted from their documentation):

Example request:

(auth.sendCode "79991234567" 1 32 "test-hash" "en")
=
(auth.sentCode
  phone_registered:(boolFalse)
  phone_code_hash:"2dc02d2cda9e615c84"
)

d16ff372 3939370b 33323139 37363534 00000001 00000020 73657409 61682d74 00006873 e77e812d
=
2215bcbd bc799737 63643212 32643230 39616463 35313665 00343863 e12b7901

      

taken from here: https://core.telegram.org/method/auth.sendCode

the expected first DWORD on each part must be different. for example: 768d5f4d

instead of d16ff372

..

So what am I missing?

some kind of link (for some reason it doesn't allow me to post this unless I put it as a code section)

https://core.telegram.org/constructor/auth.sentCode
https://core.telegram.org/mtproto/service_messages
https://core.telegram.org/method/auth.sendCode

      

+3


source to share


2 answers


Well, the problem was poor socket handling. the server just sent two packets.

The first package was Message_Service

and the second was the data I really want.



Its strange because he said nothing about these messages in the documentation

0


source


In most cases, telegram collected messages in msg_container.

For example, you can get Msg_acks for previous posts along with the expected response from your last post.

Your best bet is to set up your code to handle cases with received containers, check the number of items in the container, then skip the received messages, pass different types of messages to the appropriate handlers.



Also note that you can get rpc_response which contains the gzipped message, in which case you will need to unzip and then process the content of your message, which can also contain the message collection

amuses

0


source







All Articles