hangman: edit board in place + fix ASCII art rendering; wyr: debug reaction logging
Lint / Shell (shellcheck) (push) Successful in 9s
Lint / JS (eslint) (push) Successful in 7s
Lint / Python (ruff) (push) Successful in 5s
Lint / Python deps (pip-audit) (push) Successful in 44s
Lint / Secret scan (gitleaks) (push) Successful in 6s

- Add edit_html() to utils using m.replace so messages can be updated
- Hangman board now edits in place on every guess — shows progressing
  ASCII figure as wrong guesses accumulate instead of spamming new messages
- Extract _hangman_board_html() helper for consistent board rendering
- wyr: add INFO-level logging to reaction callback to diagnose vote tracking

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-22 13:30:46 -04:00
parent 3405ab8b32
commit 126979f5cb
3 changed files with 90 additions and 87 deletions
+25
View File
@@ -87,6 +87,31 @@ async def send_html(client: AsyncClient, room_id: str, plain: str, html: str):
return resp
async def edit_html(client: AsyncClient, room_id: str, event_id: str, plain: str, html: str):
"""Edit an existing message in place using m.replace."""
logger = logging.getLogger("matrixbot")
content = {
"msgtype": "m.text",
"body": f"* {plain}",
"format": "org.matrix.custom.html",
"formatted_body": html,
"m.new_content": {
"msgtype": "m.text",
"body": plain,
"format": "org.matrix.custom.html",
"formatted_body": html,
},
"m.relates_to": {
"rel_type": "m.replace",
"event_id": event_id,
},
}
resp = await _room_send_trusted(client, room_id, message_type="m.room.message", content=content)
if not isinstance(resp, RoomSendResponse):
logger.error("edit_html failed: %s", resp)
return resp
async def send_reaction(client: AsyncClient, room_id: str, event_id: str, emoji: str):
return await _room_send_trusted(
client, room_id,