hangman: edit board in place + fix ASCII art rendering; wyr: debug reaction logging
- 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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user