Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ======
- run.py
- ======
- import logging, asyncio
- from userbot import *
- from ws_server import *
- logging.basicConfig()
- async def main():
- await start_websockets_server()
- await start_userbot()
- asyncio.run(main())
- ==========
- userbot.py
- ==========
- from telethon.sync import TelegramClient, events
- from telethon import types
- USERS = {
- 'myuser' : {
- 'id' : 'something',
- 'hash' : 'something'
- }
- }
- AUTH_USER = 'myuser';
- async def start_userbot():
- async with TelegramClient(AUTH_USER, USERS[AUTH_USER]['id'], USERS[AUTH_USER]['hash']) as client:
- me = await client.get_me()
- MY_USERID = me.id
- print(MY_USERID)
- await client.run_until_disconnected()
- ============
- ws_server.py
- ============
- import asyncio
- async def start_websockets_server():
- while True:
- print('test')
- await asyncio.sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement