-
Notifications
You must be signed in to change notification settings - Fork 0
Add tier-aware /commands handler and register command #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| from handlers.core import ( | ||
| start, | ||
| help_command, | ||
| commands, | ||
| clear, | ||
| about, | ||
| handle_message, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -705,9 +705,76 @@ async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE): | |
| "/createcoupon <code> <plan> <uses> — Create coupon\n" | ||
| "/listcoupons — View all coupons\n" | ||
| ) | ||
| base += "\n\n💡 Use /commands to see the full command list by tier" | ||
| await safe_reply(update, base) | ||
|
|
||
|
|
||
| async def commands(update: Update, context: ContextTypes.DEFAULT_TYPE): | ||
| """List all available commands based on user tier.""" | ||
| user_id = update.effective_user.id | ||
| tier = ai.get_user_tier(user_id) | ||
|
|
||
| free_cmds = ( | ||
| "<b>🆓 FREE TIER COMMANDS</b>\n\n" | ||
| "<b>Prices & Market</b>\n" | ||
| "/price <coin> — Live price (e.g. /price BTC)\n" | ||
| "/top10 — Top 10 coins by market cap\n" | ||
| "/marketupdate — Full market overview\n" | ||
| "/rates — NGN exchange rates\n\n" | ||
| "<b>News</b>\n" | ||
| "/news — Latest crypto news (4 categories)\n\n" | ||
| "<b>Account</b>\n" | ||
| "/premium — Upgrade to premium\n" | ||
| "/myplan — Check your subscription\n" | ||
| "/redeem <code> — Redeem coupon code\n" | ||
| "/clear — Clear chat history\n" | ||
| "/about — About StrideBot\n" | ||
| "/timezone — Set your timezone" | ||
| ) | ||
|
|
||
| premium_cmds = ( | ||
| "\n\n<b>💎 PREMIUM COMMANDS</b>\n\n" | ||
| "<b>Analysis & Research</b>\n" | ||
| "/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" | ||
|
Comment on lines
+738
to
+742
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The Suggested FixRemove the free commands (e.g., Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
| "/alert — Set price alert\n" | ||
| "/myalerts — View active alerts\n" | ||
| "/cancelalert — Remove alert\n" | ||
| "/watch <symbol> — Add to watchlist (20 max)\n" | ||
| "/unwatch <symbol> — Remove from watchlist\n" | ||
| "/watchlist — View watchlist with AI commentary\n\n" | ||
| "<b>Forex & Markets</b>\n" | ||
| "/forex <pair> — Live forex rate\n" | ||
| "/forexanalysis <pair> — AI forex analysis" | ||
| ) | ||
|
|
||
| admin_cmds = ( | ||
| "\n\n<b>👑 ADMIN COMMANDS</b>\n\n" | ||
| "/broadcast — Send message to all users\n" | ||
| "/testpost <name> — Trigger scheduled post\n" | ||
| "/stats — Bot statistics\n" | ||
| "/listusers — List all users\n" | ||
| "/addpremium <user_id> <days> — Grant premium\n" | ||
| "/removepremium <user_id> — Revoke premium\n" | ||
| "/createcoupon <code> <plan> <max_uses> — Create coupon\n" | ||
| "/listcoupons — View all coupons\n" | ||
| "/trending — Run trend intelligence pipeline\n" | ||
| "/approvetrend — Approve trend post for channel" | ||
| ) | ||
|
|
||
| if tier == "admin": | ||
| text = free_cmds + premium_cmds + admin_cmds | ||
| elif tier in ["premium", "scheduler"]: | ||
| text = free_cmds + premium_cmds | ||
| else: | ||
| text = free_cmds + "\n\n💡 <i>Upgrade to premium for full access: /premium</i>" | ||
|
|
||
| log_event("commands_list") | ||
| await safe_reply_html(update, text) | ||
|
|
||
|
|
||
| async def clear(update: Update, context: ContextTypes.DEFAULT_TYPE): | ||
| await asyncio.to_thread(db.clear_history, update.effective_user.id) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/commandswill show/price — Live priceand 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 👍 / 👎.