in server answering ban
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,4 +2,5 @@
|
||||
token.yaml
|
||||
ollama-api.yaml
|
||||
__pycache__/*
|
||||
bin/__pycache__/*
|
||||
bin/__pycache__/*
|
||||
tokent.yaml
|
||||
@ -1,9 +1,12 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import skills as skills
|
||||
import skills
|
||||
import asyncio
|
||||
import yaml
|
||||
|
||||
# -----------------------------
|
||||
# Token laden
|
||||
# -----------------------------
|
||||
with open("token.yaml", "r") as yamlfile:
|
||||
data = yaml.load(yamlfile, Loader=yaml.FullLoader)
|
||||
|
||||
@ -12,46 +15,46 @@ with open("token.yaml", "r") as yamlfile:
|
||||
# -----------------------------
|
||||
intents = discord.Intents.default()
|
||||
intents.message_content = True
|
||||
intents.guilds = True
|
||||
intents.dm_messages = True
|
||||
|
||||
bot = commands.Bot(command_prefix="!", intents=intents)
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Events
|
||||
# -----------------------------
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
await bot.tree.sync() # Slash Commands registrieren
|
||||
print(f"Logged in as {bot.user} ✅")
|
||||
|
||||
@bot.event
|
||||
async def on_message(message):
|
||||
# Bot ignoriert eigene Nachrichten
|
||||
if message.author == bot.user:
|
||||
return
|
||||
|
||||
try:
|
||||
# Wenn Nachricht ein Command ist, nur Commands verarbeiten
|
||||
# Commands verarbeiten
|
||||
if message.content.startswith(bot.command_prefix):
|
||||
await bot.process_commands(message)
|
||||
return
|
||||
|
||||
# Alles andere → skills.process_text
|
||||
loop = asyncio.get_running_loop()
|
||||
result = await loop.run_in_executor(None, skills.process_text, message.content)
|
||||
|
||||
# Längere Ausgaben als Code-Block
|
||||
if len(result) > 1900:
|
||||
await message.channel.send(f"```\n{result}\n```")
|
||||
else:
|
||||
await message.channel.send(result)
|
||||
# -----------------------------
|
||||
# DM Nachrichten
|
||||
# -----------------------------
|
||||
if isinstance(message.channel, discord.DMChannel):
|
||||
loop = asyncio.get_running_loop()
|
||||
result = await loop.run_in_executor(None, skills.process_text, message.content)
|
||||
if len(result) > 1900:
|
||||
await message.channel.send(f"```\n{result}\n```")
|
||||
else:
|
||||
await message.channel.send(result)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error in on_message: {e}")
|
||||
await message.channel.send(f"⚠️ Fehler: {e}")
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Bot starten
|
||||
# -----------------------------
|
||||
|
||||
bot.run(data[0]['token'])
|
||||
|
||||
Reference in New Issue
Block a user