modified: bot.py
This commit is contained in:
58
bot.py
58
bot.py
@@ -30,6 +30,12 @@ OPENAI_BASE_URL = os.getenv("OPENAI_BASE_URL")
|
||||
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
||||
OWNER_ID = int(os.getenv("OWNER_ID"))
|
||||
|
||||
features = {
|
||||
"askmultus": bool(int(os.getenv("ASKMULTUS_ENABLED", 0))),
|
||||
"vision": bool(int(os.getenv("VISION_ENABLED", 0)))
|
||||
}
|
||||
|
||||
|
||||
# Erstelle einen Ordner für die Logs, wenn er noch nicht existiert
|
||||
LOGS_DIR = "logs"
|
||||
if not os.path.exists(LOGS_DIR):
|
||||
@@ -80,8 +86,6 @@ intents = discord.Intents.default()
|
||||
intents.message_content = True
|
||||
intents.reactions = True
|
||||
python = sys.executable
|
||||
vision_enabled = os.getenv("VISION_ENABLED")
|
||||
askmultus_enabled = os.getenv("ASKMULTUS_ENABLED")
|
||||
|
||||
client = commands.Bot(command_prefix='-', intents=intents, owner_id = OWNER_ID)
|
||||
|
||||
@@ -417,7 +421,7 @@ async def owner_command(ctx):
|
||||
@client.hybrid_command()
|
||||
async def askmultus(ctx, *, prompt: str):
|
||||
"""Submits a prompt to Multus for assistance or information. (5 Points)"""
|
||||
if not askmultus_enabled:
|
||||
if not features["askmultus"]:
|
||||
await ctx.send("Sorry, the askmultus feature is currently disabled.")
|
||||
return
|
||||
|
||||
@@ -520,7 +524,7 @@ async def process_ai_queue():
|
||||
@client.hybrid_command()
|
||||
async def vision(ctx, image_url: str):
|
||||
"""Analyzes the content of an image."""
|
||||
if not vision_enabled:
|
||||
if not features["vision"]:
|
||||
await ctx.send("Sorry, the vision feature is currently disabled.")
|
||||
return
|
||||
|
||||
@@ -580,7 +584,6 @@ async def addbackgrounddata(ctx, *, data: str):
|
||||
await ctx.send("You don't have the necessary permissions to use this command.")
|
||||
|
||||
|
||||
|
||||
@client.hybrid_command()
|
||||
async def summarize(ctx, number: int):
|
||||
"""Summarizes the last x messages in the chat."""
|
||||
@@ -641,39 +644,24 @@ async def leave(ctx):
|
||||
await ctx.send("Left the voice channel.")
|
||||
else:
|
||||
await ctx.send("I am not in a voice channel.")
|
||||
|
||||
@client.hybrid_command()
|
||||
async def switch(ctx, mode: str, state: str):
|
||||
"""Switches the state of a specified mode (vision/askmultus)."""
|
||||
global vision_enabled
|
||||
global askmultus_enabled
|
||||
@commands.has_permissions(administrator=True)
|
||||
async def toggle_feature(ctx, feature: str, state: str):
|
||||
"""Enables or disables a feature like askmultus or vision."""
|
||||
global features
|
||||
|
||||
mode = mode.lower()
|
||||
state = state.lower()
|
||||
user_perms = load_user_data(ctx.author.id)
|
||||
if 5 < user_perms["permission"]:
|
||||
if mode == "vision":
|
||||
if state == "on":
|
||||
vision_enabled = True
|
||||
await ctx.send("Vision mode enabled.")
|
||||
elif state == "off":
|
||||
vision_enabled = False
|
||||
await ctx.send("Vision mode disabled.")
|
||||
if feature.lower() not in features:
|
||||
await ctx.send(f"Feature {feature} not found.")
|
||||
return
|
||||
|
||||
if state.lower() == "on":
|
||||
features[feature.lower()] = True
|
||||
await ctx.send(f"Feature {feature} enabled.")
|
||||
elif state.lower() == "off":
|
||||
features[feature.lower()] = False
|
||||
await ctx.send(f"Feature {feature} disabled.")
|
||||
else:
|
||||
await ctx.send("Invalid state. Please use 'on' or 'off'.")
|
||||
elif mode == "askmultus":
|
||||
if state == "on":
|
||||
askmultus_enabled = True
|
||||
await ctx.send("AskMultus mode enabled.")
|
||||
elif state == "off":
|
||||
askmultus_enabled = False
|
||||
await ctx.send("AskMultus mode disabled.")
|
||||
else:
|
||||
await ctx.send("Invalid state. Please use 'on' or 'off'.")
|
||||
else:
|
||||
await ctx.send("Invalid mode. Please specify either 'vision' or 'askmultus'.")
|
||||
else:
|
||||
await ctx.send("You don't have the necessary permissions to use this command.")
|
||||
await ctx.send("Please specify 'on' or 'off'.")
|
||||
|
||||
@client.hybrid_command()
|
||||
async def version(ctx):
|
||||
|
||||
Reference in New Issue
Block a user