-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_start.py
More file actions
138 lines (116 loc) Β· 3.84 KB
/
quick_start.py
File metadata and controls
138 lines (116 loc) Β· 3.84 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/env python3
"""
Quick start script for the Discord Prediction Market Bot.
This script will:
1. Validate your setup
2. Run basic tests
3. Start the bot if everything is working
"""
import asyncio
import os
import subprocess
import sys
from pathlib import Path
def run_command(command: str, description: str) -> bool:
"""Run a command and return success status."""
print(f"π {description}...")
try:
result = subprocess.run(
command.split(),
capture_output=True,
text=True,
check=True
)
print(f"β
{description} completed")
return True
except subprocess.CalledProcessError as e:
print(f"β {description} failed:")
print(f" Error: {e.stderr}")
return False
except FileNotFoundError:
print(f"β {description} failed: Command not found")
return False
def check_python_version() -> bool:
"""Check if Python version is compatible."""
if sys.version_info < (3, 8):
print(f"β Python 3.8+ required, you have {sys.version}")
return False
print(f"β
Python {sys.version.split()[0]} is compatible")
return True
def check_env_file() -> bool:
"""Check if .env file exists."""
if not os.path.exists('.env'):
print("β .env file not found")
print(" Please copy .env.example to .env and fill in your values:")
print(" cp .env.example .env")
return False
print("β
.env file found")
return True
def check_discord_token() -> bool:
"""Check if Discord token is set."""
from dotenv import load_dotenv
load_dotenv()
token = os.getenv('DISCORD_TOKEN')
if not token or token == 'your_discord_bot_token_here':
print("β Discord token not set in .env file")
print(" Please set DISCORD_TOKEN in your .env file")
return False
print("β
Discord token is configured")
return True
async def main():
"""Main quick start process."""
print("π Discord Bot Quick Start")
print("=" * 50)
# Check Python version
if not check_python_version():
return False
# Check .env file
if not check_env_file():
return False
# Check Discord token
try:
if not check_discord_token():
return False
except ImportError:
print("β python-dotenv not installed")
print(" Installing dependencies...")
if not run_command("pip install -r requirements.txt", "Installing dependencies"):
return False
if not check_discord_token():
return False
# Validate setup
print(f"\nπ Validating setup...")
if not run_command("python scripts/validate_setup.py", "Setup validation"):
print("\nβ Setup validation failed. Please fix the issues above.")
return False
# Run architecture tests
print(f"\nπ§ͺ Testing architecture...")
if not run_command("python scripts/test_setup.py", "Architecture tests"):
print("\nβ Architecture tests failed. Please check the errors above.")
return False
# All checks passed
print(f"\n" + "=" * 50)
print("π All checks passed! Your bot is ready to run.")
print("\nStarting the bot...")
print("Press Ctrl+C to stop the bot")
print("=" * 50)
# Start the bot
try:
import main
await main.main()
except KeyboardInterrupt:
print("\nπ Bot stopped by user")
return True
except Exception as e:
print(f"\nβ Bot failed to start: {e}")
return False
if __name__ == "__main__":
try:
success = asyncio.run(main())
sys.exit(0 if success else 1)
except KeyboardInterrupt:
print("\nπ Goodbye!")
sys.exit(0)
except Exception as e:
print(f"\nπ₯ Quick start error: {e}")
sys.exit(1)