🧠 Added scheduler base + Day 5b roadmap for AI-driven posting and probabilistic logic
This commit is contained in:
parent
a0c5f07f63
commit
52d245296a
8 changed files with 107 additions and 5 deletions
61
README.md
61
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
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
BIN
__pycache__/scheduler.cpython-310.pyc
Normal file
BIN
__pycache__/scheduler.cpython-310.pyc
Normal file
Binary file not shown.
2
bot.py
2
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)
|
||||
|
|
|
|||
37
scheduler.py
Normal file
37
scheduler.py
Normal file
|
|
@ -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)
|
||||
0
scheduler/inactivity.py
Normal file
0
scheduler/inactivity.py
Normal file
0
scheduler/probabilistic.py
Normal file
0
scheduler/probabilistic.py
Normal file
0
scheduler/simple.py
Normal file
0
scheduler/simple.py
Normal file
12
settings.yml
12
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. 😼"
|
||||
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. 😈"
|
||||
Loading…
Reference in a new issue