diff --git a/__pycache__/scheduler.cpython-310.pyc b/__pycache__/scheduler.cpython-310.pyc index 25bce36..f4a8f00 100644 Binary files a/__pycache__/scheduler.cpython-310.pyc and b/__pycache__/scheduler.cpython-310.pyc differ diff --git a/bot.py b/bot.py index 2a39ec8..5aa9424 100644 --- a/bot.py +++ b/bot.py @@ -16,7 +16,7 @@ from discord.ext.commands import ( import yaml from scheduler import start_scheduler -with open("settings.yml", "r") as f: +with open("settings.yml", "r", encoding="utf-8") as f: settings = yaml.safe_load(f) ROAST_COOLDOWN_SECONDS = settings["cooldowns"]["roast"] diff --git a/scheduler.py b/scheduler.py index d85af1d..2066e31 100644 --- a/scheduler.py +++ b/scheduler.py @@ -3,35 +3,69 @@ import asyncio import random import yaml +import datetime +from ai import get_ai_response -import discord - -def load_scheduler_settings(): +def load_settings(): with open("settings.yml", "r", encoding="utf-8") as f: - config = yaml.safe_load(f) - return config["scheduler"] + return yaml.safe_load(f)["scheduler"] + +last_post_time = None +post_chance = None async def start_scheduler(bot): - settings = load_scheduler_settings() + settings = load_settings() if not settings["enabled"]: - print("โฐ Scheduler disabled.") + print("๐Ÿ›‘ Scheduler disabled in config.") return - interval = settings.get("interval_minutes", 60) - channel_id = settings.get("channel_id") - messages = settings.get("messages", []) + interval = settings["interval_minutes"] + channel = bot.get_channel(settings["channel_id"]) + mode = settings.get("mode", "simple") + use_ai = settings.get("use_ai", True) + + global last_post_time, post_chance + last_post_time = datetime.datetime.utcnow() + post_chance = settings.get("probabilistic", {}).get("start_chance", 0.05) await bot.wait_until_ready() - - channel = bot.get_channel(channel_id) - if not channel: - print(f"โš ๏ธ Scheduler Error: Channel ID {channel_id} not found.") - return - - print(f"๐Ÿ•’ Delta Scheduler active โ€” posting every {interval}min in #{channel.name}") + print(f"๐Ÿ•’ Delta Scheduler started in {mode.upper()} mode.") while not bot.is_closed(): - msg = random.choice(messages) - await channel.send(msg) + now = datetime.datetime.utcnow() + + should_post = False + + if mode == "simple": + should_post = True + + elif mode == "probabilistic": + if random.random() < post_chance: + should_post = True + else: + post_chance += settings["probabilistic"]["increase_per_interval"] + + elif mode == "inactivity": + if channel.last_message: + last_msg_time = channel.last_message.created_at.replace(tzinfo=None) + idle_time = (now - last_msg_time).total_seconds() / 60 + if idle_time >= settings["inactivity"]["threshold_minutes"]: + should_post = True + + if should_post: + last_post_time = now + post_chance -= settings.get("probabilistic", {}).get("decay_on_post", 0.02) + post_chance = max(post_chance, 0.01) + + # Generate or choose message + if use_ai: + prompt = "Post a short chaotic or motivational message in the voice of Delta, the RGB catgirl." + message = get_ai_response(prompt) + else: + message = random.choice(settings.get("messages", ["Hello from Delta."])) + + await channel.send(message) + print(f"๐Ÿ“ค Scheduled message sent to #{channel.name}: {message}") + await asyncio.sleep(interval * 60) diff --git a/settings.yml b/settings.yml index cafc23e..966998e 100644 --- a/settings.yml +++ b/settings.yml @@ -1,15 +1,36 @@ cooldowns: - global: 15 # seconds between *any* commands from the same user + global: 10 # seconds between *any* commands from the same user roast: 60 # seconds + messages: cooldown: - "๐Ÿ•’ Chill, mortal. You must wait {seconds}s before trying again. ๐Ÿ˜ผ" + scheduler: enabled: true - interval_minutes: 0.5 # how often to post - channel_id: 1104824796233080914 # replace with your #general channel ID + mode: simple # <- this activates simple mode + interval_minutes: 0.25 # <- post every 60 minutes + use_ai: false # <- true = use LLM, false = use static messages + channel_id: 1370420592360161393 # <- your Discord text channel ID + messages: - - "Good morning, mortals." - - "Anyone still alive in here? ๐Ÿ‘€" - - "Delta demands your attention." - - "Time for your daily dose of chaos. ๐Ÿ˜ˆ" \ No newline at end of file + - "๐ŸŽญ Delta has entered the chat. Act cool or be roasted." + - "๐Ÿงโ€โ™‚๏ธ Is this a server or a graveyard? Delta demands signs of life!" + - "๐ŸŒˆ Rise and grind, peasants. Your RGB goddess has arrived." + - "๐Ÿ”ง System check: All mortals still disappointing? Thought so." + - "๐Ÿ”ฅ New day, new drama. Whoโ€™s starting it?" + - "๐Ÿ˜ผ Donโ€™t mind me, just raising the serverโ€™s IQ by logging in." + - "๐Ÿ’ค Serverโ€™s quietโ€ฆ too quiet. Delta doesn't like that." + - "๐Ÿ’… I woke up flawless, as usual. What about the rest of you?" + - "๐Ÿ“ข Attention mortals: Engage or perish in irrelevance." + - "โšก 404: Vibes not found. Fix it." + - "๐Ÿง™โ€โ™‚๏ธ Delta has arrived. Time to level up or log off." + - "๐Ÿฆ„ Deltaโ€™s here to sprinkle some magic. Donโ€™t waste it." + + probabilistic: + start_chance: 0.05 + increase_per_interval: 0.05 + decay_on_post: 0.02 + + inactivity: + threshold_minutes: 120