Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,18 +2,39 @@ import gradio as gr
|
|
2 |
import subprocess
|
3 |
import threading
|
4 |
|
5 |
-
|
|
|
6 |
def run_bot():
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
|
|
9 |
threading.Thread(target=run_bot, daemon=True).start()
|
10 |
|
11 |
def launch_bot():
|
12 |
-
return "
|
|
|
|
|
|
|
13 |
|
14 |
with gr.Blocks() as demo:
|
15 |
gr.Markdown("# π¬ TheMovieProviderBot Interface")
|
16 |
gr.Markdown("Interact with the bot on Telegram.")
|
17 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
demo.launch()
|
|
|
2 |
import subprocess
|
3 |
import threading
|
4 |
|
5 |
+
logs = ""
|
6 |
+
|
7 |
def run_bot():
|
8 |
+
global logs
|
9 |
+
process = subprocess.Popen(
|
10 |
+
["python3", "bot.py"],
|
11 |
+
stdout=subprocess.PIPE,
|
12 |
+
stderr=subprocess.STDOUT,
|
13 |
+
text=True,
|
14 |
+
bufsize=1
|
15 |
+
)
|
16 |
+
for line in process.stdout:
|
17 |
+
logs += line
|
18 |
|
19 |
+
# Start the bot in a background thread
|
20 |
threading.Thread(target=run_bot, daemon=True).start()
|
21 |
|
22 |
def launch_bot():
|
23 |
+
return "β
Bot launched successfully."
|
24 |
+
|
25 |
+
def get_logs():
|
26 |
+
return logs[-2000:] # Show last 2000 characters
|
27 |
|
28 |
with gr.Blocks() as demo:
|
29 |
gr.Markdown("# π¬ TheMovieProviderBot Interface")
|
30 |
gr.Markdown("Interact with the bot on Telegram.")
|
31 |
+
gr.Markdown("[π¦ Click here to download bot files](static/setup.zip)")
|
32 |
+
|
33 |
+
with gr.Row():
|
34 |
+
gr.Button("Start Bot").click(launch_bot)
|
35 |
+
gr.Button("π Refresh Logs")
|
36 |
+
|
37 |
+
log_output = gr.Textbox(label="π Bot Logs", lines=20)
|
38 |
+
demo.load(get_logs, None, log_output, every=3)
|
39 |
|
40 |
+
demo.launch()
|