'Function not executing in telethon
If I start the client at the beginning of the script
api_id = 123254534
api_hash = '124324235543'
client = TelegramClient('parslon', api_id, api_hash)
client.start()
***
def three_step(message):
url = ""
url = message.text
bot.send_message(id_chata, 'test..')
thread_ = threading.Thread(target=kosat, args=(url,))
thread_.start()
def kosat(url):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
channel = client.get_entity(url)
Then on the line - channel = client.get_entity(url) the script stops working further. My guess is that the problem is that the authorizes in the main thread, and this code is already running in another. But I'm not sure. I tried using async but it didn't work either.
In general, the code works if you put the client's authorization directly before channel = client.get_entity(url). But I do not need it, because I get a Database error with several calls to the function.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
