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

Support tdlib > 1.8.5 #348

Closed
selankon opened this issue Jan 31, 2023 · 11 comments
Closed

Support tdlib > 1.8.5 #348

selankon opened this issue Jan 31, 2023 · 11 comments

Comments

@selankon
Copy link

selankon commented Jan 31, 2023

Hi,

This issue is directly related to tdlib/td#2285.

I had a working client with a valid api_id and everything working in my computer, but I bought a new one, so on the moving I tried to move also this project.

I moved the project itself, installed the dependencies, and build the tdlib on the new computer (tdlib/td@d912fd1). Also I moved the tdlib files folder.

But when I try to run my client, with the original client stopped, I got this error:

Telegram error: {'@type': 'error', 'code': 400, 'message': 'Valid api_id must be provided. Can be obtained at https://my.telegram.org', '@extra': {'request_id': 'updateAuthorizationState'}}

They said that probably I'm using a different tdlib version, and ask me to use getOption("version").

However, I can't really understand how to do this (because I don't understand how the wrapper really works).

Could you kindly point me how to do this call? I found the _send_data function on the wrapper, probably I can use something similar to do a call against tdlib asking for the version?

Thanks in advance

@alexander-akhmetov
Copy link
Owner

Hi! Thanks for the link to the issue. python-telegram indeed does not support the new tdlib API. It looks like at least the setTdlibParameters call here should be changed based on the tdlib version used by the wrapper. I'll adapt the wrapper, but in the meantime you can build tdlib 1.8.5 (tdlib/td@d9cfcf8), it should work with the current implementation.

I found the _send_data function on the wrapper, probably I can use something similar to do a call against tdlib asking for the version?

To get the version you could do something like this:

tg = Telegram(
    api_id=...,
    api_hash=...,
    phone=...,
    database_encryption_key=...,
)

result = tg.call_method('getOption', params={'name': 'version'})
result.wait()
print(result.update)

@selankon
Copy link
Author

selankon commented Feb 1, 2023

Ok, thanks for the answer!

The commit you are using is really back between the one that I'm using that is working too on the first computer. Anyway, I will compile the 1.8.5 version.

And thanks to show me how to use the wrapper to do tdlib calls.

@selankon selankon closed this as completed Feb 1, 2023
@selankon
Copy link
Author

selankon commented Feb 1, 2023

It is still strange, on the computer with the working version appear to be using tdlib 1.8.5, meanwhile, the commit on my tdlib folder is above 1.8.10. Which mean that I'm using another tdlib version that the one I compiled..

Looking for tdlib files on my system I don't found anymore that the ones I compiled... Strange

@alexander-akhmetov
Copy link
Owner

If you don't specify library_path when you are instantiating the client (Telegram(library_path=...)), python-telegram tries to find it and if it's unable to find the system library it uses its own version (1.8.5 currently).

It should log the path to the library that its using, in the logs you should see something like this :

2023-02-01 10:22 [INFO] telegram.tdjson: Using shared library "/path/to/libtdjson"

@selankon
Copy link
Author

selankon commented Feb 1, 2023

I don't see any log. And I thought that is mandatory to build tdlib by your own, I didn't know that python_telegram has its own tdlib.

@alexander-akhmetov
Copy link
Owner

You can try to also debug it by calling the function that python-telegram uses to find the library:

$ python3

>>> from telegram.tdjson import _get_tdjson_lib_path
>>> print(_get_tdjson_lib_path())
/path/to/libtdjson

Or set manually the exact path to the version that you want to use with library_path:

tg = Telegram(
    api_id=...,
    api_hash=...,
    phone=...,
    database_encryption_key=...,
    ...
    library_path='/path/to/libtdjson',
)

@selankon
Copy link
Author

selankon commented Feb 1, 2023

Thats nice thanks!

@Sakura0721
Copy link

I met the same problem. Hope python-telegram can be adapted to tdlib 1.8.11!

@Hi-Angel
Copy link

Hi-Angel commented Mar 1, 2023

Does it currently work with 1.8.10 ? I'm trying to run a "hello world" from the project documentation, but get the same error about api_id being invalid. I presume it's this bug? Should it be reopened?

@alexander-akhmetov alexander-akhmetov changed the title [HELP] Different tdlib versions? How to make calls to tdlib Support tdlib > 1.8.5 Mar 1, 2023
@alexander-akhmetov
Copy link
Owner

Hi, no, it does not work with the new tdlib. Its APIs have changed and the library needs to be adapted to support it.

@alexander-akhmetov
Copy link
Owner

python-telegram 0.18.0 is released and it works with tdlib > 1.8.5 (thanks to @JleMyP )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants