feat: enhance gitignore and bot prefix handling

- Updated .gitignore to properly exclude Python cache files and environment variables
- Modified bot.py to improve prefix case handling for better command recognition
- Refactored mail.py to streamline feedback email generation and database interaction
- Added environment variable loading in mail.py for better configuration management
This commit is contained in:
2026-06-01 14:14:52 +00:00
parent 3e6410d112
commit 4b07ca86b9
10 changed files with 166 additions and 147 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ from typing import Dict
from datetime import datetime
db = DatabaseManager("economy")
db = DatabaseManager()
async def create_account(user: discord.Member | discord.User):
+15 -2
View File
@@ -21,8 +21,17 @@ logger = logging.getLogger(__name__)
class DatabaseManager:
_instances = {}
@classmethod
def _resolve_instance_key(cls, env: str | None) -> str:
key = (env or "").strip()
if not key:
return "default"
env_file = f".env.{key}"
return key if os.path.exists(env_file) else "default"
def __new__(cls, env="development"):
instance_key = env or "default"
instance_key = cls._resolve_instance_key(env)
if instance_key in cls._instances:
return cls._instances[instance_key]
instance = super().__new__(cls)
@@ -49,8 +58,12 @@ class DatabaseManager:
),
}
instance_key = self._resolve_instance_key(env)
pool_name = f"mypool_{instance_key}" if instance_key else "mypool_default"
self.pool = pooling.MySQLConnectionPool(
pool_name="mypool", pool_size=5, **self.config
pool_name=pool_name,
pool_size=5,
**self.config,
)
logger.info("Database connection pool created.")