# importing multiclient library and other required importsfromtlmulticlientimportMultiClientimportasynciofromtelethonimportevents# create the multiclientclient=MultiClient(api_id=12345, api_hash='my_api_hash', sessions=['list', 'of', 'str_sessions'])
# listenting to new messages@client.on(events.NewMessage)deflistener(event):
# Now we need to use `event.client.etc` instead of client.etc to be able to run a function on all the available clients!awaitevent.client.send_message(event.chat_id, "Hello World!")
# To find out from which session an event was triggered we use:id=event.client.session_id# session id is the name of the session attached to the client which received the event.ifid=='str_sessions':
print('This event was triggered from the session named str_sessions')
else:
print('This event was triggered from the session named {0}'.format(id))
# iterate though all the clientsforcinclient:
print(c.session_id)
# run all the clientsloop=asyncio.get_event_loop()
client.run_all_clients(loop=loop)