chore: schizo

This commit is contained in:
2025-06-10 14:09:17 +02:00
parent ced26fcb59
commit 63fb12dbba
5 changed files with 3139 additions and 23 deletions

View File

@@ -11,6 +11,7 @@ COPY requirements.txt .
RUN /bot-env/bin/pip install --no-cache-dir -r requirements.txt RUN /bot-env/bin/pip install --no-cache-dir -r requirements.txt
COPY bot /aw-bot/bot COPY bot /aw-bot/bot
COPY chat /aw-bot/chat
COPY database /aw-bot/database COPY database /aw-bot/database
COPY sounds /aw-bot/sounds COPY sounds /aw-bot/sounds
COPY aw.py . COPY aw.py .

View File

@@ -13,20 +13,6 @@ GUILD_ID = 1110531063161299074
BOT_LOG = 1112049391482703873 BOT_LOG = 1112049391482703873
GENERAL_CHANNEL = 1110531063744303138 GENERAL_CHANNEL = 1110531063744303138
ALLOWED_CHANNELS = [
GENERAL_CHANNEL,
1119371841711112314, # vip-channel
1112048063448617142, # off-topic
1112016681880014928, # mw2 sp
1145459504436220014, # iw5 support
1145469136919613551, # s1 general
1145459788151537804, # s1 support
1145469106133401682, # iw6 general
1145458770122649691, # iw6 support
1180796251529293844, # bo3 general
1180796301953212537, # bo3 support
BOT_LOG,
]
async def setup(bot): async def setup(bot):
@@ -119,13 +105,6 @@ async def setup(bot):
""" """
Slash command to check if the input matches any predefined patterns. Slash command to check if the input matches any predefined patterns.
""" """
# Check if the command is executed in an allowed channel
if interaction.channel_id not in ALLOWED_CHANNELS:
await interaction.response.send_message(
"This command cannot be used in this channel.", ephemeral=True
)
return
# Check if the user is blacklisted # Check if the user is blacklisted
if is_user_blacklisted(interaction.user.id): if is_user_blacklisted(interaction.user.id):
await interaction.response.send_message( await interaction.response.send_message(

View File

@@ -1,5 +1,5 @@
import json
import os import os
import csv
from database import get_patterns from database import get_patterns
message_patterns = get_patterns() message_patterns = get_patterns()
@@ -9,3 +9,30 @@ def update_patterns(regex: str, response: str):
"""update patterns in memory.""" """update patterns in memory."""
message_patterns.append({"regex": regex, "response": response}) message_patterns.append({"regex": regex, "response": response})
print(f"Pattern added in memory: {regex}") print(f"Pattern added in memory: {regex}")
def load_chat_messages(csv_path="chat/chat_messages.csv"):
"""
Loads all messages from the given CSV file.
Args:
csv_path (str): Path to the CSV file.
Returns:
list: List of message strings.
"""
messages = []
if not os.path.exists(csv_path):
print(f"CSV file not found: {csv_path}")
return messages
with open(csv_path, newline="", encoding="utf-8") as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
msg = row.get("Message")
if msg:
messages.append(msg)
return messages
schizo_messages = load_chat_messages()

View File

@@ -1,10 +1,12 @@
from datetime import datetime, timezone from datetime import datetime, timezone
import random
import requests import requests
import discord import discord
from discord.ext import tasks, commands from discord.ext import tasks, commands
from bot.utils import aware_utcnow, fetch_api_data from bot.utils import aware_utcnow, fetch_api_data
from bot.config import schizo_messages
from bot.discourse.handle_request import fetch_cooked_posts, combine_posts_text from bot.discourse.handle_request import fetch_cooked_posts, combine_posts_text
from database import migrate_users_with_role from database import migrate_users_with_role
@@ -160,7 +162,7 @@ async def setup(bot):
) )
await bot.change_presence(activity=activity) await bot.change_presence(activity=activity)
@tasks.loop(hours=16) @tasks.loop(hours=9)
async def heat_death(): async def heat_death():
try: try:
now = aware_utcnow() now = aware_utcnow()
@@ -179,6 +181,15 @@ async def setup(bot):
except Exception as e: except Exception as e:
print(f"An error occurred in heat_death task: {e}") print(f"An error occurred in heat_death task: {e}")
@tasks.loop(hours=5)
async def shizo_message():
channel = bot.get_channel(OFFTOPIC_CHANNEL)
if channel and schizo_messages:
message = random.choice(schizo_messages)
await channel.send(message)
else:
print("Debug: Channel not found or schizo_messages is empty.")
@tasks.loop(hours=24) @tasks.loop(hours=24)
async def share_dementia_image(): async def share_dementia_image():
channel = bot.get_channel(OFFTOPIC_CHANNEL) channel = bot.get_channel(OFFTOPIC_CHANNEL)
@@ -192,6 +203,7 @@ async def setup(bot):
update_status.start() update_status.start()
heat_death.start() heat_death.start()
shizo_message.start()
share_dementia_image.start() share_dementia_image.start()
await bot.add_cog(SteamSaleChecker(bot)) await bot.add_cog(SteamSaleChecker(bot))

3097
chat/chat_messages.csv Normal file

File diff suppressed because it is too large Load Diff