Add 'Detect and Join Conversation' button to Web UI and CLI
- Added /autonomous/join-conversation API endpoint in api.py - Added 'Detect and Join Conversation' button to Web UI under Autonomous Actions - Added 'autonomous join-conversation' command to CLI tool (miku-cli.py) - Updated miku_detect_and_join_conversation_for_server to support force=True parameter - When force=True: skips time limit, activity checks, and random chance - Force mode uses last 10 user messages regardless of age - Manual triggers via Web UI/CLI now work even with old messages
This commit is contained in:
25
bot/api.py
25
bot/api.py
@@ -27,7 +27,8 @@ from utils.autonomous import (
|
||||
miku_say_something_general,
|
||||
miku_engage_random_user,
|
||||
share_miku_tweet,
|
||||
handle_custom_prompt
|
||||
handle_custom_prompt,
|
||||
miku_detect_and_join_conversation
|
||||
)
|
||||
import asyncio
|
||||
import nest_asyncio
|
||||
@@ -338,6 +339,28 @@ async def trigger_autonomous_reaction(guild_id: int = None):
|
||||
else:
|
||||
return {"status": "error", "message": "Bot not ready"}
|
||||
|
||||
@app.post("/autonomous/join-conversation")
|
||||
async def trigger_detect_and_join_conversation(guild_id: int = None):
|
||||
# If guild_id is provided, detect and join conversation only for that server
|
||||
# If no guild_id, trigger for all servers
|
||||
print(f"🔍 [API] Join conversation endpoint called with guild_id={guild_id}")
|
||||
if globals.client and globals.client.loop and globals.client.loop.is_running():
|
||||
if guild_id is not None:
|
||||
# Trigger for specific server only (force=True to bypass checks when manually triggered)
|
||||
print(f"🔍 [API] Importing and calling miku_detect_and_join_conversation_for_server({guild_id}, force=True)")
|
||||
from utils.autonomous import miku_detect_and_join_conversation_for_server
|
||||
globals.client.loop.create_task(miku_detect_and_join_conversation_for_server(guild_id, force=True))
|
||||
return {"status": "ok", "message": f"Detect and join conversation queued for server {guild_id}"}
|
||||
else:
|
||||
# Trigger for all servers (force=True to bypass checks when manually triggered)
|
||||
print(f"🔍 [API] Importing and calling miku_detect_and_join_conversation() for all servers")
|
||||
from utils.autonomous import miku_detect_and_join_conversation
|
||||
globals.client.loop.create_task(miku_detect_and_join_conversation(force=True))
|
||||
return {"status": "ok", "message": "Detect and join conversation queued for all servers"}
|
||||
else:
|
||||
print(f"⚠️ [API] Bot not ready: client={globals.client}, loop={globals.client.loop if globals.client else None}")
|
||||
return {"status": "error", "message": "Bot not ready"}
|
||||
|
||||
@app.post("/profile-picture/change")
|
||||
async def trigger_profile_picture_change(
|
||||
guild_id: int = None,
|
||||
|
||||
Reference in New Issue
Block a user