Added connect platform
This commit is contained in:
@@ -200,6 +200,67 @@ async def settings(callback_query: CallbackQuery, state: FSMContext) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@router_handlers_main.message(Command("connect"))
|
||||||
|
@router_handlers_main.message(F.text == "Подключить платформу Bybit")
|
||||||
|
async def cmd_connect(message: Message, state: FSMContext) -> None:
|
||||||
|
"""
|
||||||
|
Handle the /connect command or text "Подключить платформу Bybit".
|
||||||
|
|
||||||
|
Clears FSM state and sends a connection message.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
message (Message): Incoming Telegram message object.
|
||||||
|
state (FSMContext): FSM state context.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
None: Exceptions are caught and logged internally.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
await state.clear()
|
||||||
|
user = await rq.get_user(tg_id=message.from_user.id)
|
||||||
|
if user:
|
||||||
|
await message.answer(
|
||||||
|
text=(
|
||||||
|
"Подключение Bybit аккаунта \n\n"
|
||||||
|
"1. Зарегистрируйтесь или войдите в свой аккаунт на Bybit по ссылке: "
|
||||||
|
"[Перейти на Bybit](https://www.bybit.com/invite?ref=YME83OJ).\n"
|
||||||
|
"2. В личном кабинете выберите раздел API. \n"
|
||||||
|
"3. Создание нового API ключа\n"
|
||||||
|
" - Нажмите кнопку Create New Key (Создать новый ключ).\n"
|
||||||
|
" - Выберите системно-сгенерированный ключ.\n"
|
||||||
|
" - Укажите название API ключа (любое). \n"
|
||||||
|
" - Выберите права доступа для торговли (Trade). \n"
|
||||||
|
" - Можно ограничить доступ по IP для безопасности.\n"
|
||||||
|
"4. Подтверждение создания\n"
|
||||||
|
" - Подтвердите создание ключа.\n"
|
||||||
|
" - Отправьте чат-роботу.\n\n"
|
||||||
|
"Важно: сохраните отдельно API Key и Secret Key в надежном месте. Secret ключ отображается только один раз."
|
||||||
|
),
|
||||||
|
parse_mode="Markdown",
|
||||||
|
reply_markup=kbi.add_bybit_api,
|
||||||
|
disable_web_page_preview=True,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
await rq.create_user(
|
||||||
|
tg_id=message.from_user.id, username=message.from_user.username
|
||||||
|
)
|
||||||
|
await rq.set_user_symbol(tg_id=message.from_user.id, symbol="BTCUSDT")
|
||||||
|
await rq.create_user_additional_settings(tg_id=message.from_user.id)
|
||||||
|
await rq.create_user_risk_management(tg_id=message.from_user.id)
|
||||||
|
await rq.create_user_conditional_settings(tg_id=message.from_user.id)
|
||||||
|
await cmd_connect(message=message, state=state)
|
||||||
|
logger.debug(
|
||||||
|
"Command connect processed successfully for user: %s",
|
||||||
|
message.from_user.id,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(
|
||||||
|
"Error processing command connect for user %s: %s",
|
||||||
|
message.from_user.id,
|
||||||
|
e,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@router_handlers_main.message(Command("help"))
|
@router_handlers_main.message(Command("help"))
|
||||||
async def cmd_help(message: Message, state: FSMContext) -> None:
|
async def cmd_help(message: Message, state: FSMContext) -> None:
|
||||||
"""
|
"""
|
||||||
@@ -220,7 +281,8 @@ async def cmd_help(message: Message, state: FSMContext) -> None:
|
|||||||
text="Используйте одну из следующих команд:\n"
|
text="Используйте одну из следующих команд:\n"
|
||||||
"/start - Запустить бота\n"
|
"/start - Запустить бота\n"
|
||||||
"/profile - Профиль\n"
|
"/profile - Профиль\n"
|
||||||
"/bybit - Панель Bybit\n",
|
"/bybit - Панель Bybit\n"
|
||||||
|
"/connect - Подключиться к платформе\n",
|
||||||
reply_markup=kbr.profile,
|
reply_markup=kbr.profile,
|
||||||
)
|
)
|
||||||
logger.debug(
|
logger.debug(
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
from aiogram.types import KeyboardButton, ReplyKeyboardMarkup
|
from aiogram.types import KeyboardButton, ReplyKeyboardMarkup
|
||||||
|
|
||||||
profile = ReplyKeyboardMarkup(
|
profile = ReplyKeyboardMarkup(
|
||||||
keyboard=[[KeyboardButton(text="Панель Bybit"), KeyboardButton(text="Профиль")]],
|
keyboard=[[KeyboardButton(text="Панель Bybit"), KeyboardButton(text="Профиль")],
|
||||||
|
[KeyboardButton(text="Подключить платформу Bybit")]],
|
||||||
resize_keyboard=True,
|
resize_keyboard=True,
|
||||||
one_time_keyboard=True,
|
one_time_keyboard=True,
|
||||||
input_field_placeholder="Выберите пункт меню...",
|
input_field_placeholder="Выберите пункт меню...",
|
||||||
|
Reference in New Issue
Block a user