Muttered3 commited on
Commit
574a3cf
·
verified ·
1 Parent(s): dafbf67

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +29 -0
main.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ import os
3
+ import nest_asyncio
4
+ from telethon import TelegramClient
5
+ from telethon.sessions import MemorySession
6
+ from dummy_server import run_server
7
+ from bot import setup_handlers
8
+ from worker import run_worker
9
+
10
+ nest_asyncio.apply()
11
+
12
+ async def main():
13
+ api_id = int(os.environ["API_ID"])
14
+ api_hash = os.environ["API_HASH"]
15
+ bot_token = os.environ["BOT_TOKEN"]
16
+
17
+ client = TelegramClient(MemorySession(), api_id, api_hash)
18
+ await client.start(bot_token=bot_token)
19
+
20
+ setup_handlers(client)
21
+
22
+ await asyncio.gather(
23
+ run_server(),
24
+ client.run_until_disconnected(),
25
+ run_worker(client),
26
+ )
27
+
28
+ if __name__ == "__main__":
29
+ asyncio.run(main())