Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import re
- from telethon import TelegramClient, events
- from telethon.tl.functions.account import UpdateStatusRequest
- import asyncio
- print('App start')
- async def online(client):
- #await client.connect()
- print('online started')
- while True:
- print(await client( UpdateStatusRequest(offline=False) ) )
- await asyncio.sleep(30)
- async def main(API_ID = ,#циферки
- API_HASH = '',#букофки
- COUNT = 1):
- print('main started')
- client_list = []
- kek = 0
- print('clients creating started')
- for i in range(COUNT):
- client= TelegramClient(f'main{i}', API_ID, API_HASH)
- async with client:
- @client.on(events.NewMessage(func=lambda e: e))
- async def check(event):
- await cleint.send_message('me', f'Task {event}')
- print('SOMETHING!!!')
- client_list.append(client)
- print('clients creating finished')
- tasks = []
- print('client\'s tasks creating started')
- for client in client_list:
- await client.start()
- tasks.append( asyncio.ensure_future( online(client) ) )
- await asyncio.wait(tasks)
- print('clients\' tasks creating finished')
- loop = asyncio.get_event_loop()
- loop.create_task(main())
- print('loop created!')
- loop.run_forever()
Advertisement
Add Comment
Please, Sign In to add comment