Giter VIP home page Giter VIP logo

thedemons / opentele Goto Github PK

View Code? Open in Web Editor NEW
240.0 240.0 87.0 3.31 MB

A Python Telegram API Library for converting between tdata and telethon sessions, with built-in official Telegram APIs.

Home Page: https://opentele.readthedocs.io/

License: MIT License

Python 100.00%
opentele python python3 tdata tdesktop telegram telegram-api telegram-api-bot telegram-bot telegram-desktop telegram-userbot telegramapi telegrambot telethon

opentele's People

Contributors

json1c avatar n1ret avatar serveroid avatar staseek avatar thedemons avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opentele's Issues

TDataReadMapDataFailed: Unknown key type in encrypted map: 25 [ Called by BaseObject.MapData.read() ]

Describe the bug
Parsing the innards of TDesktop revealed that there is one single account, but its isLoaded = false. Digging deeper, it turned out that the error TDataReadMapDataFailed: Unknown key type in encrypted map: 25 [ Called by BaseObject.MapData.read() ] inside the readMapWith function of the accaunt class.

Expected behavior
TDesktop ended without exceptions.

Screenshots
Screenshot_115
Screenshot_116

Additional context
Telegram Desktop is working, so the 25-type key is not a lie.

Too many requests (caused by InviteToChannelRequest)

Hey. Could you help me to find out how to avoid the error "Too many requests (caused by InviteToChannelRequest)", when I do inviting from a few accounts(one after another) I got this error on a the second account.
I guess the Telegram sees that my two accounts have some similar data, like default app_id/app_hash or smgth?!

Should I generate a new API or smgth like that to show that I user different account?

My code:
tdesk = TDesktop(tdata_path)
async with await TelegramClient.FromTDesktop(tdesk, flag=UseCurrentSession, proxy=ipv4_sock5_proxy,connection_retries=3, receive_updates=False)

P.S Help me understand how to use your library through tdata format account, so that the Tlegram does not consider that my conditionally 5 accounts are the same and does not restrict them as one and the same, and in general is it possible to use your library so, if not, how?
Do I need to generate API for UsingCurrentSession or not, how that work?

