Auto-share Wordle result to origin room on game end
Instead of posting "Check your DMs" when !wordle is used in a public room, the bot now silently routes the game to DMs and automatically posts the spoiler-free emoji share grid back to the origin room (e.g. Commands) when the game ends — win, lose, or give up. Also removed the "use !wordle share" prompt from win/loss messages since sharing now happens automatically. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
21
wordle.py
21
wordle.py
@@ -538,6 +538,7 @@ async def wordle_guess(
|
||||
if all(s == 2 for s in result):
|
||||
game.finished = True
|
||||
game.won = True
|
||||
origin = game.origin_room_id
|
||||
_record_game_result(sender, game)
|
||||
del _active_games[sender]
|
||||
|
||||
@@ -547,9 +548,7 @@ async def wordle_guess(
|
||||
plain = (
|
||||
f"{congrats} Wordle {game.daily_number} {num}/6"
|
||||
f"{'*' if game.hard_mode else ''}\n\n"
|
||||
f"{grid_plain}\n\n"
|
||||
f"Use {BOT_PREFIX}wordle stats for your statistics "
|
||||
f"or {BOT_PREFIX}wordle share to share!"
|
||||
f"{grid_plain}"
|
||||
)
|
||||
grid_html = render_grid_html(game)
|
||||
mode = "*" if game.hard_mode else ""
|
||||
@@ -557,17 +556,18 @@ async def wordle_guess(
|
||||
f''
|
||||
f"<strong>{congrats}</strong> "
|
||||
f"Wordle {game.daily_number} {num}/6{mode}<br><br>"
|
||||
f"{grid_html}<br>"
|
||||
f"<em>Use <code>{BOT_PREFIX}wordle stats</code> for statistics "
|
||||
f"or <code>{BOT_PREFIX}wordle share</code> to share!</em>"
|
||||
f"{grid_html}"
|
||||
)
|
||||
await send_html(client, room_id, plain, html)
|
||||
if origin and origin != room_id:
|
||||
await wordle_share(client, origin, sender)
|
||||
return
|
||||
|
||||
# Check loss (6 guesses used)
|
||||
if len(game.guesses) >= 6:
|
||||
game.finished = True
|
||||
game.won = False
|
||||
origin = game.origin_room_id
|
||||
_record_game_result(sender, game)
|
||||
del _active_games[sender]
|
||||
|
||||
@@ -590,6 +590,8 @@ async def wordle_guess(
|
||||
f"<em>Better luck tomorrow!</em>"
|
||||
)
|
||||
await send_html(client, room_id, plain, html)
|
||||
if origin and origin != room_id:
|
||||
await wordle_share(client, origin, sender)
|
||||
return
|
||||
|
||||
# Still playing — show grid + keyboard
|
||||
@@ -692,6 +694,7 @@ async def wordle_give_up(client: AsyncClient, room_id: str, sender: str):
|
||||
|
||||
game.finished = True
|
||||
game.won = False
|
||||
origin = game.origin_room_id
|
||||
_record_game_result(sender, game)
|
||||
del _active_games[sender]
|
||||
|
||||
@@ -711,6 +714,8 @@ async def wordle_give_up(client: AsyncClient, room_id: str, sender: str):
|
||||
f"<em>Better luck tomorrow!</em>"
|
||||
)
|
||||
await send_html(client, room_id, plain, html)
|
||||
if origin and origin != room_id:
|
||||
await wordle_share(client, origin, sender)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -757,9 +762,7 @@ async def handle_wordle(
|
||||
# All other commands route through DM
|
||||
dm_room, origin = await _get_dm_room(client, room_id, sender)
|
||||
|
||||
# Notify the public room if we're redirecting to a DM
|
||||
if dm_room != room_id:
|
||||
await send_text(client, room_id, "\U0001f4ec Check your DMs to play Wordle!")
|
||||
# Silently redirect to DM — origin room will get an auto-share when the game ends
|
||||
|
||||
if subcmd == "help":
|
||||
await wordle_help(client, dm_room)
|
||||
|
||||
Reference in New Issue
Block a user