bug fix/install scripts

This commit is contained in:
2026-06-17 13:38:08 -05:00
parent da6767b149
commit c84acc4564
7 changed files with 522 additions and 17 deletions

View File

@@ -0,0 +1,104 @@
# Update Scripts Guide
Simple scripts to update your OC Bot installation with the latest code and fixes from GitHub.
## What Was Fixed Recently
### 1. **database.py** - SQL Syntax Errors
- Added backticks around reserved SQL keywords (`trigger`, `characters`)
- Fixed all database queries to work with MariaDB 10.5+
- Maintains cached trigger lookups for performance
### 2. **cogs/help.py** - Command Conflict Fix
- Fixed conflict with discord.py's built-in help command
- Help command now works as `,help` without errors
- Support for `,help <topic>` still works
### 3. **requirements.txt** - Python 3.13 Support
- Updated discord.py to >=2.5.0 for Python 3.13 compatibility
- Fixed `audioop` module error
- All dependencies now verified working
## Usage
### Linux / macOS
```bash
bash update.sh
```
The script will:
- ✅ Check for Git repository
- ✅ Fetch latest changes from GitHub
- ✅ Pull code updates
- ✅ Create/activate virtual environment
- ✅ Upgrade pip
- ✅ Install/update all dependencies
- ✅ Show warnings if database changes needed
### Windows
```bash
update.bat
```
Same process as Linux, but Windows-compatible.
## Features
- **Smart Detection**: Only updates dependencies if requirements.txt changed
- **Change Tracking**: Shows which files were modified
- **Safety Checks**: Warns about database changes
- **Error Handling**: Reports any failures immediately
- **Restart Guidance**: Tells you when to restart the bot
## If You Get Database Errors
After updating, if you see SQL errors, recreate the database:
```sql
DROP DATABASE rp_bot;
CREATE DATABASE rp_bot;
```
The bot will automatically recreate tables with the correct schema.
## Manual Update Steps
If the scripts don't work, do this manually:
```bash
# 1. Pull latest code
git pull origin main
# 2. Activate virtual environment
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate.bat # Windows
# 3. Install dependencies
pip install --upgrade -r requirements.txt
# 4. Restart bot
python3 bot.py
```
## Recent Changes Summary
| File | Change | Impact |
|------|--------|--------|
| database.py | Fixed SQL syntax for reserved keywords | Database operations now work on MariaDB |
| cogs/help.py | Removed command conflict | Help command now loads without errors |
| requirements.txt | Updated discord.py to 2.5.0+ | Python 3.13 compatibility |
## Support
If updates fail:
1. Check Git is installed: `git --version`
2. Check Python version: `python3 --version` (need 3.11+)
3. Check MySQL/MariaDB is running
4. Try manual update steps above
---
**Coded by Ball Studios 🎨**

105
SCRIPTS/update/update.bat Normal file
View File

@@ -0,0 +1,105 @@
@echo off
REM OC Bot - Smart Update Script (Windows)
REM Usage: update.bat
REM Pulls latest code and applies only necessary changes
REM Coded by Ball Studios 🎨
setlocal enabledelayedexpansion
echo =========================================
echo OC Bot - Smart Update Script
echo Coded by Ball Studios 🎨
echo =========================================
echo.
REM Check if this is a git repository
if not exist ".git" (
echo ❌ This is not a Git repository!
echo Please clone from GitHub first
pause
exit /b 1
)
echo 📦 Checking for updates...
echo.
REM Fetch latest changes from GitHub
echo 🔄 Fetching latest code from GitHub...
git fetch origin
if errorlevel 1 (
echo ❌ Git fetch failed!
pause
exit /b 1
)
echo ✅ Fetched latest changes
echo.
REM Check if there are updates available
for /f %%i in ('git rev-parse HEAD') do set LOCAL=%%i
for /f %%i in ('git rev-parse origin/main') do set REMOTE=%%i
if "!LOCAL!"=="!REMOTE!" (
echo ✅ Already up to date!
) else (
echo 📥 Pulling latest changes...
git pull origin main
if errorlevel 1 (
echo ❌ Git pull failed!
pause
exit /b 1
)
echo ✅ Code updated
)
echo.
REM Check if virtual environment exists
if not exist "venv" (
echo 📦 Creating virtual environment...
python3 -m venv venv
if errorlevel 1 (
echo ❌ Failed to create virtual environment!
pause
exit /b 1
)
echo ✅ Virtual environment created
)
REM Activate virtual environment
echo 🔧 Activating virtual environment...
call venv\Scripts\activate.bat
echo ✅ Virtual environment activated
echo.
REM Upgrade pip
echo 📦 Upgrading pip...
python -m pip install --upgrade pip >nul 2>&1
echo ✅ Pip upgraded
echo.
REM Update requirements
echo 📦 Installing/updating dependencies...
pip install --upgrade -r requirements.txt
if errorlevel 1 (
echo ❌ Failed to install dependencies!
pause
exit /b 1
)
echo ✅ Dependencies updated
echo.
echo =========================================
echo ✅ Update Complete!
echo =========================================
echo.
echo 📝 Summary:
echo - Code pulled from GitHub
echo - Dependencies updated
echo.
echo ⚠️ If database errors occur, recreate it:
echo DROP DATABASE rp_bot;
echo CREATE DATABASE rp_bot;
echo.
echo ⚙️ Next: Restart the bot to apply updates
echo.
pause

