Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ from telegram import Update
|
|
| 11 |
from telegram.ext import ApplicationBuilder, MessageHandler, filters, ContextTypes
|
| 12 |
|
| 13 |
# --- AYARLAR ---
|
| 14 |
-
TOKEN = "8669709095:AAFRPWdZ9gaVX8PXuVsPJMFlUtOHicjyoyg" #
|
| 15 |
ALLOWED_USERS = [7671497065, 6518828406]
|
| 16 |
COMMAND_HISTORY_FILE = "badtime_history.csv"
|
| 17 |
|
|
@@ -67,18 +67,24 @@ async def telegram_bridge(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
| 67 |
|
| 68 |
cmd = update.message.text
|
| 69 |
response = run_shell(cmd)
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
def run_tg_bot():
|
|
|
|
| 73 |
loop = asyncio.new_event_loop()
|
| 74 |
asyncio.set_event_loop(loop)
|
| 75 |
app = ApplicationBuilder().token(TOKEN).build()
|
| 76 |
app.add_handler(MessageHandler(filters.TEXT & (~filters.COMMAND), telegram_bridge))
|
| 77 |
-
|
|
|
|
| 78 |
|
| 79 |
-
# --- GRADIO ARAYÜZÜ ---
|
| 80 |
with gr.Blocks(theme=gr.themes.Monochrome()) as badtime_ui:
|
| 81 |
-
# Sayfa Başlığı (Title yerine Markdown kullanıyoruz)
|
| 82 |
gr.HTML("<title>BadTiMe Control</title>")
|
| 83 |
gr.Markdown("# 💀 BadTiMe Command & Storage Center")
|
| 84 |
|
|
@@ -103,10 +109,9 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as badtime_ui:
|
|
| 103 |
history_refresh.click(get_dashboard_data, outputs=[history_table, stats_plot])
|
| 104 |
|
| 105 |
if __name__ == "__main__":
|
| 106 |
-
|
|
|
|
|
|
|
| 107 |
|
| 108 |
-
#
|
| 109 |
-
badtime_ui.launch(
|
| 110 |
-
server_name="0.0.0.0",
|
| 111 |
-
server_port=7860
|
| 112 |
-
)
|
|
|
|
| 11 |
from telegram.ext import ApplicationBuilder, MessageHandler, filters, ContextTypes
|
| 12 |
|
| 13 |
# --- AYARLAR ---
|
| 14 |
+
TOKEN = "8669709095:AAFRPWdZ9gaVX8PXuVsPJMFlUtOHicjyoyg" # Burayı kontrol et
|
| 15 |
ALLOWED_USERS = [7671497065, 6518828406]
|
| 16 |
COMMAND_HISTORY_FILE = "badtime_history.csv"
|
| 17 |
|
|
|
|
| 67 |
|
| 68 |
cmd = update.message.text
|
| 69 |
response = run_shell(cmd)
|
| 70 |
+
|
| 71 |
+
# Telegram'a terminal çıktısını gönderiyoruz
|
| 72 |
+
if len(response) > 4000:
|
| 73 |
+
response = response[:4000] + "\n...(devamı Dashboard'da)"
|
| 74 |
+
|
| 75 |
+
await update.message.reply_text(f"```\n{response}\n```", parse_mode='Markdown')
|
| 76 |
|
| 77 |
def run_tg_bot():
|
| 78 |
+
"""Telegram botunu yanıt verebilir şekilde başlatır"""
|
| 79 |
loop = asyncio.new_event_loop()
|
| 80 |
asyncio.set_event_loop(loop)
|
| 81 |
app = ApplicationBuilder().token(TOKEN).build()
|
| 82 |
app.add_handler(MessageHandler(filters.TEXT & (~filters.COMMAND), telegram_bridge))
|
| 83 |
+
print("🚀 Telegram Hattı Dinleniyor...")
|
| 84 |
+
app.run_polling(close_loop=False)
|
| 85 |
|
| 86 |
+
# --- GRADIO ARAYÜZÜ (Gradio 6.0 Uyumlu) ---
|
| 87 |
with gr.Blocks(theme=gr.themes.Monochrome()) as badtime_ui:
|
|
|
|
| 88 |
gr.HTML("<title>BadTiMe Control</title>")
|
| 89 |
gr.Markdown("# 💀 BadTiMe Command & Storage Center")
|
| 90 |
|
|
|
|
| 109 |
history_refresh.click(get_dashboard_data, outputs=[history_table, stats_plot])
|
| 110 |
|
| 111 |
if __name__ == "__main__":
|
| 112 |
+
# Telegram Botunu Arka Planda Başlat
|
| 113 |
+
tg_thread = threading.Thread(target=run_tg_bot, daemon=True)
|
| 114 |
+
tg_thread.start()
|
| 115 |
|
| 116 |
+
# Gradio Arayüzünü Başlat
|
| 117 |
+
badtime_ui.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|