Update bot.py
Browse files
bot.py
CHANGED
|
@@ -8,6 +8,7 @@ from collections import defaultdict
|
|
| 8 |
from pyrogram import Client, filters
|
| 9 |
from pyrogram.errors import FloodWait
|
| 10 |
from pyrogram.types import InputMediaPhoto, InputMediaVideo, InputMediaDocument, InputMediaAudio
|
|
|
|
| 11 |
|
| 12 |
# ============ إصلاح MIN_CHANNEL_ID ============
|
| 13 |
import pyrogram
|
|
@@ -318,25 +319,29 @@ async def self_ping():
|
|
| 318 |
except Exception as e:
|
| 319 |
logger.debug(f"Self-ping error: {e}")
|
| 320 |
|
|
|
|
| 321 |
def run_gradio():
|
| 322 |
with gr.Blocks(title="Telegram Archiver") as demo:
|
| 323 |
gr.Markdown("# 📡 Telegram Archiver")
|
| 324 |
gr.Markdown("🟢 **الحالة:** البوت يعمل في الخلفية")
|
| 325 |
gr.Textbox(label="الحالة", value="✅ نشط", interactive=False)
|
| 326 |
|
| 327 |
-
|
| 328 |
|
| 329 |
-
@
|
| 330 |
-
@
|
| 331 |
async def health_check():
|
| 332 |
return {"status": "ok", "timestamp": time.time()}
|
| 333 |
|
| 334 |
-
@
|
| 335 |
-
@
|
| 336 |
async def ping():
|
| 337 |
return {"status": "alive"}
|
| 338 |
|
| 339 |
-
|
|
|
|
|
|
|
|
|
|
| 340 |
|
| 341 |
async def main():
|
| 342 |
await app.start()
|
|
|
|
| 8 |
from pyrogram import Client, filters
|
| 9 |
from pyrogram.errors import FloodWait
|
| 10 |
from pyrogram.types import InputMediaPhoto, InputMediaVideo, InputMediaDocument, InputMediaAudio
|
| 11 |
+
from fastapi import FastAPI
|
| 12 |
|
| 13 |
# ============ إصلاح MIN_CHANNEL_ID ============
|
| 14 |
import pyrogram
|
|
|
|
| 319 |
except Exception as e:
|
| 320 |
logger.debug(f"Self-ping error: {e}")
|
| 321 |
|
| 322 |
+
# ============ Gradio + FastAPI ============
|
| 323 |
def run_gradio():
|
| 324 |
with gr.Blocks(title="Telegram Archiver") as demo:
|
| 325 |
gr.Markdown("# 📡 Telegram Archiver")
|
| 326 |
gr.Markdown("🟢 **الحالة:** البوت يعمل في الخلفية")
|
| 327 |
gr.Textbox(label="الحالة", value="✅ نشط", interactive=False)
|
| 328 |
|
| 329 |
+
fastapi_app = FastAPI()
|
| 330 |
|
| 331 |
+
@fastapi_app.get("/health")
|
| 332 |
+
@fastapi_app.head("/health")
|
| 333 |
async def health_check():
|
| 334 |
return {"status": "ok", "timestamp": time.time()}
|
| 335 |
|
| 336 |
+
@fastapi_app.get("/ping")
|
| 337 |
+
@fastapi_app.head("/ping")
|
| 338 |
async def ping():
|
| 339 |
return {"status": "alive"}
|
| 340 |
|
| 341 |
+
gr.mount_gradio_app(fastapi_app, demo, path="/")
|
| 342 |
+
|
| 343 |
+
import uvicorn
|
| 344 |
+
uvicorn.run(fastapi_app, host="0.0.0.0", port=7860)
|
| 345 |
|
| 346 |
async def main():
|
| 347 |
await app.start()
|