|
@@ -162,9 +162,55 @@ class TelegramTradingBot:
|
|
|
self.application.add_handler(CallbackQueryHandler(self.trading_commands.button_callback))
|
|
|
self.application.add_handler(MessageHandler(
|
|
|
filters.Regex(r'^(LONG|SHORT|EXIT|SL|TP|LEVERAGE|BALANCE|POSITIONS|ORDERS|STATS|MARKET|PERFORMANCE|DAILY|WEEKLY|MONTHLY|RISK|ALARM|MONITORING|LOGS|DEBUG|VERSION|COMMANDS|KEYBOARD|COO)'),
|
|
|
- self.trading_commands.handle_keyboard_command
|
|
|
+ self.handle_keyboard_command
|
|
|
))
|
|
|
|
|
|
+ async def handle_keyboard_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
|
+ """Handles commands sent via the main keyboard."""
|
|
|
+ command_text = update.message.text.upper()
|
|
|
+ logger.info(f"Keyboard command received: {command_text}")
|
|
|
+
|
|
|
+ # Map keyboard text to the appropriate command method
|
|
|
+ command_map = {
|
|
|
+ "LONG": self.trading_commands.long_command,
|
|
|
+ "SHORT": self.trading_commands.short_command,
|
|
|
+ "EXIT": self.trading_commands.exit_command,
|
|
|
+ "SL": self.trading_commands.sl_command,
|
|
|
+ "TP": self.trading_commands.tp_command,
|
|
|
+ "LEVERAGE": self.trading_commands.leverage_command,
|
|
|
+ "COO": self.trading_commands.coo_command,
|
|
|
+ "BALANCE": self.info_commands.balance_command,
|
|
|
+ "POSITIONS": self.info_commands.positions_command,
|
|
|
+ "ORDERS": self.info_commands.orders_command,
|
|
|
+ "STATS": self.info_commands.stats_command,
|
|
|
+ "MARKET": self.info_commands.market_command,
|
|
|
+ "PERFORMANCE": self.info_commands.performance_command,
|
|
|
+ "DAILY": self.info_commands.daily_command,
|
|
|
+ "WEEKLY": self.info_commands.weekly_command,
|
|
|
+ "MONTHLY": self.info_commands.monthly_command,
|
|
|
+ "RISK": self.info_commands.risk_command,
|
|
|
+ "COMMANDS": self.commands_cmds.commands_command,
|
|
|
+ "ALARM": self.management_commands.alarm_command,
|
|
|
+ "MONITORING": self.management_commands.monitoring_command,
|
|
|
+ "LOGS": self.management_commands.logs_command,
|
|
|
+ "DEBUG": self.management_commands.debug_command,
|
|
|
+ "VERSION": self.management_commands.version_command,
|
|
|
+ "KEYBOARD": self.management_commands.keyboard_command,
|
|
|
+ }
|
|
|
+
|
|
|
+ command_func = command_map.get(command_text)
|
|
|
+ if command_func:
|
|
|
+ # We need to simulate a command call, so we'll prepend "/"
|
|
|
+ # to the message text to make it look like a real command.
|
|
|
+ original_text = update.message.text
|
|
|
+ update.message.text = f"/{original_text.lower()}"
|
|
|
+ await command_func(update, context)
|
|
|
+ else:
|
|
|
+ logger.warning(f"Unknown keyboard command: {command_text}")
|
|
|
+ await self.notification_manager.send_generic_notification(
|
|
|
+ f"Unknown command: {command_text}", chat_id=update.effective_chat.id
|
|
|
+ )
|
|
|
+
|
|
|
async def start_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
|
"""Handle the /start command."""
|
|
|
logger.info(f"/start command triggered by chat_id: {update.effective_chat.id}")
|