Guest User

Untitled

a guest
Jul 9th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | None | 0 0
  1. import time
  2. import re
  3.  
  4. from telethon import TelegramClient, events
  5. from telethon.tl.functions.account import UpdateStatusRequest
  6.  
  7. import asyncio
  8.  
  9. print('App start')
  10.  
  11. async def online(client):
  12.     #await client.connect()
  13.     print('online started')
  14.     while True:
  15.        
  16.         print(await client( UpdateStatusRequest(offline=False) )   )
  17.         await asyncio.sleep(30)
  18.  
  19.  
  20. async def main(API_ID = ,#циферки
  21.     API_HASH = '',#букофки
  22.     COUNT = 1):
  23.     print('main started')
  24.     client_list = []
  25.     kek = 0
  26.     print('clients creating started')
  27.     for i in range(COUNT)
  28.         client= TelegramClient(f'main{i}', API_ID, API_HASH)
  29.         async with client:
  30.             @client.on(events.NewMessage(func=lambda e: e))
  31.             async def check(event):
  32.                 await cleint.send_message('me', f'Task {event}')
  33.                 print('SOMETHING!!!')
  34.  
  35.             client_list.append(client)
  36.     print('clients creating finished')
  37.     tasks = []
  38.     print('client\'s tasks creating started')
  39.     for client in client_list:
  40.        
  41.         await client.start()
  42.         tasks.append(    asyncio.ensure_future(  online(client)  )    )
  43.     await asyncio.wait(tasks)
  44.     print('clients\' tasks creating finished')
  45. loop = asyncio.get_event_loop()
  46. loop.create_task(main())
  47. print('loop created!')
  48. loop.run_forever()
Advertisement
Add Comment
Please, Sign In to add comment