Skip to content

Add tier-aware /commands handler and register command#29

Open
StreetLevelTech1 wants to merge 1 commit into
devfrom
codex/add-commands-handler-to-stridebot
Open

Add tier-aware /commands handler and register command#29
StreetLevelTech1 wants to merge 1 commit into
devfrom
codex/add-commands-handler-to-stridebot

Conversation

@StreetLevelTech1
Copy link
Copy Markdown
Owner

Motivation

  • Prevent AI hallucination and correction loops when users ask for the command list by providing a deterministic, tier-aware /commands response.
  • Implement the minimal, non-invasive change necessary to expose a static command listing per user tier without refactoring adjacent code.

Description

  • Add an async commands handler in bot/handlers/core.py that uses ai.get_user_tier(user_id) and returns HTML-formatted free / premium / admin command lists via safe_reply_html, and logs usage with log_event("commands_list").
  • Update help_command in bot/handlers/core.py to point users to /commands for the full, tiered list.
  • Export commands from bot/handlers/__init__.py so it can be referenced by the main application.
  • Register CommandHandler("commands", protected(handlers.commands)) in bot/bot.py and add BotCommand("commands", "View all commands by tier") to FREE_COMMANDS; deploy together: bot/handlers/core.py, bot/handlers/__init__.py, bot/bot.py.

Testing

  • Ran syntax validation using ast.parse() on bot/handlers/core.py, bot/handlers/__init__.py, and bot/bot.py, and parsing succeeded for all modified files.

Codex Task

Comment thread bot/handlers/core.py
Comment on lines +738 to +742
"/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"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread bot/handlers/core.py
free_cmds = (
"<b>🆓 FREE TIER COMMANDS</b>\n\n"
"<b>Prices & Market</b>\n"
"/price <coin> — Live price (e.g. /price BTC)\n"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 &lt;coin&gt; (or avoid HTML parse mode for command syntax) so users get the actual usage text.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant