Fix callback_query
This commit is contained in:
@@ -2,7 +2,7 @@ import logging
|
||||
from datetime import datetime
|
||||
|
||||
import asyncpg
|
||||
from aiogram import Router, types
|
||||
from aiogram import Router, types, F
|
||||
from aiogram.filters import Command
|
||||
|
||||
from auth import login_with_credentials
|
||||
|
||||
@@ -2,7 +2,7 @@ import subprocess
|
||||
from datetime import datetime
|
||||
|
||||
import asyncpg
|
||||
from aiogram import Router, types
|
||||
from aiogram import Router, types, F
|
||||
from aiogram.filters import Command
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.fsm.state import State, StatesGroup
|
||||
@@ -61,7 +61,7 @@ async def handle_admin_command(message: types.Message):
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "user_stats")
|
||||
@router.callback_query(F.data == "user_stats")
|
||||
@admin_only()
|
||||
async def user_stats_menu(callback_query: CallbackQuery):
|
||||
conn = await asyncpg.connect(DATABASE_URL)
|
||||
@@ -99,14 +99,14 @@ async def user_stats_menu(callback_query: CallbackQuery):
|
||||
await callback_query.answer()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "send_to_alls")
|
||||
@router.callback_query(F.data == "send_to_alls")
|
||||
@admin_only()
|
||||
async def handle_send_to_all(callback_query: CallbackQuery, state: FSMContext):
|
||||
await send_message_to_all_clients(callback_query.message, state, from_panel=True)
|
||||
await callback_query.answer()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "backups")
|
||||
@router.callback_query(F.data == "backups")
|
||||
@admin_only()
|
||||
async def handle_backup(message: Message):
|
||||
await message.answer("Запускаю бэкап базы данных...")
|
||||
@@ -114,7 +114,7 @@ async def handle_backup(message: Message):
|
||||
await message.answer("Бэкап завершен и отправлен админу.")
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "restart_bot")
|
||||
@router.callback_query(F.data == "restart_bot")
|
||||
@admin_only()
|
||||
async def handle_restart(callback_query: CallbackQuery):
|
||||
if callback_query.from_user.id == ADMIN_ID:
|
||||
@@ -136,7 +136,7 @@ async def handle_restart(callback_query: CallbackQuery):
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "user_editor")
|
||||
@router.callback_query(F.data == "user_editor")
|
||||
@admin_only()
|
||||
async def user_editor_menu(callback_query: CallbackQuery):
|
||||
keyboard = InlineKeyboardMarkup(
|
||||
@@ -161,7 +161,7 @@ async def user_editor_menu(callback_query: CallbackQuery):
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "back_to_admin_menu")
|
||||
@router.callback_query(F.data == "back_to_admin_menu")
|
||||
@admin_only()
|
||||
async def back_to_admin_menu(callback_query: CallbackQuery):
|
||||
try:
|
||||
|
||||
@@ -32,7 +32,7 @@ class UserEditorState(StatesGroup):
|
||||
waiting_for_expiry_time = State()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "search_by_tg_id")
|
||||
@router.callback_query(F.data == "search_by_tg_id")
|
||||
async def prompt_tg_id(callback_query: CallbackQuery, state: FSMContext):
|
||||
await callback_query.message.edit_text("Введите tg_id клиента:")
|
||||
await state.set_state(UserEditorState.waiting_for_tg_id)
|
||||
@@ -91,7 +91,7 @@ async def handle_tg_id_input(message: types.Message, state: FSMContext):
|
||||
await conn.close()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data.startswith("change_balance_"))
|
||||
@router.callback_query(F.data.startswith("change_balance_"))
|
||||
async def process_balance_change(callback_query: CallbackQuery, state: FSMContext):
|
||||
tg_id = int(callback_query.data.split("_")[2])
|
||||
await state.update_data(tg_id=tg_id)
|
||||
@@ -134,7 +134,7 @@ async def handle_new_balance_input(message: types.Message, state: FSMContext):
|
||||
await state.clear()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data.startswith("edit_key_"))
|
||||
@router.callback_query(F.data.startswith("edit_key_"))
|
||||
async def process_key_edit(callback_query: CallbackQuery):
|
||||
email = callback_query.data.split("_", 2)[2]
|
||||
|
||||
@@ -219,7 +219,7 @@ async def process_key_edit(callback_query: CallbackQuery):
|
||||
await callback_query.answer()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "search_by_key_name")
|
||||
@router.callback_query(F.data == "search_by_key_name")
|
||||
async def prompt_key_name(callback_query: CallbackQuery, state: FSMContext):
|
||||
await callback_query.message.edit_text("Введите имя ключа:")
|
||||
await state.set_state(UserEditorState.waiting_for_key_name)
|
||||
@@ -295,7 +295,7 @@ async def handle_key_name_input(message: types.Message, state: FSMContext):
|
||||
await state.clear()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data.startswith("change_expiry|"))
|
||||
@router.callback_query(F.data.startswith("change_expiry|"))
|
||||
async def prompt_expiry_change(callback_query: CallbackQuery, state: FSMContext):
|
||||
email = callback_query.data.split("|")[1]
|
||||
await callback_query.message.edit_text(
|
||||
@@ -392,7 +392,7 @@ async def renew_server_key(server_id, tg_id, client_id, email, new_expiry_time):
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data.startswith("delete_key_admin|"))
|
||||
@router.callback_query(F.data.startswith("delete_key_admin|"))
|
||||
async def process_callback_delete_key(callback_query: types.CallbackQuery):
|
||||
tg_id = callback_query.from_user.id
|
||||
email = callback_query.data.split("|")[1]
|
||||
@@ -440,7 +440,7 @@ async def process_callback_delete_key(callback_query: types.CallbackQuery):
|
||||
await callback_query.answer()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data.startswith("confirm_delete_admin|"))
|
||||
@router.callback_query(F.data.startswith("confirm_delete_admin|"))
|
||||
async def process_callback_confirm_delete(callback_query: types.CallbackQuery):
|
||||
tg_id = callback_query.from_user.id
|
||||
client_id = callback_query.data.split("|")[1]
|
||||
@@ -529,7 +529,7 @@ async def delete_key_from_db(client_id):
|
||||
await conn.close()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "back_to_user_editor")
|
||||
@router.callback_query(F.data == "back_to_user_editor")
|
||||
async def back_to_user_editor(callback_query: CallbackQuery):
|
||||
await back_to_admin_menu(callback_query)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import os
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import asyncpg
|
||||
from aiogram import Router, types
|
||||
from aiogram import Router, types, F
|
||||
from aiogram.types import BufferedInputFile
|
||||
|
||||
from auth import login_with_credentials
|
||||
@@ -46,7 +46,7 @@ logging.basicConfig(
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "view_keys")
|
||||
@router.callback_query(F.data == "view_keys")
|
||||
async def process_callback_view_keys(callback_query: types.CallbackQuery):
|
||||
tg_id = callback_query.from_user.id
|
||||
|
||||
@@ -125,7 +125,7 @@ async def process_callback_view_keys(callback_query: types.CallbackQuery):
|
||||
await callback_query.answer()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data.startswith("view_key|"))
|
||||
@router.callback_query(F.data.startswith("view_key|"))
|
||||
async def process_callback_view_key(callback_query: types.CallbackQuery):
|
||||
tg_id = callback_query.from_user.id
|
||||
key_name, client_id = (
|
||||
@@ -254,7 +254,7 @@ async def process_callback_view_key(callback_query: types.CallbackQuery):
|
||||
await callback_query.answer()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data.startswith("update_subscription|"))
|
||||
@router.callback_query(F.data.startswith("update_subscription|"))
|
||||
async def process_callback_update_subscription(callback_query: types.CallbackQuery):
|
||||
tg_id = callback_query.from_user.id
|
||||
client_id = callback_query.data.split("|")[1]
|
||||
@@ -381,7 +381,7 @@ async def update_key_on_server(tg_id, client_id, email, expiry_time, server_id):
|
||||
)
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data.startswith("delete_key|"))
|
||||
@router.callback_query(F.data.startswith("delete_key|"))
|
||||
async def process_callback_delete_key(callback_query: types.CallbackQuery):
|
||||
tg_id = callback_query.from_user.id
|
||||
client_id = callback_query.data.split("|")[1]
|
||||
@@ -427,7 +427,7 @@ async def process_callback_delete_key(callback_query: types.CallbackQuery):
|
||||
await callback_query.answer()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data.startswith("renew_key|"))
|
||||
@router.callback_query(F.data.startswith("renew_key|"))
|
||||
async def process_callback_renew_key(callback_query: types.CallbackQuery):
|
||||
tg_id = callback_query.from_user.id
|
||||
client_id = callback_query.data.split("|")[1]
|
||||
@@ -518,7 +518,7 @@ async def process_callback_renew_key(callback_query: types.CallbackQuery):
|
||||
await callback_query.answer()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data.startswith("confirm_delete|"))
|
||||
@router.callback_query(F.data.startswith("confirm_delete|"))
|
||||
async def process_callback_confirm_delete(callback_query: types.CallbackQuery):
|
||||
tg_id = callback_query.from_user.id
|
||||
client_id = callback_query.data.split("|")[1]
|
||||
@@ -615,7 +615,7 @@ async def delete_key_from_db(client_id):
|
||||
await conn.close()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data.startswith("renew_plan|"))
|
||||
@router.callback_query(F.data.startswith("renew_plan|"))
|
||||
async def process_callback_renew_plan(callback_query: types.CallbackQuery):
|
||||
tg_id = callback_query.from_user.id
|
||||
plan, client_id = (
|
||||
|
||||
@@ -4,7 +4,7 @@ import time
|
||||
import uuid
|
||||
|
||||
import requests
|
||||
from aiogram import Router, types
|
||||
from aiogram import Router, types, F
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.fsm.state import State, StatesGroup
|
||||
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup
|
||||
@@ -91,7 +91,7 @@ async def freekassa_webhook(request):
|
||||
return web.Response(status=200)
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "pay_freekassa")
|
||||
@router.callback_query(F.data == "pay_freekassa")
|
||||
async def process_callback_pay_freekassa(
|
||||
callback_query: types.CallbackQuery, state: FSMContext
|
||||
):
|
||||
@@ -121,14 +121,14 @@ async def process_callback_pay_freekassa(
|
||||
await callback_query.answer()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "back_to_profile")
|
||||
@router.callback_query(F.data == "back_to_profile")
|
||||
async def back_to_profile_handler(
|
||||
callback_query: types.CallbackQuery, state: FSMContext
|
||||
):
|
||||
await process_callback_view_profile(callback_query, state)
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data.startswith("amount|"))
|
||||
@router.callback_query(F.data.startswith("amount|"))
|
||||
async def process_amount_selection(
|
||||
callback_query: types.CallbackQuery, state: FSMContext
|
||||
):
|
||||
@@ -160,7 +160,7 @@ async def process_amount_selection(
|
||||
await callback_query.answer()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "enter_custom_amount")
|
||||
@router.callback_query(F.data == "enter_custom_amount")
|
||||
async def process_enter_custom_amount(
|
||||
callback_query: types.CallbackQuery, state: FSMContext
|
||||
):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
import uuid
|
||||
|
||||
from aiogram import Router, types
|
||||
from aiogram import Router, types, F
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.fsm.state import State, StatesGroup
|
||||
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup
|
||||
@@ -61,7 +61,7 @@ async def send_message_with_deletion(
|
||||
return sent_message
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "replenish_balance")
|
||||
@router.callback_query(F.data == "replenish_balance")
|
||||
async def process_callback_replenish_balance(
|
||||
callback_query: types.CallbackQuery, state: FSMContext
|
||||
):
|
||||
@@ -96,14 +96,14 @@ async def process_callback_replenish_balance(
|
||||
await callback_query.answer()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "back_to_profile")
|
||||
@router.callback_query(F.data == "back_to_profile")
|
||||
async def back_to_profile_handler(
|
||||
callback_query: types.CallbackQuery, state: FSMContext
|
||||
):
|
||||
await process_callback_view_profile(callback_query, state)
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data.startswith("amount|"))
|
||||
@router.callback_query(F.data.startswith("amount|"))
|
||||
async def process_amount_selection(
|
||||
callback_query: types.CallbackQuery, state: FSMContext
|
||||
):
|
||||
@@ -233,7 +233,7 @@ async def yookassa_webhook(request):
|
||||
return web.Response(status=200)
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "enter_custom_amount")
|
||||
@router.callback_query(F.data == "enter_custom_amount")
|
||||
async def process_enter_custom_amount(
|
||||
callback_query: types.CallbackQuery, state: FSMContext
|
||||
):
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
from aiogram import Router, types
|
||||
from aiogram import Router, types,F
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.fsm.state import State, StatesGroup
|
||||
from aiogram.types import BufferedInputFile, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
@@ -108,7 +108,7 @@ async def process_callback_view_profile(
|
||||
await callback_query.answer()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "invite")
|
||||
@router.callback_query(F.data == "invite")
|
||||
async def invite_handler(callback_query: types.CallbackQuery):
|
||||
tg_id = callback_query.from_user.id
|
||||
referral_link = get_referral_link(tg_id)
|
||||
@@ -129,6 +129,6 @@ async def invite_handler(callback_query: types.CallbackQuery):
|
||||
await callback_query.answer()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "view_profile")
|
||||
@router.callback_query(F.data == "view_profile")
|
||||
async def view_profile_handler(callback_query: types.CallbackQuery, state: FSMContext):
|
||||
await process_callback_view_profile(callback_query, state)
|
||||
|
||||
+5
-8
@@ -2,7 +2,7 @@ import logging
|
||||
import os
|
||||
|
||||
import asyncpg
|
||||
from aiogram import Router
|
||||
from aiogram import Router,F
|
||||
from aiogram.filters import Command
|
||||
from aiogram.fsm.state import State, StatesGroup
|
||||
from aiogram.types import (
|
||||
@@ -86,7 +86,7 @@ async def start_command(message: Message):
|
||||
await send_welcome_message(message.chat.id, trial_status)
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "connect_vpn")
|
||||
@router.callback_query(F.data == "connect_vpn")
|
||||
async def handle_connect_vpn(callback_query: CallbackQuery):
|
||||
await callback_query.message.delete()
|
||||
user_id = callback_query.from_user.id
|
||||
@@ -153,23 +153,20 @@ async def handle_connect_vpn(callback_query: CallbackQuery):
|
||||
await callback_query.answer()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "about_vpn")
|
||||
@router.callback_query(F.data == "about_vpn")
|
||||
async def handle_about_vpn(callback_query: CallbackQuery):
|
||||
await callback_query.message.delete()
|
||||
|
||||
bot_version = "3.0.1_beta"
|
||||
info_message = ABOUT_VPN.format(bot_version=bot_version)
|
||||
|
||||
button_back = InlineKeyboardButton(text="⬅️ Назад", callback_data="back_to_menu")
|
||||
inline_keyboard_back = InlineKeyboardMarkup(inline_keyboard=[[button_back]])
|
||||
|
||||
await callback_query.message.answer(
|
||||
info_message, parse_mode="HTML", reply_markup=inline_keyboard_back
|
||||
ABOUT_VPN, parse_mode="HTML", reply_markup=inline_keyboard_back
|
||||
)
|
||||
await callback_query.answer()
|
||||
|
||||
|
||||
@router.callback_query(lambda c: c.data == "back_to_menu")
|
||||
@router.callback_query(F.data == "back_to_menu")
|
||||
async def handle_back_to_menu(callback_query: CallbackQuery):
|
||||
await callback_query.message.delete()
|
||||
trial_status = await get_trial(callback_query.from_user.id)
|
||||
|
||||
Reference in New Issue
Block a user