forked from Codeflix-Bots/FileStore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
45 lines (39 loc) · 1.04 KB
/
main.py
File metadata and controls
45 lines (39 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import asyncio
from bot import Bot, web_app
from pyrogram import idle
from config import *
async def main():
# 1. Initialize the Bot Instance
# Using the variables defined in your config.py
bot = Bot(
SESSION,
WORKERS,
DB_CHANNEL,
FSUBS,
TOKEN,
ADMINS,
MESSAGES,
AUTO_DEL,
DB_URI,
DB_NAME,
API_ID,
API_HASH,
PROTECT,
DISABLE_BTN
)
# 2. Start the Bot and Web Server (Health Check)
# This keeps the bot alive on platforms like Render, Koyeb, or Heroku
await bot.start()
await web_app()
print("Success: Bot and Web Server are now running...")
# 3. Keep the script running
# This prevents the script from exiting immediately
await idle()
# 4. Graceful Shutdown
await bot.stop()
if __name__ == "__main__":
# Execution using the asyncio event loop
try:
asyncio.get_event_loop().run_until_complete(main())
except KeyboardInterrupt:
print("Bot stopped manually.")