Spaces:
Paused
Paused
| import streamlit as st | |
| import subprocess | |
| import sys | |
| # Set up the page configuration | |
| st.set_page_config(page_title="Gojo Satoru Telegram Bot", layout="centered") | |
| st.title("Gojo Satoru Telegram Bot") | |
| # Install required packages from requirements.txt | |
| st.markdown("### Installing requirements from `requirements.txt`...") | |
| with st.spinner("Installing dependencies..."): | |
| try: | |
| subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"]) | |
| st.success("Requirements installed successfully.") | |
| except subprocess.CalledProcessError as e: | |
| st.error(f"Failed to install requirements: {e}") | |
| st.stop() # Stop further execution if installation fails | |
| # Run the bot using python3 -m powers | |
| st.markdown("### Running `python3 -m powers`...") | |
| with st.spinner("Launching bot..."): | |
| try: | |
| result = subprocess.run( | |
| [sys.executable, "-m", "powers"], # Running python3 -m powers | |
| stdout=subprocess.PIPE, | |
| stderr=subprocess.PIPE, | |
| text=True | |
| ) | |
| # Display bot logs (stdout and stderr) | |
| st.code(result.stdout + result.stderr, language='bash') | |
| except Exception as e: | |
| st.error(f"Failed to start the bot: {e}") |