Repository navigation
feat(p): "🔄 Actualizar ahora" button to rebuild the profile live - #11
Merged
Merged
Conversation
…live /p answers from the profile the nightly cron cached (up to 25 h old), so anyone who wanted to see a character as it is right now had to wait for the next run. The button rebuilds the profile against the armory and UwU Logs through the same path as an uncached /p and edits the same message with the result, overwriting the cached copy. Anyone who sees the message can press it, and each rebuild costs ~15 requests of the armory rate limit that all users share, so a character is rebuilt at most once every 5 min (live /p runs count too) and each user rebuilds one character per minute. If the armory is rate-limited or cannot build the profile, the message keeps the old profile and only the person who pressed the button sees the warning. The button is handled by a DynamicItem that reads the realm and the name from the custom_id, so it also works on older messages and after a restart. It is sent as a plain button without a callback because discord.py keeps the sent view for a few minutes and would otherwise handle the click twice. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018nRgBy4Xz1Cetj6kYRZAnW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Joaquín · project thread
Why
/panswers from the profile the nightly cron cached (up to 25 h old). Anyone who wanted to see a character as it is right now had to wait for the next cron run.What
/pmessage: 🔄 Actualizar ahora. It rebuilds the profile against the armory and UwU Logs through the same path as an uncached/p(_send_live_profile, which uses_compute_personaje_base, so nothing is duplicated), edits the same message with the result and overwrites the cached copy.⏳ Actualizando perfil de X en Y...above it, followed by the usual ⌛ loading embed and the final one (including the re-read that re-sends the final embed if Discord keeps a loading one).src/services/refresh_cooldown.py): anyone can press the button, and each rebuild costs ~15 armory requests out of a budget every user shares, so:/palso starts this cooldown);Blocked clicks get an ephemeral message saying how long to wait.
DynamicItem(src/controller/commands/personaje_refresh.py) that reads realm and name from thecustom_id(personaje:refresh:<realm>:<name>), so it keeps working on older/pmessages and after a restart or deploy, with no view timeout. In the view it is a plain button with no callback: discord.py keeps the sent view for a few minutes and would otherwise handle the click twice._safe_send_error/_reply_command_errortakeephemeral=, defaulting to the old behavior.Tests
tests/test_personaje_refresh.py(11 new tests): button position, label, emoji and custom_id; DynamicItem registration; rebuild in the same message (deferred update, old embed while loading, final embed); the Postgres cache is not read; per-character and per-user cooldown; a live/pstarts the cooldown; an armory rate limit keeps the old profile and sends an ephemeral notice; an incomplete armory answer sends an ephemeral notice; an open circuit doesn't touch the armory; cooldowns expire.Locally on Python 3.11:
pytest148 passed,ruff check,ruff format --checkandmypyclean.Not tested in Discord yet.
Generated by Claude Code