125
SCRIPTS/update/update.sh Normal file
View File

@@ -0,0 +1,125 @@
#!/bin/bash
# OC Bot - Smart Update Script
# Usage: bash update.sh
# Pulls latest code and applies only necessary changes
# Coded by Ball Studios 🎨
set -e
echo "========================================="
echo " OC Bot - Smart Update Script"
echo " Coded by Ball Studios 🎨"
echo "========================================="
echo ""
# Check if this is a git repository
if [ ! -d ".git" ]; then
echo "❌ This is not a Git repository!"
echo "Please clone from GitHub first:"
echo "git clone https://github.com/BallStudios/rp-bot.git"
exit 1
fi
# Check for uncommitted changes
if [ -n "$(git status --porcelain)" ]; then
echo "⚠️ You have uncommitted changes:"
git status --short
echo ""
read -p "Continue anyway? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Update cancelled."
exit 1
fi
fi
echo "📦 Checking for updates..."
echo ""
# Fetch latest changes from GitHub
echo "🔄 Fetching latest code from GitHub..."
git fetch origin
echo "✅ Fetched latest changes"
echo ""
# Check if there are updates available
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse origin/main)
if [ "$LOCAL" = "$REMOTE" ]; then
echo "✅ Already up to date!"
echo ""
else
echo "📥 Pulling latest changes..."
git pull origin main
echo "✅ Code updated"
echo ""
fi
# Check if virtual environment exists
if [ ! -d "venv" ]; then
echo "📦 Creating virtual environment..."
python3 -m venv venv
echo "✅ Virtual environment created"
fi
echo ""
# Activate virtual environment
echo "🔧 Activating virtual environment..."
source venv/bin/activate
echo "✅ Virtual environment activated"
echo ""
# Check for changed files
echo "🔍 Checking for code changes..."
CHANGED_FILES=$(git diff --name-only HEAD origin/main 2>/dev/null || echo "")
if [ -n "$CHANGED_FILES" ]; then
echo "📝 Changed files:"
echo "$CHANGED_FILES" | sed 's/^/ - /'
echo ""
fi
# Upgrade pip
echo "📦 Upgrading pip..."
pip install --upgrade pip > /dev/null 2>&1
echo "✅ Pip upgraded"
echo ""
# Update requirements if changed
if echo "$CHANGED_FILES" | grep -q "requirements.txt"; then
echo "📦 Installing/updating dependencies (requirements.txt changed)..."
pip install --upgrade -r requirements.txt
echo "✅ Dependencies updated"
echo ""
fi
# Database migration notice
if echo "$CHANGED_FILES" | grep -q "database.py"; then
echo "⚠️ database.py has been updated!"
echo ""
echo "If you encounter database errors after restart, run:"
echo " mysql -u root -p -e 'DROP DATABASE rp_bot; CREATE DATABASE rp_bot;'"
echo ""
fi
# Help system migration notice
if echo "$CHANGED_FILES" | grep -q "cogs/help.py"; then
echo "✅ Help system has been updated (fixed conflict with discord.py)"
echo ""
fi
echo "========================================="
echo " ✅ Update Complete!"
echo "========================================="
echo ""
echo "📝 Summary:"
echo "- Code pulled from GitHub"
echo "- Dependencies updated"
if [ -n "$CHANGED_FILES" ]; then
echo "- Files changed: $(echo \"$CHANGED_FILES\" | wc -l)"
fi
echo ""
echo "⚙️ Next: Restart the bot to apply updates"
echo ""