|
@@ -71,7 +71,8 @@ class TelegramTradingBot:
|
|
|
self.price_cmds = PriceCommands(self.trading_engine, self.notification_manager)
|
|
|
self.balance_adjustments_cmds = BalanceAdjustmentsCommands(self.trading_engine, self.notification_manager)
|
|
|
self.commands_cmds = CommandsInfo(self.trading_engine, self.notification_manager)
|
|
|
- self.copy_trading_cmds = CopyTradingCommands(self.monitoring_coordinator)
|
|
|
+ # TEMPORARY: Disable copy trading commands initialization for debugging
|
|
|
+ # self.copy_trading_cmds = CopyTradingCommands(self.monitoring_coordinator)
|
|
|
|
|
|
# Create a class to hold all info commands
|
|
|
class InfoCommandsHandler:
|
|
@@ -154,9 +155,10 @@ class TelegramTradingBot:
|
|
|
self.application.add_handler(CommandHandler("commands", self.commands_cmds.commands_command))
|
|
|
|
|
|
# Copy trading commands
|
|
|
- self.application.add_handler(CommandHandler("copy_status", self.copy_trading_cmds.copy_status_command))
|
|
|
- self.application.add_handler(CommandHandler("copy_start", self.copy_trading_cmds.copy_start_command))
|
|
|
- self.application.add_handler(CommandHandler("copy_stop", self.copy_trading_cmds.copy_stop_command))
|
|
|
+ # TEMPORARY: Disable copy trading commands for debugging
|
|
|
+ # self.application.add_handler(CommandHandler("copy_status", self.copy_trading_cmds.copy_status_command))
|
|
|
+ # self.application.add_handler(CommandHandler("copy_start", self.copy_trading_cmds.copy_start_command))
|
|
|
+ # self.application.add_handler(CommandHandler("copy_stop", self.copy_trading_cmds.copy_stop_command))
|
|
|
self.application.add_handler(CommandHandler("c", self.commands_cmds.commands_command)) # Alias
|
|
|
|
|
|
# Management commands
|
|
@@ -174,10 +176,13 @@ class TelegramTradingBot:
|
|
|
# Callback and message handlers
|
|
|
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|COPY_STATUS|COPY_START|COPY_STOP)'),
|
|
|
+ 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.handle_keyboard_command
|
|
|
))
|
|
|
|
|
|
+ # Debug message handler to catch all messages (should be last)
|
|
|
+ self.application.add_handler(MessageHandler(filters.ALL, self.debug_message_handler))
|
|
|
+
|
|
|
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()
|
|
@@ -209,9 +214,10 @@ class TelegramTradingBot:
|
|
|
"DEBUG": self.management_commands.debug_command,
|
|
|
"VERSION": self.management_commands.version_command,
|
|
|
"KEYBOARD": self.management_commands.keyboard_command,
|
|
|
- "COPY_STATUS": self.copy_trading_cmds.copy_status_command,
|
|
|
- "COPY_START": self.copy_trading_cmds.copy_start_command,
|
|
|
- "COPY_STOP": self.copy_trading_cmds.copy_stop_command,
|
|
|
+ # TEMPORARY: Disable copy trading keyboard commands for debugging
|
|
|
+ # "COPY_STATUS": self.copy_trading_cmds.copy_status_command,
|
|
|
+ # "COPY_START": self.copy_trading_cmds.copy_start_command,
|
|
|
+ # "COPY_STOP": self.copy_trading_cmds.copy_stop_command,
|
|
|
}
|
|
|
|
|
|
command_func = command_map.get(command_text)
|
|
@@ -227,12 +233,25 @@ class TelegramTradingBot:
|
|
|
f"Unknown command: {command_text}", chat_id=update.effective_chat.id
|
|
|
)
|
|
|
|
|
|
+ async def debug_message_handler(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
|
+ """Debug handler to log all incoming messages."""
|
|
|
+ try:
|
|
|
+ chat_id = update.effective_chat.id if update.effective_chat else "unknown"
|
|
|
+ message_text = update.message.text if update.message and update.message.text else "no text"
|
|
|
+ logger.info(f"🐛 DEBUG: Received message from chat_id={chat_id}, text='{message_text}'")
|
|
|
+ logger.info(f"🐛 DEBUG: Expected chat_id={Config.TELEGRAM_CHAT_ID}")
|
|
|
+ logger.info(f"🐛 DEBUG: Authorization result={self.is_authorized(chat_id)}")
|
|
|
+ except Exception as e:
|
|
|
+ logger.error(f"Error in debug message handler: {e}")
|
|
|
+
|
|
|
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}")
|
|
|
logger.debug(f"Full Update object in start_command: {update}")
|
|
|
|
|
|
chat_id = update.effective_chat.id
|
|
|
+ logger.info(f"🔍 Authorization check: chat_id={chat_id}, expected={Config.TELEGRAM_CHAT_ID}")
|
|
|
+
|
|
|
if not self.is_authorized(chat_id):
|
|
|
logger.warning(f"Unauthorized access attempt by chat_id: {chat_id} in /start.")
|
|
|
try:
|
|
@@ -254,7 +273,7 @@ class TelegramTradingBot:
|
|
|
• Exit: /exit {Config.DEFAULT_TRADING_TOKEN} (closes position)
|
|
|
• Info: /balance, /positions, /orders
|
|
|
|
|
|
-�� <b>Market Data:</b>
|
|
|
+📊 <b>Market Data:</b>
|
|
|
• /market - Detailed market overview
|
|
|
• /price - Quick price check
|
|
|
|