Explorar o código

Add quick access commands to Telegram bot - Introduce a new /commands command with a button menu for instant access to key bot functions. Update alarm command descriptions for clarity and enhance help text layout for improved user experience.

Carles Sentis hai 6 días
pai
achega
0111c030e5
Modificáronse 1 ficheiros con 73 adicións e 2 borrados
  1. 73 2
      src/telegram_bot.py

+ 73 - 2
src/telegram_bot.py

@@ -128,9 +128,9 @@ Tap the buttons below for instant access to key functions.
 • /trades - Recent trade history
 
 <b>🔔 Price Alerts:</b>
-• /alarm - List all alarms
+• /alarm - List all active alarms
 • /alarm BTC 50000 - Set alarm for BTC at $50,000
-• /alarm BTC - Show BTC alarms only
+• /alarm BTC - Show all BTC alarms
 • /alarm 3 - Remove alarm ID 3
 
 <b>🔄 Automatic Monitoring:</b>
@@ -171,6 +171,10 @@ Type /help for detailed command information.
 • Clean, readable layout
 • One-tap commands
 
+<b>💡 Quick Access:</b>
+• /commands or /c - One-tap button menu for all commands
+• Buttons below for instant access to key functions
+
 For support, contact your bot administrator.
         """.format(
             symbol=Config.DEFAULT_TRADING_TOKEN,
@@ -286,6 +290,57 @@ For support, contact your bot administrator.
         )
         
         await update.message.reply_text(help_text, parse_mode='HTML')
+
+    async def commands_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
+        """Handle the /commands and /c command with quick action buttons."""
+        if not self.is_authorized(update.effective_chat.id):
+            await update.message.reply_text("❌ Unauthorized access.")
+            return
+        
+        commands_text = """
+📱 <b>Quick Commands</b>
+
+Tap any button below for instant access to bot functions:
+
+💡 <b>Pro Tip:</b> These buttons work the same as typing the commands manually, but faster!
+        """
+        
+        keyboard = [
+            [
+                InlineKeyboardButton("💰 Balance", callback_data="balance"),
+                InlineKeyboardButton("📈 Positions", callback_data="positions")
+            ],
+            [
+                InlineKeyboardButton("📋 Orders", callback_data="orders"),
+                InlineKeyboardButton("📊 Stats", callback_data="stats")
+            ],
+            [
+                InlineKeyboardButton("💵 Price", callback_data="price"),
+                InlineKeyboardButton("📊 Market", callback_data="market")
+            ],
+            [
+                InlineKeyboardButton("🏆 Performance", callback_data="performance"),
+                InlineKeyboardButton("🔔 Alarms", callback_data="alarm")
+            ],
+            [
+                InlineKeyboardButton("📅 Daily", callback_data="daily"),
+                InlineKeyboardButton("📊 Weekly", callback_data="weekly")
+            ],
+            [
+                InlineKeyboardButton("📆 Monthly", callback_data="monthly"),
+                InlineKeyboardButton("🔄 Trades", callback_data="trades")
+            ],
+            [
+                InlineKeyboardButton("🔄 Monitoring", callback_data="monitoring"),
+                InlineKeyboardButton("📝 Logs", callback_data="logs")
+            ],
+            [
+                InlineKeyboardButton("⚙️ Help", callback_data="help")
+            ]
+        ]
+        reply_markup = InlineKeyboardMarkup(keyboard)
+        
+        await update.message.reply_text(commands_text, parse_mode='HTML', reply_markup=reply_markup)
     
     async def stats_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
         """Handle the /stats command."""
@@ -737,6 +792,20 @@ For support, contact your bot administrator.
             await self.trades_command(fake_update, context)
         elif callback_data == "help":
             await self.help_command(fake_update, context)
+        elif callback_data == "performance":
+            await self.performance_command(fake_update, context)
+        elif callback_data == "alarm":
+            await self.alarm_command(fake_update, context)
+        elif callback_data == "daily":
+            await self.daily_command(fake_update, context)
+        elif callback_data == "weekly":
+            await self.weekly_command(fake_update, context)
+        elif callback_data == "monthly":
+            await self.monthly_command(fake_update, context)
+        elif callback_data == "monitoring":
+            await self.monitoring_command(fake_update, context)
+        elif callback_data == "logs":
+            await self.logs_command(fake_update, context)
     
     async def _execute_long_order(self, query, token: str, usdc_amount: float, price: float, is_limit: bool):
         """Execute a long order."""
@@ -1075,6 +1144,8 @@ For support, contact your bot administrator.
         # Command handlers
         self.application.add_handler(CommandHandler("start", self.start_command))
         self.application.add_handler(CommandHandler("help", self.help_command))
+        self.application.add_handler(CommandHandler("commands", self.commands_command))
+        self.application.add_handler(CommandHandler("c", self.commands_command))
         self.application.add_handler(CommandHandler("balance", self.balance_command))
         self.application.add_handler(CommandHandler("positions", self.positions_command))
         self.application.add_handler(CommandHandler("orders", self.orders_command))