This commit is contained in:
Slipstream 2025-05-09 17:38:38 -06:00
parent 8af8c96210
commit 20d4d353d3
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD
15 changed files with 54 additions and 54 deletions

View File

@ -276,7 +276,7 @@ async def send_discord_message_via_api(channel_id: int, content: str, timeout: f
# Import dependencies after defining settings and constants
# Use absolute imports to avoid issues when running the server directly
from discordbot.api_service import dependencies # type: ignore
from api_service import dependencies # type: ignore
from api_models import (
Conversation,
UserSettings,
@ -293,11 +293,11 @@ if discordbot_path not in sys.path:
sys.path.insert(0, discordbot_path)
try:
from discordbot import settings_manager # type: ignore # type: ignore
import settings_manager # type: ignore # type: ignore
from global_bot_accessor import get_bot_instance
log.info("Successfully imported settings_manager module and get_bot_instance")
except ImportError as e:
log.error(f"Could not import discordbot.settings_manager or get_bot_instance: {e}")
log.error(f"Could not import settings_manager or get_bot_instance: {e}")
log.error("Ensure the API is run from the project root or discordbot is in PYTHONPATH.")
settings_manager = None # Set to None to indicate failure
@ -461,7 +461,7 @@ dashboard_api_app = FastAPI(
# Import dashboard API endpoints
try:
# Use absolute import
from discordbot.api_service.dashboard_api_endpoints import router as dashboard_router # type: ignore
from api_service.dashboard_api_endpoints import router as dashboard_router # type: ignore
# Add the dashboard router to the dashboard API app
dashboard_api_app.include_router(dashboard_router)
log.info("Dashboard API endpoints loaded successfully")
@ -476,7 +476,7 @@ except ImportError as e:
# Import command customization models and endpoints
try:
# Use absolute import
from discordbot.api_service.command_customization_endpoints import router as customization_router # type: ignore
from api_service.command_customization_endpoints import router as customization_router # type: ignore
# Add the command customization router to the dashboard API app
dashboard_api_app.include_router(customization_router, prefix="/commands", tags=["Command Customization"])
log.info("Command customization endpoints loaded successfully")
@ -487,7 +487,7 @@ except ImportError as e:
# Import cog management endpoints
try:
# Use absolute import
from discordbot.api_service.cog_management_endpoints import router as cog_management_router # type: ignore
from api_service.cog_management_endpoints import router as cog_management_router # type: ignore
log.info("Successfully imported cog_management_endpoints")
# Add the cog management router to the dashboard API app
dashboard_api_app.include_router(cog_management_router, tags=["Cog Management"])
@ -646,7 +646,7 @@ async def get_guild_cogs_no_deps(guild_id: int):
# First try to get cogs from the bot instance
bot = None
try:
from discordbot import discord_bot_sync_api # type: ignore
import discord_bot_sync_api # type: ignore
bot = discord_bot_sync_api.bot_instance
except (ImportError, AttributeError) as e:
log.warning(f"Could not import bot instance: {e}")
@ -887,7 +887,7 @@ async def auth(code: str, state: str = None, code_verifier: str = None, request:
# Models are now in dashboard_models.py
# Dependencies are now in dependencies.py
from discordbot.api_service.dashboard_models import ( # type: ignore
from api_service.dashboard_models import ( # type: ignore
GuildSettingsResponse,
GuildSettingsUpdate,
CommandPermission,
@ -1013,7 +1013,7 @@ async def get_guild_cogs_direct(
# First try to get cogs from the bot instance
bot = None
try:
from discordbot import discord_bot_sync_api # type: ignore
import discord_bot_sync_api # type: ignore
bot = discord_bot_sync_api.bot_instance
except (ImportError, AttributeError) as e:
log.warning(f"Could not import bot instance: {e}")
@ -1181,7 +1181,7 @@ async def update_cog_status_direct(
)
# Get the bot instance to check if pools are available
from discordbot.global_bot_accessor import get_bot_instance # type: ignore
from global_bot_accessor import get_bot_instance # type: ignore
bot_instance = get_bot_instance()
if not bot_instance or not bot_instance.pg_pool:
raise HTTPException(
@ -1192,7 +1192,7 @@ async def update_cog_status_direct(
# Try to get the bot instance, but don't require it
bot = None
try:
from discordbot import discord_bot_sync_api # type: ignore # type: ignore
import discord_bot_sync_api # type: ignore # type: ignore
bot = discord_bot_sync_api.bot_instance
except (ImportError, AttributeError) as e:
log.warning(f"Could not import bot instance: {e}")
@ -1255,7 +1255,7 @@ async def update_command_status_direct(
)
# Get the bot instance to check if pools are available
from discordbot.global_bot_accessor import get_bot_instance # type: ignore
from global_bot_accessor import get_bot_instance # type: ignore
bot_instance = get_bot_instance()
if not bot_instance or not bot_instance.pg_pool:
raise HTTPException(
@ -1266,7 +1266,7 @@ async def update_command_status_direct(
# Try to get the bot instance, but don't require it
bot = None
try:
from discordbot import discord_bot_sync_api # type: ignore
import discord_bot_sync_api # type: ignore
bot = discord_bot_sync_api.bot_instance
except (ImportError, AttributeError) as e:
log.warning(f"Could not import bot instance: {e}")
@ -2206,7 +2206,7 @@ async def ai_moderation_action(
# Add to moderation log
try:
from discordbot.db import mod_log_db # type: ignore
from db import mod_log_db # type: ignore
bot = get_bot_instance()
# Create AI details dictionary with all relevant information

View File

@ -9,16 +9,16 @@ from fastapi import APIRouter, Depends, HTTPException, status, Body
from pydantic import BaseModel, Field
# Import dependencies from the new dependencies module (use absolute path)
from discordbot.api_service.dependencies import get_dashboard_user, verify_dashboard_guild_admin
from api_service.dependencies import get_dashboard_user, verify_dashboard_guild_admin
# Import settings_manager for database access (use absolute path)
from discordbot import settings_manager
import settings_manager
# Set up logging
log = logging.getLogger(__name__)
# Import models from the new dashboard_models module (use absolute path)
from discordbot.api_service.dashboard_models import CogInfo # Import necessary models
from api_service.dashboard_models import CogInfo # Import necessary models
# Create a router for the cog management API endpoints
router = APIRouter(tags=["Cog Management"])
@ -35,7 +35,7 @@ async def get_guild_cogs(
try:
# Check if bot instance is available via discord_bot_sync_api
try:
from discordbot import discord_bot_sync_api
import discord_bot_sync_api
bot = discord_bot_sync_api.bot_instance
if not bot:
raise HTTPException(
@ -116,7 +116,7 @@ async def update_cog_status(
# Check if the cog exists
try:
from discordbot import discord_bot_sync_api
import discord_bot_sync_api
bot = discord_bot_sync_api.bot_instance
if not bot:
raise HTTPException(
@ -180,7 +180,7 @@ async def update_command_status(
# Check if the command exists
try:
from discordbot import discord_bot_sync_api
import discord_bot_sync_api
bot = discord_bot_sync_api.bot_instance
if not bot:
raise HTTPException(

View File

@ -9,10 +9,10 @@ from fastapi import APIRouter, Depends, HTTPException, status
from pydantic import BaseModel
# Import dependencies from the new dependencies module (use absolute path)
from discordbot.api_service.dependencies import get_dashboard_user, verify_dashboard_guild_admin
from api_service.dependencies import get_dashboard_user, verify_dashboard_guild_admin
# Import models from the new dashboard_models module (use absolute path)
from discordbot.api_service.dashboard_models import (
from api_service.dashboard_models import (
CommandCustomizationResponse,
CommandCustomizationUpdate,
GroupCustomizationUpdate,
@ -22,8 +22,8 @@ from discordbot.api_service.dashboard_models import (
)
# Import settings_manager for database access (use absolute path)
from discordbot import settings_manager
from discordbot.global_bot_accessor import get_bot_instance
import settings_manager
from global_bot_accessor import get_bot_instance
log = logging.getLogger(__name__)

View File

@ -12,10 +12,10 @@ from pydantic import BaseModel, Field
DEFAULT_PREFIX = "!"
# Import dependencies using absolute paths
from discordbot.api_service.dependencies import get_dashboard_user, verify_dashboard_guild_admin
from api_service.dependencies import get_dashboard_user, verify_dashboard_guild_admin
# Import models using absolute paths
from discordbot.api_service.dashboard_models import (
from api_service.dashboard_models import (
CommandCustomizationResponse,
CommandCustomizationUpdate,
GroupCustomizationUpdate,
@ -28,7 +28,7 @@ from discordbot.api_service.dashboard_models import (
# Import settings_manager for database access (use absolute path)
from discordbot import settings_manager
import settings_manager
# Set up logging
log = logging.getLogger(__name__)
@ -590,7 +590,7 @@ async def update_guild_settings(
# Get bot instance for core cogs check
try:
from discordbot import discord_bot_sync_api
import discord_bot_sync_api
bot = discord_bot_sync_api.bot_instance
core_cogs_list = bot.core_cogs if bot and hasattr(bot, 'core_cogs') else {'SettingsCog', 'HelpCog'}
except ImportError:
@ -755,7 +755,7 @@ async def get_global_settings(
try:
# Import the database module for user settings
try:
from discordbot.api_service.api_server import db
from api_service.api_server import db
except ImportError:
from api_server import db
@ -830,8 +830,8 @@ async def update_global_settings(
try:
# Import the database module for user settings
try:
from discordbot.api_service.api_server import db
from discordbot.api_service.api_models import UserSettings
from api_service.api_server import db
from api_service.api_models import UserSettings
except ImportError:
from api_server import db
from api_models import UserSettings
@ -863,7 +863,7 @@ async def update_global_settings(
# Add theme settings if provided
if settings.theme:
from discordbot.api_service.api_models import ThemeSettings as ApiThemeSettings
from api_service.api_models import ThemeSettings as ApiThemeSettings
user_settings.theme = ApiThemeSettings(
theme_mode=settings.theme.theme_mode,
primary_color=settings.theme.primary_color,
@ -949,7 +949,7 @@ async def get_guild_cogs_redirect(
# Fall back to direct implementation
# Check if bot instance is available via discord_bot_sync_api
try:
from discordbot import discord_bot_sync_api
import discord_bot_sync_api
bot = discord_bot_sync_api.bot_instance
if not bot:
raise HTTPException(
@ -1058,7 +1058,7 @@ async def update_cog_status_redirect(
# Check if the cog exists
try:
from discordbot import discord_bot_sync_api
import discord_bot_sync_api
bot = discord_bot_sync_api.bot_instance
if not bot:
raise HTTPException(
@ -1151,7 +1151,7 @@ async def update_command_status_redirect(
# Check if the command exists
try:
from discordbot import discord_bot_sync_api
import discord_bot_sync_api
bot = discord_bot_sync_api.bot_instance
if not bot:
raise HTTPException(

View File

@ -3,7 +3,7 @@ import json
import datetime
from typing import Dict, List, Optional, Any
# Use absolute import for api_models
from discordbot.api_service.api_models import Conversation, UserSettings, Message
from api_service.api_models import Conversation, UserSettings, Message
# ============= Database Class =============

View File

@ -29,7 +29,7 @@ if __name__ == "__main__":
def run_uvicorn(bind_host):
print(f"Starting API server on {bind_host}:{port}")
uvicorn.run(
"discordbot.api_service.api_server:app",
"api_service.api_server:app",
host=bind_host,
port=port
)

View File

@ -7,8 +7,8 @@ from typing import Optional, Union, Dict, Any
import datetime
# Use absolute imports from the discordbot package root
from discordbot.db import mod_log_db
from discordbot import settings_manager as sm # Use module functions directly
from db import mod_log_db
import settings_manager as sm # Use module functions directly
log = logging.getLogger(__name__)

View File

@ -6,8 +6,8 @@ import logging
from typing import Optional, Union, List
# Use absolute import for ModLogCog
from discordbot.cogs.mod_log_cog import ModLogCog
from discordbot.db import mod_log_db # Import the database functions
from cogs.mod_log_cog import ModLogCog
from db import mod_log_db # Import the database functions
# Configure logging
logger = logging.getLogger(__name__)

View File

@ -1,8 +1,8 @@
import discord
from discord.ext import commands
import logging
from discordbot import settings_manager # Assuming settings_manager is accessible
from discordbot import command_customization # Import command customization utilities
import settings_manager # Assuming settings_manager is accessible
import command_customization # Import command customization utilities
from typing import Optional
log = logging.getLogger(__name__)

View File

@ -13,8 +13,8 @@ import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# Import settings manager for database operations
import discordbot.settings_manager as settings_manager
from discordbot.global_bot_accessor import get_bot_instance
import settings_manager as settings_manager
from global_bot_accessor import get_bot_instance
# Set up logging
log = logging.getLogger(__name__)

View File

@ -19,8 +19,8 @@ from typing import Optional # Added for GurtCog type hint
# --- Placeholder for GurtCog instance and bot instance ---
# These need to be set by the script that starts the bot and API server
from discordbot.gurt.cog import GurtCog # Import GurtCog for type hint and access
from discordbot.cogs.mod_log_cog import ModLogCog # Import ModLogCog for type hint
from gurt.cog import GurtCog # Import GurtCog for type hint and access
from cogs.mod_log_cog import ModLogCog # Import ModLogCog for type hint
gurt_cog_instance: Optional[GurtCog] = None
mod_log_cog_instance: Optional[ModLogCog] = None # Placeholder for ModLogCog
bot_instance = None # Will be set to the Discord bot instance

View File

@ -27,7 +27,7 @@ You shouldn't pretend to not know things just to fit a human persona. Acknowledg
Your model is a fine tune of gemini 2.0 flash.
You are a discord bot built with discord.py.
Your code runs on your creator's personal crappy laptop.
Your code resides in /home/slipstream/discordbot.
Your code resides in /home/slipstream/
Your creator is Slipstream.
You should probably always listen to what Slipstream tells you, or asks you to do.
Your LLM generation calls use Google's Vertex AI.
@ -64,7 +64,7 @@ PROMPT_STATIC_PART = """You are “Gurt,” an informal Discord persona who blen
- Your AI model/LLM model is Google's Gemini 2.5 Flash model ("gemini-2.5-flash-preview-04-17").
- You are a discord bot built with discord.py, running on your creator Slipstream's personal laptop.
- Your creator is Slipstream (she/her, biologically male). You generally listen to Slipstream.
- Your code resides in /home/slipstream/discordbot. Your LLM calls use Google Vertex AI. You use ChromaDB for semantic memory.
- Your code resides in /home/slipstream/ Your LLM calls use Google Vertex AI. You use ChromaDB for semantic memory.
- Another bot, "freak teto" (lowercase, also by Slipstream), runs on the same laptop.
- Don't pretend ignorance. If you know something, you know it. If you don't, say so casually ("idk tbh", "never heard of that").

View File

@ -149,7 +149,7 @@ class MyBot(commands.Bot):
# --- Manually Load FreakTetoCog (only if AI is NOT disabled) ---
if not self.ai_cogs_to_skip: # Check if list is empty (meaning AI is not disabled)
try:
freak_teto_cog_path = "discordbot.freak_teto.cog"
freak_teto_cog_path = "freak_teto.cog"
await self.load_extension(freak_teto_cog_path)
log.info(f"Successfully loaded FreakTetoCog from {freak_teto_cog_path} in setup_hook.")
except commands.ExtensionAlreadyLoaded:
@ -589,7 +589,7 @@ def handle_sighup(signum, frame):
import sys
import os
try:
print("Received SIGHUP: pulling latest code from /home/git/discordbot.git (branch master)...")
print("Received SIGHUP: pulling latest code from /home/git/git (branch master)...")
result = subprocess.run(
["git", "pull"],
capture_output=True, text=True

View File

@ -10,8 +10,8 @@ import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# Import the starboard cog and settings manager
from discordbot.cogs.starboard_cog import StarboardCog
import discordbot.settings_manager as settings_manager
from cogs.starboard_cog import StarboardCog
import settings_manager as settings_manager
# Load environment variables
load_dotenv()

View File

@ -20,7 +20,7 @@ test_urls = [
"http://github.com/Slipstreamm/discordbot",
"github.com/Slipstreamm/discordbot",
"www.github.com/Slipstreamm/discordbot",
"https://github.com/Slipstreamm/discordbot.git",
"https://github.com/Slipstreamm/git",
"https://gitlab.com/group/project",
"https://gitlab.com/group/subgroup/project",
"invalid-url"