Answer the question
In order to leave comments, you need to log in
How to attach decorators in a loop?
I am making a bot in a telegram that reads messages from several accounts. To receive messages, the following construction is used:
@clien1t.on(events.NewMessage)
async def handler(event):
word = event.message.to_dict()['message']
if (word[:18] == "Код подтверждения:"):
print(word)
@client1.on(events.NewMessage)
@client2.on(events.NewMessage)
async def handler(event):
word = event.message.to_dict()['message']
if (word[:18] == "Код подтверждения:"):
print(word)
@client1.on(events.NewMessage)
@client2.on(events.NewMessage)
@client3.on(events.NewMessage)
@client4.on(events.NewMessage)
...
@client10.on(events.NewMessage)
for i in range(3):
client = TelegramClient(session_names[i], api_id, api_hash)
clients.append(client)
testclient=clients[i]
@testclient.on(events.NewMessage)
async def handler(event):
word = event.message.to_dict()['message']
if (word[:18] == "Код подтверждения:"):
print(word)
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