Thursday 30 November 2023

telethon and opentele conflict

I'm calling this in main.py:

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


async def save(name, path):
    client = TelegramClient(f"{name}.session")

    tdesk = await client.ToTDesktop(flag=UseCurrentSession)
    tdesk.SaveTData(path)

where I'm using TelegramClient from telethon, and I'm getting an error 'bytes or str expected, not <class 'int'>.' However, when I call it separately or in another file, there are no errors, and everything works

#main.py
 await client.start()
        await client(UpdateUsernameRequest(user_name))
        await save_tdata.save(user_name, f"{user_name}/tdata")

When I remove the line await save_tdata.save(user_name, f"{user_name}/tdata"), the error persists. However, the issue is resolved only when I remove import save_tdata. I want to emphasize that if I run it from other files, for example, create test.py and call save_tdata.save(), everything works fine. I think it somehow conflicts with Telethon. I've tried giving them different names using 'as'.



from telethon and opentele conflict

No comments:

Post a Comment