Reooiq commited on
Commit
cbb507a
·
verified ·
1 Parent(s): 4925afa

Update bot.py

Browse files
Files changed (1) hide show
  1. bot.py +11 -6
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
- app_fastapi = demo.app
328
 
329
- @app_fastapi.get("/health")
330
- @app_fastapi.head("/health")
331
  async def health_check():
332
  return {"status": "ok", "timestamp": time.time()}
333
 
334
- @app_fastapi.get("/ping")
335
- @app_fastapi.head("/ping")
336
  async def ping():
337
  return {"status": "alive"}
338
 
339
- demo.launch(server_name="0.0.0.0", server_port=7860, prevent_thread_lock=False)
 
 
 
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()