From 66f761b466a55976957b14be191db1fac9a430ac Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Wed, 22 Apr 2026 21:57:11 -0400 Subject: [PATCH] wyr/riddle: add model attribution + fix truncated WYR options wyr: - Reject options that end on a dangling word (but/and/or/with/never etc.) so truncated sentences like 'but never' return None and retry - Add 'via Llama 3.2 3B (abliterated)' credit to the poll message riddle: - Add 'via Llama 3.2 3B (abliterated)' credit to the riddle message Co-Authored-By: Claude Sonnet 4.6 --- matrixbot/commands.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/matrixbot/commands.py b/matrixbot/commands.py index 94bb74b..db46e7c 100644 --- a/matrixbot/commands.py +++ b/matrixbot/commands.py @@ -1692,10 +1692,13 @@ async def _generate_wyr() -> dict | None: parsed = json.loads(text) a = parsed.get("option_a", "").strip() b = parsed.get("option_b", "").strip() - # Hard cap: truncate options that are too long + _HANGING = {"but", "and", "or", "with", "for", "in", "on", "at", + "the", "a", "an", "never", "always", "no", "not", "to", + "of", "by", "from", "that", "which", "who", "be", "have"} if a and b: - a = " ".join(a.split()[:10]) - b = " ".join(b.split()[:10]) + # Reject if either option ends on a dangling word (truncation artifact) + if a.split()[-1].lower() in _HANGING or b.split()[-1].lower() in _HANGING: + return None q = f"Would you rather {a.rstrip('.')} OR {b.rstrip('.')}?" return {"question": q, "option_a": a, "option_b": b} except Exception as e: @@ -1724,7 +1727,8 @@ async def cmd_wyr(client: AsyncClient, room_id: str, sender: str, args: str): f'{wyr["question"]}

' f'🅰️ {wyr["option_a"]}
' f'🅱️ {wyr["option_b"]}

' - f'React with 🅰️ or 🅱️ — results in 30 seconds!' + f'React with 🅰️ or 🅱️ — results in 30 seconds!
' + f'via {_model_label(BALL_MODEL)}' ) resp = await send_html(client, room_id, plain, html) @@ -1871,7 +1875,8 @@ async def cmd_riddle(client: AsyncClient, room_id: str, sender: str, args: str): html = ( f'🧩 Riddle!
' f'
{riddle}
' - f'Type your answer in chat — 60 seconds on the clock!' + f'Type your answer in chat — 60 seconds on the clock!
' + f'via {_model_label(BALL_MODEL)}' ) await send_html(client, room_id, plain, html)