|
@@ -43,17 +43,16 @@ class ManagementCommands(InfoCommandsBase):
|
|
self.monitoring_coordinator = monitoring_coordinator
|
|
self.monitoring_coordinator = monitoring_coordinator
|
|
self.alarm_manager = AlarmManager()
|
|
self.alarm_manager = AlarmManager()
|
|
|
|
|
|
- def _is_authorized(self, chat_id: str) -> bool:
|
|
|
|
- """Check if the chat ID is authorized."""
|
|
|
|
- return str(chat_id) == str(Config.TELEGRAM_CHAT_ID)
|
|
|
|
|
|
+
|
|
|
|
|
|
async def monitoring_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
async def monitoring_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
"""Handle the /monitoring command."""
|
|
"""Handle the /monitoring command."""
|
|
- chat_id = update.effective_chat.id
|
|
|
|
- if not self._is_authorized(chat_id):
|
|
|
|
- await context.bot.send_message(chat_id=chat_id, text="❌ Unauthorized access.")
|
|
|
|
|
|
+ if not self._is_authorized(update):
|
|
|
|
+ await self._reply(update, "❌ Unauthorized access.")
|
|
return
|
|
return
|
|
|
|
|
|
|
|
+ chat_id = update.effective_chat.id
|
|
|
|
+
|
|
# Get alarm statistics
|
|
# Get alarm statistics
|
|
alarm_stats = self.alarm_manager.get_statistics()
|
|
alarm_stats = self.alarm_manager.get_statistics()
|
|
|
|
|
|
@@ -131,11 +130,12 @@ class ManagementCommands(InfoCommandsBase):
|
|
|
|
|
|
async def alarm_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
async def alarm_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
"""Handle the /alarm command."""
|
|
"""Handle the /alarm command."""
|
|
- chat_id = update.effective_chat.id
|
|
|
|
- if not self._is_authorized(chat_id):
|
|
|
|
- await context.bot.send_message(chat_id=chat_id, text="❌ Unauthorized access.")
|
|
|
|
|
|
+ if not self._is_authorized(update):
|
|
|
|
+ await self._reply(update, "❌ Unauthorized access.")
|
|
return
|
|
return
|
|
|
|
|
|
|
|
+ chat_id = update.effective_chat.id
|
|
|
|
+
|
|
try:
|
|
try:
|
|
if not context.args or len(context.args) == 0:
|
|
if not context.args or len(context.args) == 0:
|
|
# No arguments - list all alarms
|
|
# No arguments - list all alarms
|
|
@@ -238,11 +238,12 @@ Will trigger when {token} price moves {alarm['direction']} {target_price_str}
|
|
|
|
|
|
async def logs_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
async def logs_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
"""Handle the /logs command."""
|
|
"""Handle the /logs command."""
|
|
- chat_id = update.effective_chat.id
|
|
|
|
- if not self._is_authorized(chat_id):
|
|
|
|
- await context.bot.send_message(chat_id=chat_id, text="❌ Unauthorized access.")
|
|
|
|
|
|
+ if not self._is_authorized(update):
|
|
|
|
+ await self._reply(update, "❌ Unauthorized access.")
|
|
return
|
|
return
|
|
|
|
|
|
|
|
+ chat_id = update.effective_chat.id
|
|
|
|
+
|
|
try:
|
|
try:
|
|
logs_dir = "logs"
|
|
logs_dir = "logs"
|
|
|
|
|
|
@@ -358,11 +359,12 @@ Will trigger when {token} price moves {alarm['direction']} {target_price_str}
|
|
|
|
|
|
async def debug_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
async def debug_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
"""Handle the /debug command."""
|
|
"""Handle the /debug command."""
|
|
- chat_id = update.effective_chat.id
|
|
|
|
- if not self._is_authorized(chat_id):
|
|
|
|
- await context.bot.send_message(chat_id=chat_id, text="❌ Unauthorized access.")
|
|
|
|
|
|
+ if not self._is_authorized(update):
|
|
|
|
+ await self._reply(update, "❌ Unauthorized access.")
|
|
return
|
|
return
|
|
|
|
|
|
|
|
+ chat_id = update.effective_chat.id
|
|
|
|
+
|
|
try:
|
|
try:
|
|
# Get monitoring status
|
|
# Get monitoring status
|
|
monitoring_status = await self.monitoring_coordinator.get_monitoring_status()
|
|
monitoring_status = await self.monitoring_coordinator.get_monitoring_status()
|
|
@@ -431,11 +433,12 @@ Will trigger when {token} price moves {alarm['direction']} {target_price_str}
|
|
|
|
|
|
async def version_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
async def version_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
"""Handle the /version command."""
|
|
"""Handle the /version command."""
|
|
- chat_id = update.effective_chat.id
|
|
|
|
- if not self._is_authorized(chat_id):
|
|
|
|
- await context.bot.send_message(chat_id=chat_id, text="❌ Unauthorized access.")
|
|
|
|
|
|
+ if not self._is_authorized(update):
|
|
|
|
+ await self._reply(update, "❌ Unauthorized access.")
|
|
return
|
|
return
|
|
|
|
|
|
|
|
+ chat_id = update.effective_chat.id
|
|
|
|
+
|
|
try:
|
|
try:
|
|
# Get monitoring status
|
|
# Get monitoring status
|
|
monitoring_status = await self.monitoring_coordinator.get_monitoring_status()
|
|
monitoring_status = await self.monitoring_coordinator.get_monitoring_status()
|
|
@@ -498,10 +501,11 @@ Will trigger when {token} price moves {alarm['direction']} {target_price_str}
|
|
|
|
|
|
async def keyboard_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
async def keyboard_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
"""Handle the /keyboard command to show the main keyboard."""
|
|
"""Handle the /keyboard command to show the main keyboard."""
|
|
- chat_id = update.effective_chat.id
|
|
|
|
- if not self._is_authorized(chat_id):
|
|
|
|
- await context.bot.send_message(chat_id=chat_id, text="❌ Unauthorized access.")
|
|
|
|
|
|
+ if not self._is_authorized(update):
|
|
|
|
+ await self._reply(update, "❌ Unauthorized access.")
|
|
return
|
|
return
|
|
|
|
+
|
|
|
|
+ chat_id = update.effective_chat.id
|
|
|
|
|
|
# Define default keyboard layout
|
|
# Define default keyboard layout
|
|
default_keyboard = [
|
|
default_keyboard = [
|
|
@@ -625,10 +629,11 @@ Will trigger when {token} price moves {alarm['direction']} {target_price_str}
|
|
|
|
|
|
async def deposit_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
async def deposit_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
"""Handle the /deposit command to record a deposit."""
|
|
"""Handle the /deposit command to record a deposit."""
|
|
- chat_id = update.effective_chat.id
|
|
|
|
- if not self._is_authorized(chat_id):
|
|
|
|
- await context.bot.send_message(chat_id=chat_id, text="❌ Unauthorized access.")
|
|
|
|
|
|
+ if not self._is_authorized(update):
|
|
|
|
+ await self._reply(update, "❌ Unauthorized access.")
|
|
return
|
|
return
|
|
|
|
+
|
|
|
|
+ chat_id = update.effective_chat.id
|
|
|
|
|
|
try:
|
|
try:
|
|
# Parse arguments
|
|
# Parse arguments
|
|
@@ -682,10 +687,11 @@ Will trigger when {token} price moves {alarm['direction']} {target_price_str}
|
|
|
|
|
|
async def withdrawal_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
async def withdrawal_command(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|
"""Handle the /withdrawal command to record a withdrawal."""
|
|
"""Handle the /withdrawal command to record a withdrawal."""
|
|
- chat_id = update.effective_chat.id
|
|
|
|
- if not self._is_authorized(chat_id):
|
|
|
|
- await context.bot.send_message(chat_id=chat_id, text="❌ Unauthorized access.")
|
|
|
|
|
|
+ if not self._is_authorized(update):
|
|
|
|
+ await self._reply(update, "❌ Unauthorized access.")
|
|
return
|
|
return
|
|
|
|
+
|
|
|
|
+ chat_id = update.effective_chat.id
|
|
|
|
|
|
try:
|
|
try:
|
|
# Parse arguments
|
|
# Parse arguments
|