Fix formating and freekassa
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
[flake8]
|
[flake8]
|
||||||
max-line-length = 200
|
max-line-length = 250
|
||||||
ignore = E203, E266, E501, W503, F541, E704, W293, W291, E126, E121, E123, E128, E302, E131, E231, W292, E402, E261
|
ignore = E203, E266, E501, W503, F541, E704, W293, W291, E126, E121, E123, E128, E302, E131, E231, W292, E402, E261
|
||||||
max-complexity = 25
|
max-complexity = 25
|
||||||
select = B, C, E, F, W, T4, B9
|
select = B, C, E, F, W, T4, B9
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
[settings]
|
[settings]
|
||||||
profile=black
|
profile=black
|
||||||
line_length = 200
|
line_length = 250
|
||||||
@@ -18,7 +18,9 @@ async def cmd_add_balance(message: types.Message):
|
|||||||
return
|
return
|
||||||
|
|
||||||
await add_balance_to_client(int(client_id), amount)
|
await add_balance_to_client(int(client_id), amount)
|
||||||
await message.reply(f"✅ Баланс клиента {client_id} успешно пополнен на {amount}")
|
await message.reply(
|
||||||
|
f"✅ Баланс клиента {client_id} успешно пополнен на {amount}"
|
||||||
|
)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
await message.reply(
|
await message.reply(
|
||||||
"❓ Неверный формат команды!\n"
|
"❓ Неверный формат команды!\n"
|
||||||
|
|||||||
@@ -31,15 +31,17 @@ async def handle_admin_command(message: types.Message):
|
|||||||
text="📊 Статистика пользователей", callback_data="user_stats"
|
text="📊 Статистика пользователей", callback_data="user_stats"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
builder.row(
|
|
||||||
InlineKeyboardButton(text="👥 Управление пользователями", callback_data="user_editor")
|
|
||||||
)
|
|
||||||
builder.row(
|
builder.row(
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text="📢 Массовая рассылка", callback_data="send_to_alls"
|
text="👥 Управление пользователями", callback_data="user_editor"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
builder.row(InlineKeyboardButton(text="💾 Создать резервную копию", callback_data="backups"))
|
builder.row(
|
||||||
|
InlineKeyboardButton(text="📢 Массовая рассылка", callback_data="send_to_alls")
|
||||||
|
)
|
||||||
|
builder.row(
|
||||||
|
InlineKeyboardButton(text="💾 Создать резервную копию", callback_data="backups")
|
||||||
|
)
|
||||||
builder.row(
|
builder.row(
|
||||||
InlineKeyboardButton(text="🔄 Перезагрузить бота", callback_data="restart_bot")
|
InlineKeyboardButton(text="🔄 Перезагрузить бота", callback_data="restart_bot")
|
||||||
)
|
)
|
||||||
@@ -73,7 +75,9 @@ async def user_stats_menu(callback_query: CallbackQuery):
|
|||||||
|
|
||||||
builder = InlineKeyboardBuilder()
|
builder = InlineKeyboardBuilder()
|
||||||
builder.row(
|
builder.row(
|
||||||
InlineKeyboardButton(text="🔙 Вернуться в меню", callback_data="back_to_admin_menu")
|
InlineKeyboardButton(
|
||||||
|
text="🔙 Вернуться в меню", callback_data="back_to_admin_menu"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
await callback_query.message.edit_text(
|
await callback_query.message.edit_text(
|
||||||
@@ -94,7 +98,9 @@ async def handle_send_to_all(callback_query: CallbackQuery, state: FSMContext):
|
|||||||
async def handle_backup(message: Message):
|
async def handle_backup(message: Message):
|
||||||
await message.answer("💾 Инициализация резервного копирования базы данных...")
|
await message.answer("💾 Инициализация резервного копирования базы данных...")
|
||||||
await backup_database()
|
await backup_database()
|
||||||
await message.answer("✅ Резервная копия успешно создана и отправлена администратору.")
|
await message.answer(
|
||||||
|
"✅ Резервная копия успешно создана и отправлена администратору."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.callback_query(F.data == "restart_bot", IsAdminFilter)
|
@router.callback_query(F.data == "restart_bot", IsAdminFilter)
|
||||||
@@ -122,9 +128,15 @@ async def user_editor_menu(callback_query: CallbackQuery):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
builder.row(
|
builder.row(
|
||||||
InlineKeyboardButton(text="🆔 Поиск по Telegram ID", callback_data="search_by_tg_id")
|
InlineKeyboardButton(
|
||||||
|
text="🆔 Поиск по Telegram ID", callback_data="search_by_tg_id"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
builder.row(
|
||||||
|
InlineKeyboardButton(
|
||||||
|
text="🔙 Вернуться назад", callback_data="back_to_admin_menu"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
builder.row(InlineKeyboardButton(text="🔙 Вернуться назад", callback_data="back_to_admin_menu"))
|
|
||||||
await callback_query.message.edit_text(
|
await callback_query.message.edit_text(
|
||||||
"👇 Выберите способ поиска пользователя:", reply_markup=builder.as_markup()
|
"👇 Выберите способ поиска пользователя:", reply_markup=builder.as_markup()
|
||||||
)
|
)
|
||||||
@@ -144,15 +156,17 @@ async def back_to_admin_menu(callback_query: CallbackQuery):
|
|||||||
text="📊 Статистика пользователей", callback_data="user_stats"
|
text="📊 Статистика пользователей", callback_data="user_stats"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
builder.row(
|
|
||||||
InlineKeyboardButton(text="👥 Управление пользователями", callback_data="user_editor")
|
|
||||||
)
|
|
||||||
builder.row(
|
builder.row(
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text="📢 Массовая рассылка", callback_data="send_to_alls"
|
text="👥 Управление пользователями", callback_data="user_editor"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
builder.row(InlineKeyboardButton(text="💾 Создать резервную копию", callback_data="backups"))
|
builder.row(
|
||||||
|
InlineKeyboardButton(text="📢 Массовая рассылка", callback_data="send_to_alls")
|
||||||
|
)
|
||||||
|
builder.row(
|
||||||
|
InlineKeyboardButton(text="💾 Создать резервную копию", callback_data="backups")
|
||||||
|
)
|
||||||
builder.row(
|
builder.row(
|
||||||
InlineKeyboardButton(text="🔄 Перезагрузить бота", callback_data="restart_bot")
|
InlineKeyboardButton(text="🔄 Перезагрузить бота", callback_data="restart_bot")
|
||||||
)
|
)
|
||||||
|
|||||||
+12
-4
@@ -32,7 +32,9 @@ async def backup_command(message: Message):
|
|||||||
|
|
||||||
await message.answer("🔄 Инициализация резервного копирования базы данных...")
|
await message.answer("🔄 Инициализация резервного копирования базы данных...")
|
||||||
await backup_database()
|
await backup_database()
|
||||||
await message.answer("✅ Бэкап базы данных успешно завершен и отправлен администратору.")
|
await message.answer(
|
||||||
|
"✅ Бэкап базы данных успешно завершен и отправлен администратору."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.message(Command("start"))
|
@router.message(Command("start"))
|
||||||
@@ -75,10 +77,14 @@ async def handle_send_trial_command(message: types.Message, state: FSMContext):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
if "Forbidden: bot was blocked by the user" in str(e):
|
if "Forbidden: bot was blocked by the user" in str(e):
|
||||||
blocked_count += 1
|
blocked_count += 1
|
||||||
logger.info(f"🚫 Бот заблокирован пользователем с tg_id: {tg_id}")
|
logger.info(
|
||||||
|
f"🚫 Бот заблокирован пользователем с tg_id: {tg_id}"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
error_count += 1
|
error_count += 1
|
||||||
logger.error(f"❌ Ошибка при отправке сообщения пользователю {tg_id}: {e}")
|
logger.error(
|
||||||
|
f"❌ Ошибка при отправке сообщения пользователю {tg_id}: {e}"
|
||||||
|
)
|
||||||
|
|
||||||
await message.answer(
|
await message.answer(
|
||||||
f"📊 Результаты рассылки пробных периодов:\n"
|
f"📊 Результаты рассылки пробных периодов:\n"
|
||||||
@@ -87,7 +93,9 @@ async def handle_send_trial_command(message: types.Message, state: FSMContext):
|
|||||||
f"❌ Ошибок: {error_count}"
|
f"❌ Ошибок: {error_count}"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await message.answer("📭 Нет пользователей с неиспользованными пробными ключами.")
|
await message.answer(
|
||||||
|
"📭 Нет пользователей с неиспользованными пробными ключами."
|
||||||
|
)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
await conn.close()
|
await conn.close()
|
||||||
|
|||||||
@@ -209,9 +209,7 @@ async def handle_key_name_input(message: Message, state: FSMContext):
|
|||||||
|
|
||||||
remaining_time = expiry_time - current_time
|
remaining_time = expiry_time - current_time
|
||||||
days = remaining_time.days
|
days = remaining_time.days
|
||||||
key_message = key_message_success(
|
key_message = key_message_success(public_link, f"⏳ Осталось дней: {days} 📅")
|
||||||
public_link, f"⏳ Осталось дней: {days} 📅"
|
|
||||||
)
|
|
||||||
|
|
||||||
await message.bot.send_message(
|
await message.bot.send_message(
|
||||||
tg_id, key_message, parse_mode="HTML", reply_markup=keyboard
|
tg_id, key_message, parse_mode="HTML", reply_markup=keyboard
|
||||||
|
|||||||
@@ -138,7 +138,9 @@ async def process_callback_view_key(callback_query: types.CallbackQuery):
|
|||||||
time_left = expiry_date - current_date
|
time_left = expiry_date - current_date
|
||||||
|
|
||||||
if time_left.total_seconds() <= 0:
|
if time_left.total_seconds() <= 0:
|
||||||
days_left_message = "<b>🕒 Статус подписки:</b>\n🔴 Истекла\nОсталось часов: 0"
|
days_left_message = (
|
||||||
|
"<b>🕒 Статус подписки:</b>\n🔴 Истекла\nОсталось часов: 0"
|
||||||
|
)
|
||||||
elif time_left.days > 0:
|
elif time_left.days > 0:
|
||||||
days_left_message = f"Осталось дней: <b>{time_left.days}</b>"
|
days_left_message = f"Осталось дней: <b>{time_left.days}</b>"
|
||||||
else:
|
else:
|
||||||
|
|||||||
+7
-5
@@ -17,33 +17,35 @@ async def handle_pay(callback_query: CallbackQuery):
|
|||||||
if YOOKASSA_ENABLE:
|
if YOOKASSA_ENABLE:
|
||||||
builder.row(
|
builder.row(
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text="💳 ЯКасса: быстрый перевод",
|
text="💳 ЯКасса: быстрый перевод",
|
||||||
callback_data="pay_yookassa",
|
callback_data="pay_yookassa",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if FREEKASSA_ENABLE:
|
if FREEKASSA_ENABLE:
|
||||||
builder.row(
|
builder.row(
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text="🌐 FreeKassa: множество способов",
|
text="🌐 FreeKassa: множество способов",
|
||||||
callback_data="pay_freekassa",
|
callback_data="pay_freekassa",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if CRYPTO_BOT_ENABLE:
|
if CRYPTO_BOT_ENABLE:
|
||||||
builder.row(
|
builder.row(
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text="💰 CryptoBot: криптовалюта",
|
text="💰 CryptoBot: криптовалюта",
|
||||||
callback_data="pay_cryptobot",
|
callback_data="pay_cryptobot",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if STARS_ENABLE:
|
if STARS_ENABLE:
|
||||||
builder.row(
|
builder.row(
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text="⭐ Оплата Звездами",
|
text="⭐ Оплата Звездами",
|
||||||
callback_data="pay_stars",
|
callback_data="pay_stars",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
builder.row(InlineKeyboardButton(text="⬅️ Вернуться в профиль", callback_data="view_profile"))
|
builder.row(
|
||||||
|
InlineKeyboardButton(text="⬅️ Вернуться в профиль", callback_data="view_profile")
|
||||||
|
)
|
||||||
|
|
||||||
await callback_query.message.answer(
|
await callback_query.message.answer(
|
||||||
"💸 <b>Выберите удобный способ пополнения баланса:</b>\n\n"
|
"💸 <b>Выберите удобный способ пополнения баланса:</b>\n\n"
|
||||||
|
|||||||
@@ -11,10 +11,12 @@ from aiogram.fsm.state import State, StatesGroup
|
|||||||
from aiogram.types import InlineKeyboardButton
|
from aiogram.types import InlineKeyboardButton
|
||||||
from aiogram.utils.keyboard import InlineKeyboardBuilder
|
from aiogram.utils.keyboard import InlineKeyboardBuilder
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
from telegram import InlineKeyboardMarkup
|
||||||
|
|
||||||
from bot import bot
|
from bot import bot
|
||||||
from config import FREEKASSA_API_KEY, FREEKASSA_SHOP_ID
|
from config import FREEKASSA_API_KEY, FREEKASSA_SHOP_ID
|
||||||
from database import update_balance
|
from database import update_balance
|
||||||
|
from handlers.texts import PAYMENT_OPTIONS
|
||||||
|
|
||||||
router = Router()
|
router = Router()
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|||||||
+11
-7
@@ -31,9 +31,7 @@ async def process_callback_view_profile(
|
|||||||
profile_message = profile_message_send(username, chat_id, balance, key_count)
|
profile_message = profile_message_send(username, chat_id, balance, key_count)
|
||||||
|
|
||||||
if key_count == 0:
|
if key_count == 0:
|
||||||
profile_message += (
|
profile_message += "\n🔧 <i>Нажмите кнопку ➕ Устройство, чтобы настроить VPN-подключение</i>"
|
||||||
"\n🔧 <i>Нажмите кнопку ➕ Устройство, чтобы настроить VPN-подключение</i>"
|
|
||||||
)
|
|
||||||
|
|
||||||
builder = InlineKeyboardBuilder()
|
builder = InlineKeyboardBuilder()
|
||||||
builder.row(InlineKeyboardButton(text="📢 Наш канал", url=CHANNEL_URL))
|
builder.row(InlineKeyboardButton(text="📢 Наш канал", url=CHANNEL_URL))
|
||||||
@@ -51,13 +49,15 @@ async def process_callback_view_profile(
|
|||||||
InlineKeyboardButton(text="👥 Пригласить друзей", callback_data="invite"),
|
InlineKeyboardButton(text="👥 Пригласить друзей", callback_data="invite"),
|
||||||
InlineKeyboardButton(text="📘 Инструкции", callback_data="instructions"),
|
InlineKeyboardButton(text="📘 Инструкции", callback_data="instructions"),
|
||||||
)
|
)
|
||||||
builder.row(InlineKeyboardButton(text="⬅️ Главное меню", callback_data="back_to_menu"))
|
builder.row(
|
||||||
|
InlineKeyboardButton(text="⬅️ Главное меню", callback_data="back_to_menu")
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await callback_query.message.delete()
|
await callback_query.message.delete()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"❗ Ошибка при удалении сообщения: {e}")
|
logger.error(f"❗ Ошибка при удалении сообщения: {e}")
|
||||||
|
|
||||||
if os.path.isfile(image_path):
|
if os.path.isfile(image_path):
|
||||||
with open(image_path, "rb") as image_file:
|
with open(image_path, "rb") as image_file:
|
||||||
await bot.send_photo(
|
await bot.send_photo(
|
||||||
@@ -76,7 +76,9 @@ async def process_callback_view_profile(
|
|||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await bot.send_message(chat_id, f"❗️ Не удалось загрузить профиль. Техническая ошибка: {e}")
|
await bot.send_message(
|
||||||
|
chat_id, f"❗️ Не удалось загрузить профиль. Техническая ошибка: {e}"
|
||||||
|
)
|
||||||
|
|
||||||
await callback_query.answer()
|
await callback_query.answer()
|
||||||
|
|
||||||
@@ -91,7 +93,9 @@ async def invite_handler(callback_query: types.CallbackQuery):
|
|||||||
invite_message = invite_message_send(referral_link, referral_stats)
|
invite_message = invite_message_send(referral_link, referral_stats)
|
||||||
|
|
||||||
builder = InlineKeyboardBuilder()
|
builder = InlineKeyboardBuilder()
|
||||||
builder.row(InlineKeyboardButton(text="⬅️ Вернуться в профиль", callback_data="view_profile"))
|
builder.row(
|
||||||
|
InlineKeyboardButton(text="⬅️ Вернуться в профиль", callback_data="view_profile")
|
||||||
|
)
|
||||||
|
|
||||||
await callback_query.message.delete()
|
await callback_query.message.delete()
|
||||||
|
|
||||||
|
|||||||
+8
-8
@@ -107,23 +107,23 @@ async def handle_connect_vpn(callback_query: CallbackQuery):
|
|||||||
|
|
||||||
builder.row(
|
builder.row(
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text="🍏 Скачать для iOS",
|
text="🍏 Скачать для iOS",
|
||||||
url="https://apps.apple.com/ru/app/v2raytun/id6476628951"
|
url="https://apps.apple.com/ru/app/v2raytun/id6476628951",
|
||||||
),
|
),
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text="🤖 Скачать для Android",
|
text="🤖 Скачать для Android",
|
||||||
url="https://play.google.com/store/apps/details?id=com.v2raytun.android&hl=ru"
|
url="https://play.google.com/store/apps/details?id=com.v2raytun.android&hl=ru",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
builder.row(
|
builder.row(
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text="🍏 Подключить на iOS",
|
text="🍏 Подключить на iOS",
|
||||||
url=f'{APP_URL}/?url=v2raytun://import/{trial_key_info["key"]}'
|
url=f'{APP_URL}/?url=v2raytun://import/{trial_key_info["key"]}',
|
||||||
),
|
),
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text="🤖 Подключить на Android",
|
text="🤖 Подключить на Android",
|
||||||
url=f'{APP_URL}/?url=v2raytun://import-sub?url={trial_key_info["key"]}'
|
url=f'{APP_URL}/?url=v2raytun://import-sub?url={trial_key_info["key"]}',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user