Меню переделано как Игорь хотел

This commit is contained in:
2024-12-15 14:23:36 +03:00
parent 050ca9936b
commit dd80136194
6 changed files with 47 additions and 49 deletions

View File

@@ -1,4 +1,4 @@
---
# VPN Configuration Sales Bot
@@ -33,5 +33,4 @@
Этот проект распространяется под лицензией MIT License. Подробности в файле [LICENSE](./LICENSE).
---

View File

@@ -39,13 +39,13 @@ class MongoDBRepository:
self.logger.debug(f"VPN сервер добавлен с ID: {result.inserted_id}")
return result.inserted_id
async def get_server(self, server_id: str):
async def get_server(self, server_name: str):
"""Получает сервер VPN по его ID."""
server = await self.collection.find_one({"name": server_id})
server = await self.collection.find_one({"server.name": server_name})
if server:
self.logger.debug(f"Найден VPN сервер: {server}")
else:
self.logger.debug(f"VPN сервер с ID {server_id} не найден.")
self.logger.debug(f"VPN сервер с ID {server_name} не найден.")
return server
async def get_server_with_least_clients(self):

View File

@@ -181,17 +181,6 @@ class DatabaseManager:
self.logger.error(f"Не удалось найти сервер с ID {user_sub.vpn_server_id}.")
return "ERROR"
# Найдем клиента на сервере по telegram_id
client = None
for client_info in server['clients']:
if client_info['subscriptions']['tgId'] == telegram_id:
client = client_info
break
if not client:
self.logger.error(f"Не удалось найти клиента с Telegram ID {telegram_id} на сервере.")
return "ERROR"
# Доступ к данным сервера для добавления клиента
server_info = server['server']
url_base = f"https://{server_info['ip']}:{server_info['port']}/{server_info['secretKey']}"
@@ -203,10 +192,8 @@ class DatabaseManager:
# Инициализируем взаимодействие с панелью управления
panel = PanelInteraction(url_base, login_data, self.logger)
# Добавляем клиента на сервер
client_id = client['id']
expiry_date_iso = user_sub.expiry_date.isoformat()
response = await panel.add_client(client_id, expiry_date_iso, user.username)
response = await panel.add_client(user.id, expiry_date_iso, user.username)
# Логируем результат
if response == "OK":

View File

@@ -42,7 +42,7 @@ services:
context: .
container_name: telegram_bot
environment:
TOKEN: "7502946151:AAHspA8iieJqrhUHZveILGfeZWp-VqQhEnQ"
TOKEN: "8104061818:AAGJ6H1PTFmfJm-_mZqGv7EnHxGl4dZndnU"
POSTGRES_URL: "postgresql+asyncpg://AH3J9GSPBYOP:uPS9?y~mcu2@postgres:5432/bot_db"
MONGO_URL: "mongodb://root:itOj4CE2miKR@mongodb:27017"
DB_NAME: "MongoDBSub&Ser"

View File

