File size: 981 Bytes
222f19c
0d44831
350b6eb
 
0d44831
 
222f19c
0d44831
3140238
ffdffe9
 
222f19c
0d44831
 
 
 
 
 
4b81f85
350b6eb
0d44831
ffdffe9
0d44831
 
 
 
 
 
 
 
 
4b81f85
0d44831
ffdffe9
0d44831
ffdffe9
0d44831
 
 
 
350b6eb
222f19c
0d44831
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
# main.py

import logging
import uvicorn
from fastapi import FastAPI
import asyncio

from bot import start_bot

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

app = FastAPI(
    title="Terabox Downloader Bot API",
    version="1.0.0"
)

dp, bot = start_bot()

@app.on_event("startup")
async def startup_event():
    logger.info("Starting bot polling in background...")
    asyncio.create_task(dp.start_polling(bot))

@app.get("/", tags=["root"])
async def read_root():
    return {
        "message": "✅ Terabox Downloader Bot is running!",
        "workers": "4",  # You can even dynamically count your workers
        "status": "OK"
    }

@app.get("/health", tags=["health"])
async def health_check():
    return {
        "status": "ok",
        "bot_username": (await bot.me()).username,
        "forward_channel": f"{bot.id}",
        "version": "1.0.0"
    }

if __name__ == "__main__":
    uvicorn.run("main:app", host="0.0.0.0", port=7860)