From 52d245296a3392fb70e2bd82f0d538c9041a6ffd Mon Sep 17 00:00:00 2001 From: milo Date: Thu, 8 May 2025 23:40:35 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=A0=20Added=20scheduler=20base=20+=20D?= =?UTF-8?q?ay=205b=20roadmap=20for=20AI-driven=20posting=20and=20probabili?= =?UTF-8?q?stic=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 61 ++++++++++++++++++++++++-- __pycache__/scheduler.cpython-310.pyc | Bin 0 -> 1179 bytes bot.py | 2 + scheduler.py | 37 ++++++++++++++++ scheduler/inactivity.py | 0 scheduler/probabilistic.py | 0 scheduler/simple.py | 0 settings.yml | 12 ++++- 8 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 __pycache__/scheduler.cpython-310.pyc create mode 100644 scheduler.py create mode 100644 scheduler/inactivity.py create mode 100644 scheduler/probabilistic.py create mode 100644 scheduler/simple.py diff --git a/README.md b/README.md index 4b10fc8..da21f9a 100644 --- a/README.md +++ b/README.md @@ -94,10 +94,63 @@ A structured build plan for developing and deploying the AlphaBot Discord compan --- -### πŸ•’ Day 5 – Daily Message Scheduler -- [ ] Add `scheduler.py` for once-a-day posting -- [ ] Pick default channel (e.g. `#general`) -- [ ] Make messages dynamic/funny with flair +### πŸ•’ Day 5b – AI Scheduled Messages & Smarter Posting 🧠 + +> Goal: Let Delta post her own AI-generated chaos on a schedule, instead of just scripted messages. + +#### βœ… Core Features + +- [ ] Replace static messages in `scheduler.py` with AI-generated ones via `get_ai_response()` + - Use prompt like: *β€œPost something sassy, attention-grabbing, or chaotic to wake up the server.”* + - Maintain current persona system for tone consistency +- [ ] Add `settings.yml` option to control post mode: + - `mode: preset` – static messages only + - `mode: ai` – generate new message via LLM + - `mode: mixed` – random chance between the two +- [ ] Log each scheduled post and mode used for debugging + +--- + +#### βš™οΈ Probabilistic Scheduler (Mode 2 – Optional) + +> Post when it feels "natural" – low chance at first, rising over time. + +- [ ] Add `probabilistic_scheduler.py` or integrate into `scheduler.py` +- [ ] Configurable parameters: + - `start_chance: 0.05` (5% per hour) + - `increase_per_hour: 0.05` + - `decay_on_post: 0.02` +- [ ] Reset chance after post, store `last_post_time` + +--- + +#### πŸ’€ Inactivity-Aware Scheduler (Mode 3 – Stretch Goal) + +> Posts when the **server** or a **user** has been inactive for too long. + +- [ ] Monitor `message.created_at` timestamps per channel or user +- [ ] After `X minutes` of silence, apply probabilistic logic to post +- [ ] Configurable thresholds in `settings.yml` + +--- + +### πŸ›  Example: settings.yml Additions + +```yaml +scheduler: + mode: ai # Options: preset, ai, mixed + interval_minutes: 60 + + probabilistic: + enabled: false + start_chance: 0.05 + increase_per_hour: 0.05 + decay_on_post: 0.02 + + inactivity: + enabled: false + threshold_minutes: 120 +``` --- diff --git a/__pycache__/scheduler.cpython-310.pyc b/__pycache__/scheduler.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..25bce367fc854e72a450aa771a91252f1a095488 GIT binary patch literal 1179 zcmYjQ&1)Pt6qhs~JNpr54yM6|!h}Fz4qYe|T7oGByT*p#9!x1+7KZUiyPhy3Et1A& z%@|VLYcYiMQe(1v?5)S#bL*d=qkAYhCFejtp2i->(!3|>>3!+<-iUkmdI-jFgD1w%1fS&7-;uN^eb~&NjK5b*s&Sc5D>nX)vn`n)vGJD3s*-W7#yg^9(bM!` zOmme9NuvXy$G72zv$=U--6yxAq|LW$u^0dg@c{S!3rP5HK%^C97+5vIAa!fBaF%Enw0A6!XyMil z=yec+NPHsrkt}P$*BoSrc^p*s(NG{{kC}b`uvWsZ>1FSNwj%w5bbV7C;f;E9Zf{V z>987t(fe1wzKFJ1q0>8tX{Mpz(be;p(M%}YXc0SNavq%okV^#Lqj=C%&3H2jc^YTR zvEcF3yi!E50IfnrPBs+N;Pfz_?q?Y<$a}7sXun(3JBF>VC1=v z0}@~t4@eIha)tDWi$genLIRM4com2L$cLaB`*Ix?X)7juV5W1^{0$C`&YigSPm)dW WV51cFFZ|l}chmYdB20)d@csuHH8;=z literal 0 HcmV?d00001 diff --git a/bot.py b/bot.py index b9bb339..2a39ec8 100644 --- a/bot.py +++ b/bot.py @@ -14,6 +14,7 @@ from discord.ext.commands import ( CommandOnCooldown ) import yaml +from scheduler import start_scheduler with open("settings.yml", "r") as f: settings = yaml.safe_load(f) @@ -86,5 +87,6 @@ async def roast(ctx): @bot.event async def on_ready(): print(f"βœ… Logged in as {bot.user.name}") + bot.loop.create_task(start_scheduler(bot)) bot.run(TOKEN) diff --git a/scheduler.py b/scheduler.py new file mode 100644 index 0000000..d85af1d --- /dev/null +++ b/scheduler.py @@ -0,0 +1,37 @@ +# scheduler.py + +import asyncio +import random +import yaml + +import discord + +def load_scheduler_settings(): + with open("settings.yml", "r", encoding="utf-8") as f: + config = yaml.safe_load(f) + return config["scheduler"] + +async def start_scheduler(bot): + settings = load_scheduler_settings() + + if not settings["enabled"]: + print("⏰ Scheduler disabled.") + return + + interval = settings.get("interval_minutes", 60) + channel_id = settings.get("channel_id") + messages = settings.get("messages", []) + + 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}") + + while not bot.is_closed(): + msg = random.choice(messages) + await channel.send(msg) + await asyncio.sleep(interval * 60) diff --git a/scheduler/inactivity.py b/scheduler/inactivity.py new file mode 100644 index 0000000..e69de29 diff --git a/scheduler/probabilistic.py b/scheduler/probabilistic.py new file mode 100644 index 0000000..e69de29 diff --git a/scheduler/simple.py b/scheduler/simple.py new file mode 100644 index 0000000..e69de29 diff --git a/settings.yml b/settings.yml index 224a929..cafc23e 100644 --- a/settings.yml +++ b/settings.yml @@ -2,4 +2,14 @@ cooldowns: global: 15 # seconds between *any* commands from the same user roast: 60 # seconds messages: - cooldown: "πŸ•’ Chill, mortal. You must wait {seconds}s before trying again. 😼" \ No newline at end of file + 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 + 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