@@ -3,7 +3,7 @@ from aiogram.filters import Command
from databases.postgresql import DatabaseManager
from databases.model import User, Subscription, Transaction, Administrators
from databases.db_config import get_postgres_session
from keyboard.keyboards import subhist_keyboard,confirm_popup_keyboard,tarif_confirm_keyboard, popup_keyboard, main_keyboard,faq_keyboard,about_tarifs_keyboard, account_keyboard, buy_keyboard,balance_keyboard,guide_keyboard,tarif_Lark_keyboard,tarif_Lark_pro_keyboard,tranhist_keyboard
from keyboard.keyboards import subhist_keyboard,confirm_popup_keyboard,tarif_confirm_keyboard, popup_keyboard, main_keyboard,faq_keyboard, account_keyboard, buy_keyboard,balance_keyboard,guide_keyboard,tarif_Lark_keyboard,tarif_Lark_pro_keyboard,tranhist_keyboard
# Инициализируем менеджер базы данных
db_manager = DatabaseManager(get_postgres_session)
@@ -24,14 +24,26 @@ async def start_command(message: types.Message):
"""
Обработчик команды /start.
"""
await message.answer("Привет! Я ваш Telegram-бот.", reply_markup=main_keyboard())
await message.answer(f"""Приветствуем в рядах птенец {message.from_user.username}🐣
\nСкорее пополни баланс, приобрети подписку и получай доступ к TikTok, YouTube, Discord, Instagram на всех устройствах без ограничений ❕❕❕
\nОзнакомься с руководством по пользованию и выбери подходящий тариф 🦅
\nСледи за акциями, спец-предложениями, а также розыгрышами по ссылке ниже
\n👇👇👇
\nhttps://t.me/+0z5xqn3F1m02OTJi
\nС любовью ваши пернатые разработчики 🤍🤍🤍""", reply_markup=main_keyboard())
async def start_callback_handler(callback: types.CallbackQuery):
"""
Обработчик callback_query с data="base".
"""
await callback.message.edit_text(
f"Привет! Я ваш Telegram-бот.",
f"""Приветствуем в рядах птенец {callback.from_user.username}🐣
\nСкорее пополни баланс, приобрети подписку и получай доступ к TikTok, YouTube, Discord, Instagram на всех устройствах без ограничений ❕❕❕
\nОзнакомься с руководством по пользованию и выбери подходящий тариф 🦅
\nСледи за акциями, спец-предложениями, а также розыгрышами по ссылке ниже
\n👇👇👇
\nhttps://t.me/+0z5xqn3F1m02OTJi
\nС любовью ваши пернатые разработчики 🤍🤍🤍""",
reply_markup=main_keyboard()
)
@@ -48,9 +60,9 @@ async def profile_callback_handler(callback: types.CallbackQuery):
return
if user:
text = f"""Ваш профиль:\nID: {user.username}\nБаланс: {user.balance}"""
await callback.message.edit_text(
f"Ваш профиль:\n"
f"👤 Username: {user.username}\n",
text,
reply_markup=account_keyboard()
)
else:
@@ -71,7 +83,7 @@ async def balance_callback_handler(callback: types.CallbackQuery):
if user:
await callback.message.edit_text(
f"Ваш баланс: {user.balance} рубликов",
f"Ваш баланс: {user.balance} ",
reply_markup=balance_keyboard()
)
else:
@@ -170,7 +182,7 @@ async def buy_subscription_callback_handler(callback: types.CallbackQuery):
Обработчик callback_query с data="buy_subscription".
"""
await callback.message.edit_text(
f"Покупайте, покупайте потому что мы скоро закроемся!!!",
f"Ознакомься с условиями в вкладке \"О тарифах\" и выбери подходящий 🦅",
reply_markup=buy_keyboard()
)
@@ -201,14 +213,14 @@ async def subs_pro_callback_handler(callback: types.CallbackQuery):
reply_markup=tarif_Lark_pro_keyboard()
)
async def about_tarifs_callback_handler(callback: types.CallbackQuery):
"""
Обработчик callback_query с data="about_tarifs".
"""
await callback.message.edit_text(
f"Бла бла бла, хуйня на хуйне",
reply_markup=about_tarifs_keyboard()
)
# async def about_tarifs_callback_handler(callback: types.CallbackQuery):
# """
# Обработчик callback_query с data="about_tarifs".
# """
# await callback.message.edit_text(
# f"Бла бла бла, хуйня на хуйне",
# reply_markup=about_tarifs_keyboard()
# )
async def faq_callback_handler(callback:types.CallbackQuery):
"""
@@ -309,7 +321,7 @@ def register_handlers(dp: Dispatcher):
dp.message.register(start_command, Command("start"))
dp.callback_query.register(balance_callback_handler, lambda c: c.data == "balance")
dp.callback_query.register(guide_callback_handler, lambda c: c.data == "guide")
dp.callback_query.register(about_tarifs_callback_handler, lambda c: c.data == "about_tarifs")
# dp.callback_query.register(about_tarifs_callback_handler, lambda c: c.data == "about_tarifs")
dp.callback_query.register(lark_tariff_callback_handler, lambda c: c.data.startswith("Lark:"))
dp.callback_query.register(confirm_callback_handler, lambda c: c.data.startswith("confirm:"))
dp.callback_query.register(popup_confirm_callback_handler, lambda c: c.data.startswith("popup:"))

View File

@@ -31,7 +31,7 @@ def buy_keyboard():
builder = InlineKeyboardBuilder()
builder.row(InlineKeyboardButton(text="Тариф Lark", callback_data="subs"))
builder.row(InlineKeyboardButton(text="Тариф Lark Pro", callback_data="subs_pro"))
builder.row(InlineKeyboardButton(text="О тарифах", callback_data="about_tarifs"))
builder.row(InlineKeyboardButton(text="О тарифах", url="https://t.me/proxylark/19"))
builder.row(InlineKeyboardButton(text="Назад", callback_data="profile"))
return builder.as_markup()
@@ -48,9 +48,9 @@ def popup_keyboard():
Пополнение
"""
builder = InlineKeyboardBuilder()
builder.row(InlineKeyboardButton(text="Пополнение на 100", callback_data="popup:100"))
builder.row(InlineKeyboardButton(text="Пополнение на 300", callback_data="popup:300"))
builder.row(InlineKeyboardButton(text="Пополнение на 500", callback_data="popup:500"))
builder.row(InlineKeyboardButton(text="200₽", callback_data="popup:200"),InlineKeyboardButton(text="500₽", callback_data="popup:500"))
builder.row(InlineKeyboardButton(text="1000₽", callback_data="popup:1000"),InlineKeyboardButton(text="2000₽", callback_data="popup:2000"))
builder.row(InlineKeyboardButton(text="3000₽", callback_data="popup:3000"),InlineKeyboardButton(text="5000₽", callback_data="popup:5000"))
builder.row(InlineKeyboardButton(text="Назад", callback_data="balance"))
return builder.as_markup()
@@ -70,8 +70,8 @@ def tarif_Lark_keyboard():
"""
builder = InlineKeyboardBuilder()
builder.row(InlineKeyboardButton(text="Тариф Lark 1 Месяц", callback_data="Lark:Standart:1"))
builder.row(InlineKeyboardButton(text="Тариф Lark 3 Месяц", callback_data="Lark:Standart:3"))
builder.row(InlineKeyboardButton(text="Тариф Lark 6 Месяц", callback_data="Lark:Standart:6"))
builder.row(InlineKeyboardButton(text="Тариф Lark 12 Месяц", callback_data="Lark:Standart:12"))
builder.row(InlineKeyboardButton(text="Назад", callback_data="buy_subscription"))
return builder.as_markup()
@@ -81,8 +81,8 @@ def tarif_Lark_pro_keyboard():
"""
builder = InlineKeyboardBuilder()
builder.row(InlineKeyboardButton(text="Тариф Lark Pro 1 Месяц", callback_data="Lark:Pro:1"))
builder.row(InlineKeyboardButton(text="Тариф Lark Pro 3 Месяц", callback_data="Lark:Pro:3"))
builder.row(InlineKeyboardButton(text="Тариф Lark Pro 6 Месяц", callback_data="Lark:Pro:6"))
builder.row(InlineKeyboardButton(text="Тариф Lark Pro 12 Месяц", callback_data="Lark:Pro:12"))
builder.row(InlineKeyboardButton(text="Назад", callback_data="buy_subscription"))
return builder.as_markup()
@@ -97,13 +97,13 @@ def guide_keyboard():
return builder.as_markup()
def about_tarifs_keyboard():
"""
О тарифах
"""
builder = InlineKeyboardBuilder()
builder.row(InlineKeyboardButton(text="Назад", callback_data="buy_subscription"))
return builder.as_markup()
# def about_tarifs_keyboard():
# """
# О тарифах
# """
# builder = InlineKeyboardBuilder()
# builder.row(InlineKeyboardButton(text="Назад", callback_data="buy_subscription"))
# return builder.as_markup()
def faq_keyboard():