feat: add optional custom argument topic override via Web UI

- Added optional 'topic' field to BipolarTriggerRequest model
- Added topic parameter to force_trigger_argument and force_trigger_argument_from_message_id
- Updated run_argument to accept optional custom topic (None=random, ''=no topic, str=custom)
- Added topic input field to Web UI trigger-argument section
- Updated JS to send topic in API request body
- Custom topics bypass the random rotation system, allowing manual theme control
This commit is contained in:
2026-04-30 12:07:28 +03:00
parent 98fca53066
commit 846557fa96
5 changed files with 40 additions and 10 deletions

View File

@@ -129,7 +129,7 @@ def trigger_argument(data: BipolarTriggerRequest):
if message_id:
async def trigger_from_message():
success, error = await force_trigger_argument_from_message_id(
channel_id, message_id, globals.client, data.context
channel_id, message_id, globals.client, data.context, topic=data.topic
)
if not success:
logger.error(f"Failed to trigger argument from message: {error}")
@@ -148,8 +148,8 @@ def trigger_argument(data: BipolarTriggerRequest):
if not channel:
return JSONResponse(status_code=404, content={"status": "error", "message": f"Channel {channel_id} not found"})
# Trigger the argument
globals.client.loop.create_task(force_trigger_argument(channel, globals.client, data.context))
# Trigger the argument with optional custom topic
globals.client.loop.create_task(force_trigger_argument(channel, globals.client, data.context, topic=data.topic))
return {
"status": "ok",

View File

@@ -46,6 +46,7 @@ class BipolarTriggerRequest(BaseModel):
channel_id: str # String to handle large Discord IDs from JS
message_id: str = None # Optional: starting message ID (string)
context: str = ""
topic: str = "" # Optional: custom argument topic (overrides random topic selection)
class ManualCropRequest(BaseModel):