Add tier-aware /commands handler and register command#29
Add tier-aware /commands handler and register command#29StreetLevelTech1 wants to merge 1 commit into
Conversation
| "/analysis <coin> — Deep AI analysis\n" | ||
| "/stock <symbol> — Stock price & data\n" | ||
| "/summary — AI news digest\n" | ||
| "/polymarket <topic> — Prediction market intelligence\n\n" | ||
| "<b>Alerts & Tracking</b>\n" |
There was a problem hiding this comment.
Bug: The /commands handler incorrectly lists free commands like /analysis and /alert as premium-only, misleading users about feature availability.
Severity: LOW
Suggested Fix
Remove the free commands (e.g., /analysis, /summary, /polymarket, /alert, /watchlist, /forex and related commands) from the premium_cmds string within the commands handler in bot/handlers/core.py. The displayed command list should accurately reflect the tiers defined in bot/bot.py.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: bot/handlers/core.py#L738-L742
Potential issue: The `/commands` handler incorrectly lists several commands as
premium-only when they are actually available to free-tier users. The `premium_cmds`
string in `bot/handlers/core.py` includes commands such as `/analysis`, `/summary`,
`/polymarket`, `/alert`, `/watchlist`, and `/forex`. However, these are all registered
in the `FREE_COMMANDS` list in `bot/bot.py` and do not have any tier-based restrictions
in their respective handlers. This will cause the bot to incorrectly inform free users
that they need to upgrade to use features they already have access to, creating a
confusing user experience.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bcf5a5d1d5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| free_cmds = ( | ||
| "<b>🆓 FREE TIER COMMANDS</b>\n\n" | ||
| "<b>Prices & Market</b>\n" | ||
| "/price <coin> — Live price (e.g. /price BTC)\n" |
There was a problem hiding this comment.
Escape argument placeholders before sending HTML
Because this response is sent through safe_reply_html(..., parse_mode="HTML"), placeholders like <coin> are parsed as HTML tags; Telegram rejects unsupported tags, and the fallback strips all <...> text, so /commands will show /price — Live price and similarly remove every argument name. Escape these placeholders as <coin> (or avoid HTML parse mode for command syntax) so users get the actual usage text.
Useful? React with 👍 / 👎.
Motivation
/commandsresponse.Description
commandshandler inbot/handlers/core.pythat usesai.get_user_tier(user_id)and returns HTML-formatted free / premium / admin command lists viasafe_reply_html, and logs usage withlog_event("commands_list").help_commandinbot/handlers/core.pyto point users to/commandsfor the full, tiered list.commandsfrombot/handlers/__init__.pyso it can be referenced by the main application.CommandHandler("commands", protected(handlers.commands))inbot/bot.pyand addBotCommand("commands", "View all commands by tier")toFREE_COMMANDS; deploy together:bot/handlers/core.py,bot/handlers/__init__.py,bot/bot.py.Testing
ast.parse()onbot/handlers/core.py,bot/handlers/__init__.py, andbot/bot.py, and parsing succeeded for all modified files.Codex Task