Spaces:
Runtime error
Runtime error
File size: 1,487 Bytes
5cf0eef c4cbaf0 6948eae 5cf0eef 2af8f98 c4cbaf0 5cf0eef c4cbaf0 5cf0eef 6948eae 2af8f98 c4cbaf0 2af8f98 6948eae c4cbaf0 2af8f98 6948eae 2af8f98 6948eae c4cbaf0 6948eae 5cf0eef c4cbaf0 6948eae c4cbaf0 6948eae c4cbaf0 | 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 46 47 48 49 50 51 52 53 54 55 56 | """
MTXtyle Bot - Hugging Face Spaces Entry Point (Gradio SDK)
Runs the Telegram bot in a background thread and provides
a Gradio status interface.
"""
import threading
import os
import time
import gradio as gr
bot_status = "β³ Ishga tushirilmoqda..."
def run_bot():
global bot_status
token = os.getenv("BOT_TOKEN")
if not token:
bot_status = "β BOT_TOKEN topilmadi! Settings -> Secrets ga qo'shing."
return
# Import and run bot directly in thread
try:
bot_status = "π Bot yuklanmoqda..."
time.sleep(3)
# Import bot module
import asyncio
from bot import main as bot_main
bot_status = "β
Bot ishlayapti!"
# Run the bot
bot_main()
except Exception as e:
bot_status = f"β Xato: {str(e)[:200]}"
def get_status():
return bot_status
# Start bot in background
bot_thread = threading.Thread(target=run_bot, daemon=True)
bot_thread.start()
# Gradio Interface
with gr.Blocks(title="MTXtyle Bot") as demo:
gr.Markdown("# π€ MTXtyle Telegram Bot")
gr.Markdown("Kiyim va aksessuarlar do'koni uchun Telegram bot")
status_box = gr.Textbox(label="Bot Holati", value=bot_status, interactive=False)
refresh_btn = gr.Button("π Yangilash")
refresh_btn.click(fn=get_status, outputs=[status_box])
demo.load(fn=get_status, outputs=[status_box])
demo.launch(server_name="0.0.0.0", server_port=7860)
|