chore: import local project into Gitea
This commit is contained in:
131
run_bots.py
Normal file
131
run_bots.py
Normal file
@@ -0,0 +1,131 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Simple script to run both MeetMe bots with monitoring
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import subprocess
|
||||
import threading
|
||||
from datetime import datetime
|
||||
|
||||
def print_header():
|
||||
"""Print header for the bot runner"""
|
||||
print("""
|
||||
╔══════════════════════════════════════════════════════════════╗
|
||||
║ 🤖 MEETME BOT RUNNER 🤖 ║
|
||||
║ Enhanced Edition ║
|
||||
╚══════════════════════════════════════════════════════════════╝
|
||||
""")
|
||||
|
||||
def run_bot(bot_name, script_name):
|
||||
"""Run a bot in a separate process"""
|
||||
try:
|
||||
print(f"🚀 Starting {bot_name}...")
|
||||
process = subprocess.Popen(
|
||||
[sys.executable, script_name],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
bufsize=1
|
||||
)
|
||||
|
||||
# Print output in real-time
|
||||
for line in process.stdout:
|
||||
timestamp = datetime.now().strftime("%H:%M:%S")
|
||||
print(f"[{timestamp}] {bot_name}: {line.rstrip()}")
|
||||
|
||||
return process
|
||||
except Exception as e:
|
||||
print(f"❌ Error starting {bot_name}: {e}")
|
||||
return None
|
||||
|
||||
def main():
|
||||
"""Main function to run both bots"""
|
||||
print_header()
|
||||
|
||||
# Check if .env file exists
|
||||
if not os.path.exists('.env'):
|
||||
print("❌ .env file not found!")
|
||||
print("Please copy env_template_enhanced.txt to .env and configure it.")
|
||||
return
|
||||
|
||||
# Check if bot scripts exist
|
||||
icebreaker_script = "enhanced_icebreaker_bot.py"
|
||||
responder_script = "enhanced_responder_bot.py"
|
||||
|
||||
if not os.path.exists(icebreaker_script):
|
||||
print(f"❌ {icebreaker_script} not found!")
|
||||
return
|
||||
|
||||
if not os.path.exists(responder_script):
|
||||
print(f"❌ {responder_script} not found!")
|
||||
return
|
||||
|
||||
print("📋 Available bots:")
|
||||
print(" 1. Ice Breaker Bot (sends initial messages)")
|
||||
print(" 2. Auto Responder Bot (responds to incoming messages)")
|
||||
print(" 3. Run both bots")
|
||||
print(" 4. Exit")
|
||||
|
||||
while True:
|
||||
try:
|
||||
choice = input("\n🎯 Select option (1-4): ").strip()
|
||||
|
||||
if choice == "1":
|
||||
print("\n🧊 Starting Ice Breaker Bot...")
|
||||
process = run_bot("Ice Breaker", icebreaker_script)
|
||||
if process:
|
||||
process.wait()
|
||||
break
|
||||
|
||||
elif choice == "2":
|
||||
print("\n🤖 Starting Auto Responder Bot...")
|
||||
process = run_bot("Auto Responder", responder_script)
|
||||
if process:
|
||||
process.wait()
|
||||
break
|
||||
|
||||
elif choice == "3":
|
||||
print("\n🚀 Starting both bots...")
|
||||
print("Note: Ice Breaker Bot will run once and exit")
|
||||
print("Auto Responder Bot will run continuously")
|
||||
|
||||
# Start responder bot first (it runs continuously)
|
||||
responder_process = run_bot("Auto Responder", responder_script)
|
||||
|
||||
# Wait a bit for responder to initialize
|
||||
time.sleep(5)
|
||||
|
||||
# Start ice breaker bot
|
||||
icebreaker_process = run_bot("Ice Breaker", icebreaker_script)
|
||||
|
||||
# Wait for ice breaker to complete
|
||||
if icebreaker_process:
|
||||
icebreaker_process.wait()
|
||||
|
||||
print("\n✅ Ice Breaker Bot completed. Auto Responder Bot continues running...")
|
||||
print("Press Ctrl+C to stop the Auto Responder Bot")
|
||||
|
||||
# Keep responder running
|
||||
if responder_process:
|
||||
responder_process.wait()
|
||||
break
|
||||
|
||||
elif choice == "4":
|
||||
print("👋 Goodbye!")
|
||||
break
|
||||
|
||||
else:
|
||||
print("❌ Invalid choice. Please select 1-4.")
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("\n⏹️ Stopped by user")
|
||||
break
|
||||
except Exception as e:
|
||||
print(f"❌ Error: {e}")
|
||||
break
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user