Update id
This commit is contained in:
+2
-2
@@ -11,7 +11,7 @@ class IsAdminFilter(BaseFilter):
|
||||
try:
|
||||
admin_ids: Union[int, list[int]] = ADMIN_ID
|
||||
if isinstance(admin_ids, list):
|
||||
return message.from_user.id in admin_ids
|
||||
return message.from_user.id == admin_ids
|
||||
return message.chat.id in admin_ids
|
||||
return message.chat.id == admin_ids
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ async def handle_activate_coupon(callback_query: types.CallbackQuery, state: FSM
|
||||
@router.message(CouponActivationState.waiting_for_coupon_code)
|
||||
async def process_coupon_code(message: types.Message, state: FSMContext, session: Any):
|
||||
coupon_code = message.text.strip()
|
||||
activation_result = await activate_coupon(message.from_user.id, coupon_code, session)
|
||||
activation_result = await activate_coupon(message.chat.id, coupon_code, session)
|
||||
|
||||
builder = InlineKeyboardBuilder()
|
||||
builder.row(InlineKeyboardButton(text="👤 Личный кабинет", callback_data="profile"))
|
||||
|
||||
@@ -35,7 +35,7 @@ async def send_instructions(callback_query: types.CallbackQuery):
|
||||
|
||||
@router.callback_query(F.data.startswith("connect_pc|"))
|
||||
async def process_connect_pc(callback_query: types.CallbackQuery, session: Any):
|
||||
tg_id = callback_query.from_user.id
|
||||
tg_id = callback_query.chat.id
|
||||
key_name = callback_query.data.split("|")[1]
|
||||
|
||||
record = await session.fetchrow(
|
||||
|
||||
@@ -34,7 +34,7 @@ async def process_callback_create_key(callback_query: CallbackQuery, state: FSMC
|
||||
|
||||
|
||||
async def select_server(callback_query: CallbackQuery, state: FSMContext, session: Any):
|
||||
trial_status = await get_trial(callback_query.from_user.id, session)
|
||||
trial_status = await get_trial(callback_query.chat.id, session)
|
||||
if trial_status == 1:
|
||||
builder = InlineKeyboardBuilder()
|
||||
builder.row(
|
||||
@@ -54,7 +54,7 @@ async def select_server(callback_query: CallbackQuery, state: FSMContext, sessio
|
||||
|
||||
@router.callback_query(F.data == "confirm_create_new_key")
|
||||
async def confirm_create_new_key(callback_query: CallbackQuery, state: FSMContext):
|
||||
tg_id = callback_query.from_user.id
|
||||
tg_id = callback_query.chat.id
|
||||
|
||||
logger.info(f"User {tg_id} confirmed creation of a new key.")
|
||||
|
||||
@@ -76,7 +76,7 @@ async def confirm_create_new_key(callback_query: CallbackQuery, state: FSMContex
|
||||
|
||||
@router.message(Form.waiting_for_key_name)
|
||||
async def handle_key_name_input(message: Message, state: FSMContext, session: Any):
|
||||
tg_id = message.from_user.id
|
||||
tg_id = message.chat.id
|
||||
key_name = sanitize_key_name(message.text)
|
||||
|
||||
logger.info(f"User {tg_id} is attempting to create a key with the name: {key_name}")
|
||||
@@ -106,7 +106,7 @@ async def handle_key_name_input(message: Message, state: FSMContext, session: An
|
||||
expiry_time = None
|
||||
|
||||
logger.info(f"Checking trial status for user {tg_id}.")
|
||||
trial_status = await get_trial(message.from_user.id, session)
|
||||
trial_status = await get_trial(message.chat.id, session)
|
||||
|
||||
if trial_status == 0:
|
||||
expiry_time = current_time + timedelta(days=1, hours=3)
|
||||
@@ -172,9 +172,9 @@ async def handle_key_name_input(message: Message, state: FSMContext, session: An
|
||||
await asyncio.gather(*tasks)
|
||||
|
||||
logger.info(f"Updating trial status for user {tg_id} in the database.")
|
||||
trial_status = await get_trial(message.from_user.id, session)
|
||||
trial_status = await get_trial(message.chat.id, session)
|
||||
if trial_status == 0:
|
||||
await use_trial(message.from_user.id, session)
|
||||
await use_trial(message.chat.id, session)
|
||||
else:
|
||||
await add_connection(tg_id, 0, 1)
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ router = Router()
|
||||
|
||||
@router.callback_query(F.data == "view_keys")
|
||||
async def process_callback_view_keys(callback_query: types.CallbackQuery, session: Any):
|
||||
tg_id = callback_query.from_user.id
|
||||
tg_id = callback_query.chat.id
|
||||
try:
|
||||
records = await session.fetch(
|
||||
"""
|
||||
@@ -99,7 +99,7 @@ async def process_callback_view_keys(callback_query: types.CallbackQuery, sessio
|
||||
|
||||
@router.callback_query(F.data.startswith("view_key|"))
|
||||
async def process_callback_view_key(callback_query: types.CallbackQuery, session: Any):
|
||||
tg_id = callback_query.from_user.id
|
||||
tg_id = callback_query.chat.id
|
||||
key_name = callback_query.data.split("|")[1]
|
||||
try:
|
||||
record = await session.fetchrow(
|
||||
@@ -185,7 +185,7 @@ async def process_callback_view_key(callback_query: types.CallbackQuery, session
|
||||
|
||||
@router.callback_query(F.data.startswith("update_subscription|"))
|
||||
async def process_callback_update_subscription(callback_query: types.CallbackQuery, session: Any):
|
||||
tg_id = callback_query.from_user.id
|
||||
tg_id = callback_query.chat.id
|
||||
email = callback_query.data.split("|")[1]
|
||||
try:
|
||||
record = await session.fetchrow(
|
||||
@@ -284,7 +284,7 @@ async def process_callback_delete_key(callback_query: types.CallbackQuery):
|
||||
|
||||
@router.callback_query(F.data.startswith("renew_key|"))
|
||||
async def process_callback_renew_key(callback_query: types.CallbackQuery, session: Any):
|
||||
tg_id = callback_query.from_user.id
|
||||
tg_id = callback_query.chat.id
|
||||
key_name = callback_query.data.split("|")[1]
|
||||
try:
|
||||
record = await session.fetchrow(
|
||||
@@ -390,7 +390,7 @@ async def process_callback_confirm_delete(callback_query: types.CallbackQuery, s
|
||||
|
||||
@router.callback_query(F.data.startswith("renew_plan|"))
|
||||
async def process_callback_renew_plan(callback_query: types.CallbackQuery, session: Any):
|
||||
tg_id = callback_query.from_user.id
|
||||
tg_id = callback_query.chat.id
|
||||
plan, client_id = (
|
||||
callback_query.data.split("|")[1],
|
||||
callback_query.data.split("|")[2],
|
||||
|
||||
@@ -53,11 +53,11 @@ async def process_callback_pay_cryptobot(callback_query: types.CallbackQuery, st
|
||||
)
|
||||
)
|
||||
builder.row(InlineKeyboardButton(text="⬅️ Назад", callback_data="back_to_profile"))
|
||||
key_count = await get_key_count(callback_query.from_user.id)
|
||||
key_count = await get_key_count(callback_query.chat.id)
|
||||
if key_count == 0:
|
||||
exists = await check_connection_exists(callback_query.from_user.id)
|
||||
exists = await check_connection_exists(callback_query.chat.id)
|
||||
if not exists:
|
||||
await add_connection(callback_query.from_user.id, balance=0.0, trial=0)
|
||||
await add_connection(callback_query.chat.id, balance=0.0, trial=0)
|
||||
await callback_query.message.answer(
|
||||
"Выберите сумму пополнения:",
|
||||
reply_markup=builder.as_markup(),
|
||||
@@ -88,7 +88,7 @@ async def process_amount_selection(callback_query: types.CallbackQuery, state: F
|
||||
asset="USDT",
|
||||
amount=str(int(amount // RUB_TO_USDT)),
|
||||
description=f"Пополнения баланса на {amount} руб",
|
||||
payload=f"{callback_query.from_user.id}:{int(amount)}",
|
||||
payload=f"{callback_query.chat.id}:{int(amount)}",
|
||||
)
|
||||
|
||||
if hasattr(invoice, "bot_invoice_url"):
|
||||
@@ -158,7 +158,7 @@ async def process_custom_amount_input(message: types.Message, state: FSMContext)
|
||||
asset="USDT",
|
||||
amount=str(int(amount // RUB_TO_USDT)),
|
||||
description=f"Пополнения баланса на {amount} руб",
|
||||
payload=f"{message.from_user.id}:{amount}",
|
||||
payload=f"{message.chat.id}:{amount}",
|
||||
)
|
||||
|
||||
if hasattr(invoice, "bot_invoice_url"):
|
||||
|
||||
@@ -130,9 +130,9 @@ async def process_amount_selection(callback_query: types.CallbackQuery, state: F
|
||||
await callback_query.message.answer("Некорректная сумма.")
|
||||
return
|
||||
|
||||
user_email = f"{callback_query.from_user.id}@solo.net"
|
||||
user_email = f"{callback_query.chat.id}@solo.net"
|
||||
user_ip = callback_query.message.chat.id
|
||||
payment_url = await create_payment(callback_query.from_user.id, amount, user_email, user_ip)
|
||||
payment_url = await create_payment(callback_query.chat.id, amount, user_email, user_ip)
|
||||
|
||||
if payment_url:
|
||||
confirm_keyboard = InlineKeyboardMarkup(
|
||||
@@ -166,9 +166,9 @@ async def process_custom_amount_input(message: types.Message, state: FSMContext)
|
||||
await message.answer("Сумма должна быть больше нуля. Пожалуйста, введите сумму еще раз:")
|
||||
return
|
||||
|
||||
user_email = f"{message.from_user.id}@solo.net"
|
||||
user_email = f"{message.chat.id}@solo.net"
|
||||
user_ip = message.chat.id
|
||||
payment_url = await create_payment(message.from_user.id, amount, user_email, user_ip)
|
||||
payment_url = await create_payment(message.chat.id, amount, user_email, user_ip)
|
||||
|
||||
if payment_url:
|
||||
keyboard = InlineKeyboardMarkup(inline_keyboard=[[InlineKeyboardButton("Оплатить", url=payment_url)]])
|
||||
|
||||
@@ -49,7 +49,7 @@ def generate_payment_link(amount, inv_id, description, tg_id):
|
||||
|
||||
@router.callback_query(F.data == "pay_robokassa")
|
||||
async def process_callback_pay_robokassa(callback_query: types.CallbackQuery, state: FSMContext):
|
||||
tg_id = callback_query.from_user.id
|
||||
tg_id = callback_query.chat.id
|
||||
logger.info(f"User {tg_id} initiated Robokassa payment.")
|
||||
|
||||
builder = InlineKeyboardBuilder()
|
||||
@@ -117,13 +117,13 @@ async def process_amount_selection(callback_query: types.CallbackQuery, state: F
|
||||
return
|
||||
|
||||
await state.update_data(amount=amount)
|
||||
logger.info(f"User {callback_query.from_user.id} selected amount: {amount}.")
|
||||
logger.info(f"User {callback_query.chat.id} selected amount: {amount}.")
|
||||
inv_id = 0
|
||||
|
||||
tg_id = callback_query.from_user.id
|
||||
tg_id = callback_query.chat.id
|
||||
payment_url = generate_payment_link(amount, inv_id, "Пополнение баланса", tg_id)
|
||||
|
||||
logger.info(f"Payment URL for user {callback_query.from_user.id}: {payment_url}")
|
||||
logger.info(f"Payment URL for user {callback_query.chat.id}: {payment_url}")
|
||||
|
||||
confirm_keyboard = InlineKeyboardMarkup(
|
||||
inline_keyboard=[
|
||||
@@ -136,7 +136,7 @@ async def process_amount_selection(callback_query: types.CallbackQuery, state: F
|
||||
text=f"Вы выбрали пополнение на {amount} рублей. Для оплаты перейдите по ссылке ниже:",
|
||||
reply_markup=confirm_keyboard,
|
||||
)
|
||||
logger.info(f"Payment link sent to user {callback_query.from_user.id}.")
|
||||
logger.info(f"Payment link sent to user {callback_query.chat.id}.")
|
||||
|
||||
|
||||
async def robokassa_webhook(request):
|
||||
@@ -200,7 +200,7 @@ def check_payment_signature(params):
|
||||
|
||||
@router.callback_query(F.data == "enter_custom_amount_robokassa")
|
||||
async def process_custom_amount_selection(callback_query: types.CallbackQuery, state: FSMContext):
|
||||
tg_id = callback_query.from_user.id
|
||||
tg_id = callback_query.chat.id
|
||||
logger.info(f"User {tg_id} chose to enter a custom amount.")
|
||||
|
||||
await callback_query.message.answer(text="Пожалуйста, введите сумму пополнения в рублях (например, 150):")
|
||||
@@ -209,7 +209,7 @@ async def process_custom_amount_selection(callback_query: types.CallbackQuery, s
|
||||
|
||||
@router.message(ReplenishBalanceState.waiting_for_payment_confirmation_robokassa)
|
||||
async def handle_custom_amount_input(message: types.Message, state: FSMContext):
|
||||
tg_id = message.from_user.id
|
||||
tg_id = message.chat.id
|
||||
logger.info(f"User {tg_id} entered custom amount: {message.text}")
|
||||
inv_id = 0
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class ReplenishBalanceState(StatesGroup):
|
||||
|
||||
@router.callback_query(F.data == "pay_stars")
|
||||
async def process_callback_pay_stars(callback_query: types.CallbackQuery, state: FSMContext):
|
||||
tg_id = callback_query.from_user.id
|
||||
tg_id = callback_query.chat.id
|
||||
|
||||
builder = InlineKeyboardBuilder()
|
||||
builder.row(InlineKeyboardButton(text="🤖 Бот для покупки звезд", url="https://t.me/PremiumBot"))
|
||||
@@ -176,7 +176,7 @@ async def on_successful_payment(
|
||||
message: types.Message,
|
||||
):
|
||||
try:
|
||||
user_id = int(message.from_user.id)
|
||||
user_id = int(message.chat.id)
|
||||
amount = float(message.successful_payment.invoice_payload.split("_")[0])
|
||||
logger.debug(f"Payment succeeded for user_id: {user_id}, amount: {amount}")
|
||||
await add_payment(int(user_id), float(amount), "stars")
|
||||
|
||||
@@ -31,7 +31,7 @@ class ReplenishBalanceState(StatesGroup):
|
||||
|
||||
@router.callback_query(F.data == "pay_yookassa")
|
||||
async def process_callback_pay_yookassa(callback_query: types.CallbackQuery, state: FSMContext):
|
||||
tg_id = callback_query.from_user.id
|
||||
tg_id = callback_query.chat.id
|
||||
|
||||
builder = InlineKeyboardBuilder()
|
||||
|
||||
@@ -95,7 +95,7 @@ async def process_amount_selection(callback_query: types.CallbackQuery, state: F
|
||||
|
||||
# state_data = await state.get_data()
|
||||
customer_name = callback_query.from_user.full_name
|
||||
customer_id = callback_query.from_user.id
|
||||
customer_id = callback_query.chat.id
|
||||
|
||||
customer_email = f"{customer_id}@solo.net"
|
||||
|
||||
@@ -195,7 +195,7 @@ async def process_custom_amount_input(message: types.Message, state: FSMContext)
|
||||
"receipt": {
|
||||
"customer": {
|
||||
"full_name": message.from_user.full_name,
|
||||
"email": f"{message.from_user.id}@solo.net",
|
||||
"email": f"{message.chat.id}@solo.net",
|
||||
"phone": "79000000000",
|
||||
},
|
||||
"items": [
|
||||
@@ -210,7 +210,7 @@ async def process_custom_amount_input(message: types.Message, state: FSMContext)
|
||||
}
|
||||
],
|
||||
},
|
||||
"metadata": {"user_id": message.from_user.id},
|
||||
"metadata": {"user_id": message.chat.id},
|
||||
},
|
||||
uuid.uuid4(),
|
||||
)
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ router = Router()
|
||||
|
||||
@router.callback_query(F.data == "profile")
|
||||
async def process_callback_view_profile(callback_query: types.CallbackQuery, state: FSMContext, admin: bool):
|
||||
chat_id = callback_query.from_user.id
|
||||
chat_id = callback_query.chat.id
|
||||
username = callback_query.from_user.full_name
|
||||
image_path = os.path.join("img", "pic.jpg")
|
||||
key_count = await get_key_count(chat_id)
|
||||
@@ -84,7 +84,7 @@ async def view_tariffs_handler(callback_query: types.CallbackQuery):
|
||||
|
||||
@router.callback_query(F.data == "invite")
|
||||
async def invite_handler(callback_query: types.CallbackQuery):
|
||||
chat_id = callback_query.from_user.id
|
||||
chat_id = callback_query.chat.id
|
||||
referral_link = get_referral_link(chat_id)
|
||||
|
||||
referral_stats = await get_referral_stats(chat_id)
|
||||
|
||||
+5
-6
@@ -11,7 +11,6 @@ from config import CHANNEL_URL, CONNECT_ANDROID, CONNECT_IOS, DOWNLOAD_ANDROID,
|
||||
from database import add_connection, add_referral, check_connection_exists, get_trial, use_trial
|
||||
from handlers.keys.trial_key import create_trial_key
|
||||
from handlers.texts import INSTRUCTIONS_TRIAL, WELCOME_TEXT, get_about_vpn
|
||||
from logger import logger
|
||||
|
||||
router = Router()
|
||||
|
||||
@@ -26,13 +25,13 @@ async def start_command(message: Message, state: FSMContext, session: Any, admin
|
||||
if message.text:
|
||||
try:
|
||||
referrer_tg_id = int(message.text.split("referral_")[1])
|
||||
await add_referral(message.from_user.id, referrer_tg_id, session)
|
||||
await add_referral(message.chat.id, referrer_tg_id, session)
|
||||
except (ValueError, IndexError):
|
||||
pass
|
||||
connection_exists = await check_connection_exists(message.from_user.id)
|
||||
connection_exists = await check_connection_exists(message.chat.id)
|
||||
if not connection_exists:
|
||||
await add_connection(message.from_user.id, session)
|
||||
trial_status = await get_trial(message.from_user.id, session)
|
||||
await add_connection(message.chat.id, session)
|
||||
trial_status = await get_trial(message.chat.id, session)
|
||||
image_path = os.path.join("img", "pic.jpg")
|
||||
|
||||
builder = InlineKeyboardBuilder()
|
||||
@@ -65,7 +64,7 @@ async def start_command(message: Message, state: FSMContext, session: Any, admin
|
||||
|
||||
@router.callback_query(F.data == "connect_vpn")
|
||||
async def handle_connect_vpn(callback_query: CallbackQuery, session: Any):
|
||||
user_id = callback_query.from_user.id
|
||||
user_id = callback_query.chat.id
|
||||
|
||||
trial_key_info = await create_trial_key(user_id, session)
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class AdminMiddleware(BaseMiddleware):
|
||||
try:
|
||||
admin_ids: Union[int, list[int]] = ADMIN_ID
|
||||
if isinstance(admin_ids, list):
|
||||
return event.from_user.id in admin_ids
|
||||
return event.from_user.id == admin_ids
|
||||
return event.chat.id in admin_ids
|
||||
return event.chat.id == admin_ids
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user