Answer the question
In order to leave comments, you need to log in
How can I run multiple Telethon clients?
I found a number of answers, good ones, but these methods are only valid if there are a certain number of accounts. And I need the program to receive data from json accounts, the number of which can be as many as you like, one, two, at least twenty. I tried to implement it by creating a class and declaring an instance of this class for each account. But still, I failed: because in order to declare a decorator, it needs an explicit instance of TelegramClient, and it will not work to declare, because a session file will be created and data must be passed when declaring a client.
class Account:
client = None
def __init__(self, acc):
client = TelegramClient(acc['name'], acc['api_id'], acc['api_hash'])
@client.on(events.NewMessage)
async def my_event_handler(event):
pass
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question