|
@@ -31,8 +31,7 @@ from src.commands.info.risk import RiskCommands
|
|
from src.commands.info.price import PriceCommands
|
|
from src.commands.info.price import PriceCommands
|
|
from src.commands.info.balance_adjustments import BalanceAdjustmentsCommands
|
|
from src.commands.info.balance_adjustments import BalanceAdjustmentsCommands
|
|
from src.commands.info.commands import CommandsInfo
|
|
from src.commands.info.commands import CommandsInfo
|
|
-# DISABLE AGAIN: Copy trading still causing blocking issues
|
|
|
|
-# from src.commands.copy_trading_commands import CopyTradingCommands
|
|
|
|
|
|
+from src.commands.copy_trading_commands import CopyTradingCommands
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@@ -72,8 +71,7 @@ class TelegramTradingBot:
|
|
self.price_cmds = PriceCommands(self.trading_engine, self.notification_manager)
|
|
self.price_cmds = PriceCommands(self.trading_engine, self.notification_manager)
|
|
self.balance_adjustments_cmds = BalanceAdjustmentsCommands(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.commands_cmds = CommandsInfo(self.trading_engine, self.notification_manager)
|
|
- # DISABLE AGAIN: Copy trading still causing blocking issues
|
|
|
|
- # self.copy_trading_cmds = CopyTradingCommands(self.monitoring_coordinator)
|
|
|
|
|
|
+ self.copy_trading_cmds = CopyTradingCommands(self.monitoring_coordinator)
|
|
|
|
|
|
# Create a class to hold all info commands
|
|
# Create a class to hold all info commands
|
|
class InfoCommandsHandler:
|
|
class InfoCommandsHandler:
|
|
@@ -156,6 +154,9 @@ class TelegramTradingBot:
|
|
self.application.add_handler(CommandHandler("commands", self.commands_cmds.commands_command))
|
|
self.application.add_handler(CommandHandler("commands", self.commands_cmds.commands_command))
|
|
self.application.add_handler(CommandHandler("c", self.commands_cmds.commands_command)) # Alias
|
|
self.application.add_handler(CommandHandler("c", self.commands_cmds.commands_command)) # Alias
|
|
|
|
|
|
|
|
+ # Copy trading commands (Step 1: Commands only, monitor still disabled)
|
|
|
|
+ self.application.add_handler(CommandHandler("copy", self.copy_trading_cmds.copy_command))
|
|
|
|
+
|
|
# Management commands
|
|
# Management commands
|
|
self.application.add_handler(CommandHandler("monitoring", self.management_commands.monitoring_command))
|
|
self.application.add_handler(CommandHandler("monitoring", self.management_commands.monitoring_command))
|
|
self.application.add_handler(CommandHandler("alarm", self.management_commands.alarm_command))
|
|
self.application.add_handler(CommandHandler("alarm", self.management_commands.alarm_command))
|
|
@@ -171,7 +172,7 @@ class TelegramTradingBot:
|
|
# Callback and message handlers
|
|
# Callback and message handlers
|
|
self.application.add_handler(CallbackQueryHandler(self.trading_commands.button_callback))
|
|
self.application.add_handler(CallbackQueryHandler(self.trading_commands.button_callback))
|
|
self.application.add_handler(MessageHandler(
|
|
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)'),
|
|
|
|
|
|
+ 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)'),
|
|
self.handle_keyboard_command
|
|
self.handle_keyboard_command
|
|
))
|
|
))
|
|
|
|
|
|
@@ -206,23 +207,40 @@ class TelegramTradingBot:
|
|
"DEBUG": self.management_commands.debug_command,
|
|
"DEBUG": self.management_commands.debug_command,
|
|
"VERSION": self.management_commands.version_command,
|
|
"VERSION": self.management_commands.version_command,
|
|
"KEYBOARD": self.management_commands.keyboard_command,
|
|
"KEYBOARD": self.management_commands.keyboard_command,
|
|
|
|
+ "COPY": self._handle_copy_status_keyboard,
|
|
}
|
|
}
|
|
|
|
|
|
command_func = command_map.get(command_text)
|
|
command_func = command_map.get(command_text)
|
|
if command_func:
|
|
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)
|
|
|
|
- # Restore original text
|
|
|
|
- update.message.text = original_text
|
|
|
|
|
|
+ # For COPY command, handle specially
|
|
|
|
+ if command_text == "COPY":
|
|
|
|
+ await command_func(update, context)
|
|
|
|
+ else:
|
|
|
|
+ # 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)
|
|
|
|
+ # Restore original text
|
|
|
|
+ update.message.text = original_text
|
|
else:
|
|
else:
|
|
logger.warning(f"Unknown keyboard command: {command_text}")
|
|
logger.warning(f"Unknown keyboard command: {command_text}")
|
|
await self.notification_manager.send_generic_notification(
|
|
await self.notification_manager.send_generic_notification(
|
|
f"Unknown command: {command_text}", chat_id=update.effective_chat.id
|
|
f"Unknown command: {command_text}", chat_id=update.effective_chat.id
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+ async def _handle_copy_status_keyboard(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
|
|
+ """Handle COPY keyboard command by showing copy trading status."""
|
|
|
|
+ # Create a mock context with status args to avoid modifying original
|
|
|
|
+ from types import SimpleNamespace
|
|
|
|
+
|
|
|
|
+ # Create a simple object that mimics the context for copy commands
|
|
|
|
+ mock_context = SimpleNamespace()
|
|
|
|
+ mock_context.args = ["status"]
|
|
|
|
+ mock_context.bot = context.bot
|
|
|
|
+
|
|
|
|
+ await self.copy_trading_cmds.copy_command(update, mock_context)
|
|
|
|
+
|
|
async def start_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
async def start_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
"""Handle the /start command."""
|
|
"""Handle the /start command."""
|
|
logger.info(f"/start command triggered by chat_id: {update.effective_chat.id}")
|
|
logger.info(f"/start command triggered by chat_id: {update.effective_chat.id}")
|