Stable version 1.0
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -174,3 +174,7 @@ cython_debug/
|
||||
# PyPI configuration file
|
||||
.pypirc
|
||||
|
||||
# Other files
|
||||
config.ini
|
||||
*.log
|
||||
*.log.*
|
31
dockerfile
Normal file
31
dockerfile
Normal file
@@ -0,0 +1,31 @@
|
||||
# Use official Python image
|
||||
FROM python:3.11-slim
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
gcc \
|
||||
python3-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy requirements first to leverage Docker cache
|
||||
COPY requirements.txt .
|
||||
|
||||
# Install Python dependencies
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy the rest of the application
|
||||
COPY . .
|
||||
|
||||
# Create a non-root user and switch to it
|
||||
RUN useradd -m botuser && chown -R botuser:botuser /app
|
||||
USER botuser
|
||||
|
||||
# Set environment variables for configuration
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
ENV CONFIG_PATH=/app/config.ini
|
||||
|
||||
# Command to run the bot
|
||||
CMD ["python", "pterodisbot.py"]
|
10
embed_locations.json
Normal file
10
embed_locations.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"401095ca": {
|
||||
"channel_id": "1392730642206429307",
|
||||
"message_id": "1395282129377689671"
|
||||
},
|
||||
"548c4f18": {
|
||||
"channel_id": "1392730682576343121",
|
||||
"message_id": "1395282135237001358"
|
||||
}
|
||||
}
|
48
generate_config.py
Normal file
48
generate_config.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import os
|
||||
import configparser
|
||||
from pathlib import Path
|
||||
|
||||
def validate_env_vars():
|
||||
"""Validate that required environment variables are set and non-empty."""
|
||||
required_vars = [
|
||||
'DISCORD_TOKEN',
|
||||
'ALLOWED_GUILD_ID',
|
||||
'PANEL_URL',
|
||||
'CLIENT_API_KEY',
|
||||
'APPLICATION_API_KEY'
|
||||
]
|
||||
|
||||
missing_vars = [var for var in required_vars if not os.getenv(var)]
|
||||
if missing_vars:
|
||||
raise ValueError(f"Missing required environment variables: {', '.join(missing_vars)}")
|
||||
|
||||
def generate_config():
|
||||
"""Generate config.ini from environment variables."""
|
||||
# Validate environment variables first
|
||||
validate_env_vars()
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
# Discord section - ensure all values are strings
|
||||
config['Discord'] = {
|
||||
'Token': str(os.getenv('DISCORD_TOKEN')),
|
||||
'AllowedGuildID': str(os.getenv('ALLOWED_GUILD_ID'))
|
||||
}
|
||||
|
||||
# Pterodactyl section - ensure all values are strings
|
||||
config['Pterodactyl'] = {
|
||||
'PanelURL': str(os.getenv('PANEL_URL')),
|
||||
'ClientAPIKey': str(os.getenv('CLIENT_API_KEY')),
|
||||
'ApplicationAPIKey': str(os.getenv('APPLICATION_API_KEY'))
|
||||
}
|
||||
|
||||
# Write to file
|
||||
config_path = Path(os.getenv('CONFIG_PATH', 'config.ini'))
|
||||
config_path.parent.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
with open(config_path, 'w') as configfile:
|
||||
config.write(configfile)
|
||||
print(f"Config file generated at {config_path}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
generate_config()
|
58999
pterodactyl_bot.log.1
Normal file
58999
pterodactyl_bot.log.1
Normal file
File diff suppressed because it is too large
Load Diff
1041
pterodisbot.py
Normal file
1041
pterodisbot.py
Normal file
File diff suppressed because it is too large
Load Diff
3
requirements.txt
Normal file
3
requirements.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
discord.py>=2.3.0
|
||||
aiohttp>=3.8.0
|
||||
configparser>=5.3.0
|
Reference in New Issue
Block a user