Dont work (

File "C:\Users\ns\AppData\Local\Programs\Python\Python39\lib\site-packages\opentele\td\storage.py", line 310, in ReadFile
raise tries_exception if tries_exception else TFileNotFound(
opentele.exception.TFileNotFound: TFileNotFound: Could not open key_data [ Called by ReadFile() ]

A problem installing opentele on kalinethunter

Every time I try to install opentele on kalinethunter I get this error

`$ pip install opentele
Collecting opentele
Using cached opentele-1.15.1-py3-none-any.whl (81 kB)
Collecting pyqt5
Using cached PyQt5-5.15.9.tar.gz (3.2 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error

× Preparing metadata (pyproject.toml) did not run successfully.
? exit code: 1
??> [25 lines of output]
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in
main()
File "/usr/lib/python3/dist-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-7stihp6p/overlay/local/lib/python3.11/dist-packages/sipbuild/api.py", line 46, in build_wheel
project = AbstractProject.bootstrap('wheel',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-7stihp6p/overlay/local/lib/python3.11/dist-packages/sipbuild/abstract_project.py", line 87, in bootstrap
project.setup(pyproject, tool, tool_description)
File "/tmp/pip-build-env-7stihp6p/overlay/local/lib/python3.11/dist-packages/sipbuild/project.py", line 586, in setup
self.apply_user_defaults(tool)
File "/tmp/pip-install-7_5vl7wf/pyqt5_c199201c6b8b45f2bd87a1dca100f2cc/project.py", line 68, in apply_user_defaults
super().apply_user_defaults(tool)
File "/tmp/pip-build-env-7stihp6p/overlay/local/lib/python3.11/dist-packages/pyqtbuild/project.py", line 70, in apply_user_defaults
super().apply_user_defaults(tool)
File "/tmp/pip-build-env-7stihp6p/overlay/local/lib/python3.11/dist-packages/sipbuild/project.py", line 237, in apply_user_defaults
self.builder.apply_user_defaults(tool)
File "/tmp/pip-build-env-7stihp6p/overlay/local/lib/python3.11/dist-packages/pyqtbuild/builder.py", line 69, in apply_user_defaults
raise PyProjectOptionException('qmake',
sipbuild.pyproject.PyProjectOptionException
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
??> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
`

Please Help!

It worked like that, I have deleted 'use_ipv6=True'.

It worked like that, I have deleted 'use_ipv6=True'.

client = await TelegramClient.FromTDesktop(tdesk,
flag=UseCurrentSession,
api=api,
proxy=(socks.SOCKS5,
'217.22.62.241',
10111,
True,
'HzJ9PZ',
'ngEXQ3')
)

As far as I know, Telethon has stopped supporting ipv6, but opentele supports it, is the old version being used?

Originally posted by @Ch4ttY in #52 (comment)

Bug with opentele.td.TDesktop.ToTelethon

I have bug, when I started this: client = await tdesk.ToTelethon(session=path, flag=CreateNewSession, proxy=proxy) my code stopped and was "waiting". Can you tell me, how can I fix this?

RecursionError: maximum recursion depth exceeded in comparison

I get RecursionError: maximum recursion depth exceeded in comparison when i try to start many sessions using asyncio

This is my code:
image
image

It works for 8 iterations, and fails with RecursionError
Stacktrace:
image

What i'm doing wrong? Or it's bug? Works perfect with only one session

asyncio.run(main()) has error, how to resolve ?

Unhandled error while receiving data
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\asyncio\runners.py", line 43, in run
return loop.run_until_complete(main)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 574, in run_until_complete
self.run_forever()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 541, in run_forever
self._run_once()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 1786, in _run_once
handle._run()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\asyncio\events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File ".\TdataToSession.py", line 49, in main
exit(0)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib_sitebuiltins.py", line 26, in call
raise SystemExit(code)
SystemExit: 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\telethon\network\mtprotosender.py", line 505, in _recv_loop
body = await self._connection.recv()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\telethon\network\connection\connection.py", line 299, in recv
result, err = await self._recv_queue.get()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\asyncio\queues.py", line 159, in get
await getter
concurrent.futures._base.CancelledError

RecursionError: maximum recursion depth exceeded withing converting

Describe the bug
RecursionError: maximum recursion depth exceeded

To Reproduce
Steps to reproduce the behavior:
Run example

from opentele.td import TDesktop
from opentele.tl import TelegramClient
from opentele.api import API, UseCurrentSession, CreateNewSession
import asyncio

async def main():

    # Load TDesktop client from tdata folder
    tdataFolder = r"F:\Telegram Desktop\tdata"
    tdesk = TDesktop(tdataFolder)
    
    # Check if we have loaded any accounts
    assert tdesk.isLoaded()

    # flag=UseCurrentSession
    #
    # Convert TDesktop to Telethon using the current session.
    client = await tdesk.ToTelethon(session="telethon.session", flag=CreateNewSession)
    
    # Connect and print all logged-in sessions of this client.
    # Telethon will save the session to telethon.session on creation.
    await client.connect()
    await client.PrintSessions()

asyncio.run(main())

Expected behavior
Loaded account and .session output

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context

File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 677, in api
    self.owner.api = self.api
    ^^^^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\tdesktop.py", line 666, in api
    account.api = value
    ^^^^^^^^^^^
  File "c:\Users\SeB4ik\Desktop\checker\venv\Lib\site-packages\opentele\td\account.py", line 676, in api
    if self.owner.api != self.api:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
RecursionError: maximum recursion depth exceeded

Cannot receive code with send_code_request.

It seems that they have Fix or have realized so when using the Send code request from the OpenTele, it does not receive SMS anymore, if the emulator or SMS is still received normally.

I dont understand how to start it:(

Sorry but i dont understand how to start it. I know how to sart .py files but id ont know how to start opentele. i need to convert tdate to session

{Bug}

Hi.
can help Fixed

'C:\Users\Administrator\Downloads\Compressed\Telegram-noborderz-main\Telegram-noborderz-main\sessions>1.py
Traceback (most recent call last):
File "C:\Users\Administrator\Downloads\Compressed\Telegram-noborderz-main\Telegram-noborderz-main\sessions\1.py", line 29, in
asyncio.run(main())
File "C:\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\Users\Administrator\Downloads\Compressed\Telegram-noborderz-main\Telegram-noborderz-main\sessions\1.py", line 10, in main
tdesk = TDesktop(tdataFolder)
File "C:\Python310\lib\site-packages\opentele\td\tdesktop.py", line 141, in init
self.LoadTData()
File "C:\Python310\lib\site-packages\opentele\td\tdesktop.py", line 216, in LoadTData
raise e
File "C:\Python310\lib\site-packages\opentele\td\tdesktop.py", line 203, in LoadTData
self.__loadFromTData()
File "C:\Python310\lib\site-packages\opentele\td\tdesktop.py", line 453, in __loadFromTData
Expects(len(self.accounts) > 0, "No account has been loaded")
File "C:\Python310\lib\site-packages\opentele\exception.py", line 326, in Expects
raise exception
File "C:\Python310\lib\site-packages\opentele\td\tdesktop.py", line 453, in __loadFromTData
Expects(len(self.accounts) > 0, "No account has been loaded")
opentele.exception.OpenTeleException: Unexpected Exception: No account has been loaded [ Called by BaseObject.TDesktop.__loadFromTData() ]'

Errors at loop, need help.

hello mate, i very like your repo
but i have problem with opentele.

i want create many session file from tdata folders

async def main():
	_path = input("[Path]> ")
	all_dirs = glob.glob(f"{_path}/*/Telegram/*/")
	print(len(all_dirs))
	for tdataFolder in all_dirs:
		try:
			time.sleep(2)
			tdesk = TDesktop(tdataFolder)
			api = API.TelegramIOS.Generate()
			savePath = r"tgses\\" + str(int(time.time())) + ".session"
			client = await tdesk.ToTelethon(savePath, CreateNewSession, api)
			await client.connect()
			await client.PrintSessions()
			await client.disconnect()
		except TDesktopUnauthorized:
			print("TDesktopUnauthorized | TDesktop client is unauthorized")
			continue
		except OpenTeleException:
			print("OpenTeleException | No account has been loaded")
			continue
		except LoginFlagInvalid:
			print("LoginFlagInvalid | LoginFlag invalid")
			continue
		except Exception as ex:
			print(ex)
			continue
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())

i used try except , and have this error:

 File "C:\Users\Plutonium\Desktop\tdata.py", line 51, in main
    client = await tdesk.ToTelethon(savePath, CreateNewSession, api)

telethon.errors.common.InvalidBufferError: Invalid response buffer (HTTP code 404)

Future exception was never retrieved
future: <Future finished exception=InvalidBufferError('Invalid response buffer (HTTP code 404)')>

And this error:

maximum recursion depth exceeded in comparison

how fix it ? pls help me.

.......

when support Android file to telethon

Unexpected Exception: No account has been loaded

Can't get the account to "load". Logged in multiple ways (with qr code and number). googled everything I could, used every fix I could find and no help. Somehow it worked with one tdata folder, but I don't how it happened, now as much as I try I can't get it to work again.

Is it possible to somehow log in, but not with api_id and hash_id to make the device seem real OR if possible log in with api_id and hash_id, but make the device not be detected as a bot?

Question. session with phone data

I tried to log into the session file using an old device where I take the session file.

Device Information:

{
"session_file": "+6287787624748",
"phone": "+6287787624748",
"register_time": 1712558990,
"app_id": "6",
"app_hash": "eb06d4abfb49dc3eeb1aeb98ae0f581e",
"sdk": "SDK 33",
"app_version": "10.10.1 (4583)",
"device": "samsung SM-A226B",
"last_check_time": 1712559105,
"avatar": null,
"first_name": "Harta",
"last_name": "Ibrahim",
"username": "JohnxRuiz17",
"birthday": [
"day: 13",
"month: 5",
"year: None"
],
"twoFA": null,
"sex": 0,
"lang_code": "en",
"system_lang_code": "en-us",
"proxy": null,
"ipv6": false,
"timezone": "25200",
"register_layer": 177,
"device_auth_token": "fXJqjH-qSpmkeMLgr3dRs-:APA91bERJOhfQxChXRbJQVzZC7hotE1M6VMTkpC-yUxBD3i-liWF4vI4iYPexETYawg9SHlNmYTTHNBnx9cl6QPzUBKSEZZbNFbP28l2TtTCEWblKgMAJpZ1dIPmwCSrk7JzPrgTjjeP",
"device_auth_token_sign": "vwfshZ6hrYiyR/i05CHq0GUZkOyvIGrHXQEc5v8F2vml7i31lCWEf6FkWX2bxX6X6hjoeE1xx8ulGat3xMSIow==",
"device_auth_token_secret": "b"\xe8\xe77J\xbfw\xa6\xbdU\xa5\x1e\x9fv\xda0n\xfeG\x16V\xb8 X\x1c\xe0\xf8\xb6\xcb\xe2V)d\x9a2\xf5q\x03\x85\x97(\x11\x81u\x89\x18\xf8\xbb\xe5K\xb6T\xc6\xa7\xa2\xe0\x07\xdb\r\x99G,i\xa3\x8c[Si\xb1 \xef\x1b\xfdd\x13\xab\x889\xb6\xd6\xdc\x9d\x85\t'zIg\x94\xadq\x98\xdc\xfa&\x04\x86\x92\x8f\x9ej\x9fX\xf7E 1Y\xce\x81\xbcz\xe7E\x10[\xb3\xfbM\xc5\x11\x16\xb1&vQE\xb9\xc8\xb7\xf1\xd2\xacf(g\xd5\x0b?\xc4~\xd6\x94\x84\xaf\x94\xe0\x90\r\xef\xb8\x9a\x94\xa4\xd9\x8e5\xd0\x9b\xf9\xe1$\x95\x02\x05\xd2\xd4p\x9cYC\xa38M1\x12\xe3.\xb1@\x16\xa8\x0b\xef\xb7\x1d\xdf&1&[JBe\xc9\x0e^\x15\xd5\x9b\xad\xb9\xd6y\xc8z70N^<\x01c\xae4P\xd40eh\xfe\x8aR\x88\xf4U\x92\xdd\xc6\x1b1.\x85\x11\x97\xa4u)08\x80\xc4,\xac\xbc\xd6\x1d2a\x8e\xd2f<\x1e\xcb]\xa4""
}

i tryed to use code below :

    api = API.TelegramAndroid(api_id=6, api_hash="eb06d4abfb49dc3eeb1aeb98ae0f581e", lang_code='en',
                              device_model="samsung SM-A226B",
                              system_version="SDK 33", app_version="10.9.1 (4464)")
    print(api)
    client = TelegramClient(session=session_file_path, api=api)

    await client.connect()
    await client.PrintSessions()

but i have error like this: telethon.errors.rpcerrorlist.SessionRevokedError: The authorization has been invalidated, because of the user terminating all sessions (caused by GetAuthorizationsRequest)

Can anyone tell me what I'm doing wrong?

Convert data from GetAuthorizationsRequest to params new client

The situation is that there are several devices that use the Telethon + Opentele API. Is there some way to convert data from:

result = await client(functions.account.GetAuthorizationsRequest())
result = result.__getattribute__('authorizations')

into query parameters to generate a new client?

client = TelegramClient("telethon.session", api=api)
await client.connect()

I noticed that the client's parameters and the response to the request differ in some parameters.

'TelegramAndroid() = {
    api_id: 6
    api_hash: eb06d4abfb49dc3eeb1aeb98ae0f581e
    device_model: Huawei HUAWEI Y516-T00
    system_version: SDK 29
    app_version: 8.4.1 (2522)
    system_lang_code: en-US
    lang_pack: android
    lang_code: en
    pid: 14167883335082106939
}'

but from

GetAuthorizationsRequest()

slightly different data

device_model='Huawei Y516-'
system_version='10 Q (29)'
app_version='8.4.1'

Can't install from github

I use the command:
pip install git+https://github.com/thedemons/opentele.git
Td and tl are not installed.

RuntimeError: Event loop is closed

Hello,
I am using ".session to tdata" feature.
But it gives error:

Traceback (most recent call last):
  File "C:\Users\honur\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\honur\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\honur\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon
    self._check_closed()
  File "C:\Users\honur\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000019F5C6B1CF0>
Traceback (most recent call last):
  File "C:\Users\honur\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\honur\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\honur\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon
    self._check_closed()
  File "C:\Users\honur\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

I think its something about async but could not figure it out. Can you help?

Impossible to unload TDesktop instance.

Hello. As soon as an instance of the TDesktop class is created, it immediately starts working with tdata folder and never stops it again until the Python process cleans up open handlers before closing. Therefore, nothing can be done with the tdata folder and all other parent folders.

It would be nice to do something like a method close to close any opened handlers and another stuff.

Proof:

from opentele.td import TDesktop
from asyncio import get_event_loop
from os import remove

tdata = "path_to_tdata"

async def main():
    tdesk = TDesktop(tdata)
    assert tdesk.isLoaded()


if __name__ == "__main__":
    loop = get_event_loop()
    loop.run_until_complete(main())
    remove(tdata) # this line will always raise PermissionError: [WinError 5] Access denied

authorization

hi there , i have a question about the library since the doc want really clear for me

since telegram decides the unofficial telegram apps cant sign up any account , how can i sign up my number using libraries?
and i found your library but its not clear for me why should we have telegram app on our machine? cant we just simply register the numbers using offical api? btw tnx for such a nice library and my poor english <3

TypeError: writeInt64(self, i: int): argument 1 has unexpected type 'NoneType'

Describe the bug
I took the code from the example to create the tdata folder and created a session through the telethon library

Code

Next, I specified this session in this code

Code

A tdata folder is created, and another one is stored in it, where only maps are stored. That's not enough for a full tdata

Expected behavior
I wanted to see the tdata in the created folder

tl/telethon.py AuthMethods._on_login isn't awaited

Describe the bug
I think that this bug caused the absence of authkey in the .session file

To Reproduce
Steps to reproduce the behavior:

  1. Using ToTelethon method on TDesktop

Additional context
/opentele/tl/telethon.py:686: RuntimeWarning: coroutine 'AuthMethods._on_login' was never awaited
newClient._on_login(result.user) # type: ignore

No account has been loaded

Python version: 3.8.2
Pip version: 22.3.1
Operation System: Windows 10 (10.0.19044)

Tdata:
Снимок экрана 2022-12-13 233245

Code:

from opentele.td import TDesktop
from opentele.tl import TelegramClient
from opentele.api import API, UseCurrentSession
import asyncio

async def main():

    # Load TDesktop client from tdata folder
    tdataFolder = r"C:\Users\Alex\Downloads\15\79872317223\tdata"
    tdesk = TDesktop(tdataFolder)
    
    # Check if we have loaded any accounts
    assert tdesk.isLoaded()

    # flag=UseCurrentSession
    #
    # Convert TDesktop to Telethon using the current session.
    client = await tdesk.ToTelethon(session="telethon.session", flag=UseCurrentSession)
    
    # Connect and print all logged-in sessions of this client.
    # Telethon will save the session to telethon.session on creation.
    await client.connect()
    await client.PrintSessions()

asyncio.run(main())

Error:

Traceback (most recent call last):
  File "test.py", line 63, in <module>
    asyncio.run(main())
  File "C:\Program Files\Python38\lib\asyncio\runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "test.py", line 48, in main
    tdesk = TDesktop(tdataFolder)
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 141, in __init__ 
    self.LoadTData()
PS D:\Code\Python\TgTool> py test.py
Traceback (most recent call last):
  File "test.py", line 25, in <module>
    asyncio.run(main())
  File "C:\Program Files\Python38\lib\asyncio\runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "test.py", line 10, in main
    tdesk = TDesktop(tdataFolder)
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 141, in __init__ 
    self.LoadTData()
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 216, in LoadTData
    raise e
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 203, in LoadTData
    self.__loadFromTData()
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 453, in __loadFromTData
    Expects(len(self.accounts) > 0, "No account has been loaded")
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\exception.py", line 326, in Expects
    raise exception
  File "C:\Users\Alex\AppData\Roaming\Python\Python38\site-packages\opentele\td\tdesktop.py", line 453, in __loadFromTData
    Expects(len(self.accounts) > 0, "No account has been loaded")
opentele.exception.OpenTeleException: Unexpected Exception: No account has been loaded [ Called by BaseObject.TDesktop.__loadFromTData() ]

TDesktopUnauthorized problem

Hello, for some reason I started receiving this error, everything has been working literally yesterday.
Can you explain what causes this issue?

Here is my code

from opentele.td import TDesktop
from opentele.tl import TelegramClient
from opentele.api import API, CreateNewSession


try:
      tdesk = TDesktop(path)
      api = API.TelegramDesktop.Generate()
      await tdesk.ToTelethon("session.session", CreateNewSession, api, password="6754")
except FloodWaitError:
      pass

Can I use a proxy? Thank you

Can I use a proxy? Thank you

tdesk = await client.ToTDesktop(flag=UseCurrentSession)

// like
client = TelegramClient('sessions.session',111,'c1111111119',proxy=('socks5','127.0.0.1',8080))

Feature request

My account got banned using this module. I had used it just 3-4 times and the next day my account got banned for suspicious activities.
Can you tell me why is this happening. If have done something wrong or does it really gets you banned. I used the Current session flag instead of new session flag from the demo code. I wanted to use my current desktop session without entering number and otp. Thanks

1

1

Interception of updates from the client does not work

I plan to use event interception (namely messages) from the client, but this does not work. Here is the code:

import asyncio

from opentele.td import TDesktop
from opentele.tl.telethon import UseCurrentSession
from telethon.events import NewMessage


async def handler(event):
    print(type(event))


async def main():
    tdata_folder = "path_to_tdata"
    tdesktop = TDesktop(tdata_folder)
    client = await tdesktop.ToTelethon("name_of_session", flag=UseCurrentSession)
    await client.connect()
    client.add_event_handler(handler, NewMessage(outgoing=True))
    await client.run_until_disconnected()


asyncio.run(main())

When I use the "regular" telethon, the outgoing message handler works.

What do you think about this?

proxy param does not work

i need set proxy for each converted account(let's say i have 10 tdata and 10 http proxy)
after i set proxy param and convert to .session i get same ip like i have on my pc, but not proxy ip.

client = await tdesk.ToTelethon(f"tdata\\{i}\\newSession.session", flag=CreateNewSession, proxy=(socks.HTTP, proxy_data['ip'], int(proxy_data['port"]), True, proxy_data["login"], proxy_data["password"]) )

tdesk.isLoaded() failed assertion with new tdatas

Describe the bug
You can capture the problem if you'll try to import fresh new tdatas, I think tdata folder structure was changed by Telegram

To Reproduce
Steps to reproduce the behavior:

  1. Get fresh new tdata
  2. Try to load it with TDesktop

Expected behavior
Loaded tdesk object with account(s) loaded

Snippet

    try:
        tdesk = TDesktop(f"{tdata}")
        assert tdesk.isLoaded()
    except:
        print('No accounts loaded, skipping')
        accounts_not_loaded += 1
        continue

Create new session bug

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

cannot import name 'password' from 'telethon'

Hi

I am having problems:
cannot import name 'password' from 'telethon'

It happened when I just installed opentele and tried to import the library

telethon version = 1.4.3

Looking forward to your support. Thanks

image

Getting SessionPasswordNeededError

Whenever I try to use current session I still get SessionPasswordNeededError:
SessionPasswordNeededError('Two-steps verification is enabled and a password is required (caused by GetAuthorizationsRequest)')

I tried both method of obtaining TelegramClient, in both CurrentSession flag was used.

 # client = await TelegramClient.FromTDesktop(tdesk, session=None, flag=UseCurrentSession, proxy=proxy)
    client = await tdesk.ToTelethon(session=None, flag=UseCurrentSession, proxy=proxy)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.