opentele
opentele copied to clipboard
switching from .session to tdata not working
I tried it, although it creates a folder tdata but there is no login on it
It's still working for the latest version of Telegram Desktop. Can you post your code here and also specify which version of Telegram Desktop you're using?
Edit: Please make sure that you have the latest version of opentele
pip install -U --no-cache-dir opentele
I run the code from the example and raises an error...
from opentele.td import TDesktop
from opentele.tl import TelegramClient
from opentele.api import API, UseCurrentSession
import asyncio
import os
async def main():
client = TelegramClient('62895385923488.session')
tdesk = await client.ToTDesktop(flag=UseCurrentSession) # error occurs here
tdesk.SaveTData()#"tdata")
asyncio.run(main())
-----------------------------------------------
File "/home/af/.local/lib/python3.9/site-packages/opentele/td/account.py", line 1007, in FromTelethon
Expects(
opentele.exception.TelethonUnauthorized: TelethonUnauthorized: Telethon client is unauthorized, it need to be authorized first [ Called by FromTelethon() ]
how to make it work?
I run the code from the example and raises an error...
from opentele.td import TDesktop from opentele.tl import TelegramClient from opentele.api import API, UseCurrentSession import asyncio import os async def main(): client = TelegramClient('62895385923488.session') tdesk = await client.ToTDesktop(flag=UseCurrentSession) # error occurs here tdesk.SaveTData()#"tdata") asyncio.run(main()) ----------------------------------------------- File "/home/af/.local/lib/python3.9/site-packages/opentele/td/account.py", line 1007, in FromTelethon Expects( opentele.exception.TelethonUnauthorized: TelethonUnauthorized: Telethon client is unauthorized, it need to be authorized first [ Called by FromTelethon() ]
how to make it work?
The error is:
TelethonUnauthorized: Telethon client is unauthorized, it need to be authorized first
Your .session file is not authorized yet, that mean you haven't logged in.
Everything miraculously worked after your answer. Thanks! But now I don't understand why it didn't work...
This is your code from account.py :
..........
else:
copy = telethonClient
ss = copy.session
authKey = ss.auth_key.key
dcId = DcId(ss.dc_id)
userId = copy.UserId
authKey = td.AuthKey(authKey, td.AuthKeyType.ReadFromFile, dcId)
if userId == None:
await copy.connect()
await copy.get_me()
userId = copy.UserId # the problem was here
..........
copy.UserId was returning None. I do not understand why I did not connect with the client? Now everything connects and gets the userId. I am now going to use your library. Suddenly I have questions, let me disturb you in telegrams? For efficiency ... My telegram @AlexFX77
I'm sorry for my English, I'm using google translate...