MM
Где то год назад поднимал вопрос, кроме поднятия проесса других отвветов не было.
Size: a a a
MM
В
a
from telethon import TelegramClient, events
client = TelegramClient('anon', api_id, api_hash)
@client.on(events.NewMessage)
async def my_event_handler(event):
await event.reply('hi!')
client.start()
client.run_until_disconnected()
a
a
ŁT
from telethon import TelegramClient, events
client = TelegramClient('anon', api_id, api_hash)
@client.on(events.NewMessage)
async def my_event_handler(event):
await event.reply('hi!')
client.start()
client.run_until_disconnected()
@
А
c1 = TelegramClient (..)
c2 = TelegramClient (..)
c3 = TelegramClient (..)
...
await c1.start()
await c2.start()
...
c10.run_until_disconnected()
ŁT
c1 = TelegramClient (..)
c2 = TelegramClient (..)
c3 = TelegramClient (..)
...
await c1.start()
await c2.start()
...
c10.run_until_disconnected()
А
А
@
@
c1 = TelegramClient (..)
c2 = TelegramClient (..)
c3 = TelegramClient (..)
...
await c1.start()
await c2.start()
...
c10.run_until_disconnected()
В
import asyncio
import telethon
async def start_client(session_path: str):
client = telethon.TelegramClient(...)
await client.start()
...
def main():
sessions_paths = [
"account1.session",
"account2.session"
]
loop = asyncio.get_event_loop()
coros = [start_client(session_path) for session_path in sessions_paths]
gathered = asyncio.gather(*coros)
loop.run_until_complete(gathered)
if __name__ == '__main__':
main()
@
import asyncio
import telethon
async def start_client(session_path: str):
client = telethon.TelegramClient(...)
await client.start()
...
def main():
sessions_paths = [
"account1.session",
"account2.session"
]
loop = asyncio.get_event_loop()
coros = [start_client(session_path) for session_path in sessions_paths]
gathered = asyncio.gather(*coros)
loop.run_until_complete(gathered)
if __name__ == '__main__':
main()
А
А
import asyncio
import telethon
async def start_client(session_path: str):
client = telethon.TelegramClient(...)
await client.start()
...
def main():
sessions_paths = [
"account1.session",
"account2.session"
]
loop = asyncio.get_event_loop()
coros = [start_client(session_path) for session_path in sessions_paths]
gathered = asyncio.gather(*coros)
loop.run_until_complete(gathered)
if __name__ == '__main__':
main()
@
А
await client.connect()
if await client.is_user_authorized():
l.e(f"no sesson {sessname}")
А