Stable version 1.0

This commit is contained in:
k.eaven committed 2025-07-17 05:23:07 -07:00
1 parent b53401481d
commit fbcc04a999
7 files changed
+60136

No files matched your search

+4
View File
@@ -174,3 +174,7 @@ cython_debug/
# PyPI configuration file # PyPI configuration file
.pypirc .pypirc
# Other files
config.ini
*.log
*.log.*
+31
View 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
View File
@@ -0,0 +1,10 @@
{
"401095ca": {
"channel_id": "1392730642206429307",
"message_id": "1395282129377689671"
},
"548c4f18": {
"channel_id": "1392730682576343121",
"message_id": "1395282135237001358"
}
}
+48
View 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
View File
File diff suppressed because it is too large. Load diff
+1041
View File
File diff suppressed because it is too large. Load diff
+3
View File
@@ -0,0 +1,3 @@
discord.py>=2.3.0
aiohttp>=3.8.0
configparser>=5.3.0