File size: 1,039 Bytes
b00d2c6
7ce64c9
 
 
eceb86e
 
7ce64c9
eceb86e
 
 
 
 
 
 
 
 
 
7ce64c9
eceb86e
7ce64c9
b00d2c6
 
eceb86e
 
 
69a921f
b00d2c6
 
 
 
eceb86e
 
 
69a921f
 
eceb86e
 
69a921f
 
 
b00d2c6
eceb86e
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
import gradio as gr
import subprocess
import threading

logs = ""

def run_bot():
    global logs
    process = subprocess.Popen(
        ["python3", "bot.py"],
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT,
        text=True,
        bufsize=1
    )
    for line in process.stdout:
        logs += line

# Start the bot in a background thread
threading.Thread(target=run_bot, daemon=True).start()

def launch_bot():
    return "βœ… Bot launched successfully."

def get_logs():
    return logs[-2000:]

with gr.Blocks() as demo:
    gr.Markdown("# 🎬 TheMovieProviderBot Interface")
    gr.Markdown("Interact with the bot on Telegram.")
    gr.Markdown("[πŸ“¦ Click here to download bot files](static/setup.zip)")

    with gr.Row():
        launch_btn = gr.Button("πŸš€ Start Bot")
        refresh_btn = gr.Button("πŸ” Refresh Logs")

    log_output = gr.Textbox(label="πŸ“„ Bot Logs", lines=20)

    launch_btn.click(fn=launch_bot, outputs=None)
    refresh_btn.click(fn=get_logs, outputs=log_output)

demo.launch()