Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. ======
  2. run.py
  3. ======
  4. import logging, asyncio
  5. from userbot import *
  6. from ws_server import *
  7.  
  8. logging.basicConfig()
  9.  
  10. async def main():
  11.         await start_websockets_server()
  12.         await start_userbot()
  13.  
  14. asyncio.run(main())
  15.  
  16. ==========
  17. userbot.py
  18. ==========
  19. from telethon.sync import TelegramClient, events
  20. from telethon import types
  21.  
  22. USERS = {
  23.         'myuser' : {
  24.                 'id' : 'something',
  25.                 'hash' : 'something'
  26.         }
  27. }
  28.  
  29. AUTH_USER = 'myuser';
  30.  
  31. async def start_userbot():
  32.         async with TelegramClient(AUTH_USER, USERS[AUTH_USER]['id'], USERS[AUTH_USER]['hash']) as client:
  33.                 me = await client.get_me()
  34.                 MY_USERID = me.id
  35.                 print(MY_USERID)
  36.  
  37.         await client.run_until_disconnected()
  38.  
  39. ============
  40. ws_server.py
  41. ============
  42. import asyncio
  43.  
  44. async def start_websockets_server():
  45.         while True:
  46.                 print('test')
  47.                 await asyncio.sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement