somethjijngs
This commit is contained in:
@@ -3,14 +3,25 @@ from aiogram import Router, F
|
||||
from aiogram.types import CallbackQuery
|
||||
from aiogram.fsm.context import FSMContext
|
||||
|
||||
from keyboards.client import devices_selector, duration_selector
|
||||
from misc.utils import calculate_price, convert_int_to_duration
|
||||
from keyboards.client import (
|
||||
devices_selector,
|
||||
duration_selector,
|
||||
return_to_menu,
|
||||
payment_gateways,
|
||||
)
|
||||
from misc.utils import (
|
||||
calculate_price,
|
||||
convert_int_to_duration,
|
||||
format_support_subscription,
|
||||
)
|
||||
from schemas.subscriptions import SubscriptionPlan
|
||||
from states.buy import SubscriptionStorage
|
||||
from texts import (
|
||||
CALLBACK_FALLBACK,
|
||||
CHECKOUT_PAYMENT_CHOICE,
|
||||
CONTEXT_REINITIATED,
|
||||
NOTHING_PLACEHOLDER,
|
||||
STANDARD_FALLBACK,
|
||||
SUBSCRIPTION_DEVICE_SELECTOR,
|
||||
SUBSCRIPTION_DURATION_SELECTOR,
|
||||
)
|
||||
@@ -58,18 +69,13 @@ async def toggle_whitelists(cb: CallbackQuery, state: FSMContext):
|
||||
data = await state.get_data()
|
||||
await state.clear()
|
||||
|
||||
ctx: Optional[SubscriptionPlan] = data.get("ctx")
|
||||
if not ctx:
|
||||
await state.set_state(SubscriptionPlan())
|
||||
await state.set_data({"ctx": ctx})
|
||||
await cb.answer(CALLBACK_FALLBACK)
|
||||
return
|
||||
ctx: Optional[SubscriptionPlan] = data.get("ctx", SubscriptionPlan())
|
||||
ctx.whitelists = (
|
||||
not ctx.whitelists or ctx.devices >= settings.whitelist_device_threshold
|
||||
)
|
||||
|
||||
try:
|
||||
await cb.message.edit_reply_markup(
|
||||
await cb.message.edit_text(
|
||||
SUBSCRIPTION_DEVICE_SELECTOR.format(price=calculate_price(ctx)),
|
||||
reply_markup=devices_selector(
|
||||
current=ctx.devices, whitelists=ctx.whitelists
|
||||
@@ -91,8 +97,6 @@ async def select_duration_init(cb: CallbackQuery, state: FSMContext):
|
||||
|
||||
ctx: Optional[SubscriptionPlan] = data.get("ctx")
|
||||
if not ctx:
|
||||
await state.set_state(SubscriptionPlan())
|
||||
await state.set_data({"ctx": ctx})
|
||||
await cb.answer(CALLBACK_FALLBACK)
|
||||
return
|
||||
|
||||
@@ -121,8 +125,6 @@ async def select_duration(cb: CallbackQuery, state: FSMContext):
|
||||
|
||||
ctx: Optional[SubscriptionPlan] = data.get("ctx")
|
||||
if not ctx:
|
||||
await state.set_state()
|
||||
await state.set_data({"ctx": ctx})
|
||||
await cb.answer(CONTEXT_REINITIATED)
|
||||
ctx = SubscriptionPlan()
|
||||
|
||||
@@ -149,5 +151,15 @@ async def select_duration(cb: CallbackQuery, state: FSMContext):
|
||||
|
||||
@router.callback_query(SubscriptionStorage.duration, F.data == "confirm")
|
||||
async def proceed_to_checkout(cb: CallbackQuery, state: FSMContext):
|
||||
await cb.answer("yay!!!! fuck off.")
|
||||
...
|
||||
data = await state.get_data()
|
||||
await state.clear()
|
||||
|
||||
ctx: Optional[SubscriptionPlan] = data.get("ctx")
|
||||
if not ctx:
|
||||
await cb.message.edit_text(STANDARD_FALLBACK, reply_markup=return_to_menu)
|
||||
return
|
||||
|
||||
await cb.message.edit_text(
|
||||
CHECKOUT_PAYMENT_CHOICE.format(code=format_support_subscription(ctx)),
|
||||
reply_markup=payment_gateways,
|
||||
) # FIXME: temp solution that's incredibly stupid
|
||||
|
||||
@@ -51,11 +51,13 @@ async def received_message(
|
||||
F.message_thread_id.is_not(None),
|
||||
F.from_user.is_bot == False, # noqa: E712
|
||||
~Command("close"),
|
||||
F.text,
|
||||
)
|
||||
async def handle_admin_message(
|
||||
msg: Message, state: FSMContext, session: AsyncSession, deps: DependenciesDTO
|
||||
):
|
||||
await state.clear()
|
||||
print(str(msg))
|
||||
|
||||
await deps.user_service.support_answer(session, msg)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user