Initial local state
This commit is contained in:
@@ -0,0 +1,255 @@
|
||||
# - *- coding: utf- 8 - *-
|
||||
from aiogram.types import InlineKeyboardMarkup
|
||||
from aiogram.utils.keyboard import InlineKeyboardBuilder
|
||||
|
||||
from tgbot.database import Settingsx, Paymentsx
|
||||
from tgbot.utils.const_functions import ikb
|
||||
|
||||
|
||||
################################################################################
|
||||
#################################### ПРОЧЕЕ ####################################
|
||||
# Удаление сообщения
|
||||
def close_finl() -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("❌ Закрыть", data="close_this"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Рассылка
|
||||
def mail_confirm_finl() -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("✅ Отправить", data="mail_confirm:Yes"),
|
||||
ikb("❌ Отменить", data="mail_confirm:Not"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Поиск профиля пользователя
|
||||
def profile_edit_finl(user_id: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("💰 Изменить баланс", data=f"admin_user_balance_set:{user_id}"),
|
||||
ikb("💰 Выдать баланс", data=f"admin_user_balance_add:{user_id}"),
|
||||
).row(
|
||||
ikb("🎁 Покупки", data=f"admin_user_purchases:{user_id}"),
|
||||
ikb("💌 Отправить СМС", data=f"admin_user_message:{user_id}"),
|
||||
).row(
|
||||
ikb("🔄 Обновить", data=f"admin_user_refresh:{user_id}"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Переход к профилю пользователя
|
||||
def profile_edit_return_finl(user_id: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("❌ Отменить", data=f"admin_user_refresh:{user_id}"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
################################################################################
|
||||
############################## ПЛАТЕЖНЫЕ СИСТЕМЫ ###############################
|
||||
# Управление - CryptoBot
|
||||
async def payment_cryptobot_finl() -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_payments = await Paymentsx().get()
|
||||
|
||||
if get_payments.cryptobot_token == "None":
|
||||
assets_symbol = "➖"
|
||||
else:
|
||||
assets_symbol = "➕"
|
||||
|
||||
if get_payments.status_cryptobot == "True":
|
||||
status_kb = ikb(f"{assets_symbol} | Статус: Включено ✅", data="payment_cryptobot_status:False")
|
||||
else:
|
||||
status_kb = ikb(f"{assets_symbol} | Статус: Выключено ❌", data="payment_cryptobot_status:True")
|
||||
|
||||
keyboard.row(
|
||||
ikb("Информация ♻️", data="payment_cryptobot_check"),
|
||||
).row(
|
||||
ikb("Баланс 💰", data="payment_cryptobot_balance"),
|
||||
).row(
|
||||
ikb("Изменить 🖍", data="payment_cryptobot_edit"),
|
||||
).row(
|
||||
ikb("", data="..."),
|
||||
).row(
|
||||
status_kb,
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Управление - ЮMoney
|
||||
async def payment_yoomoney_finl() -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_payments = await Paymentsx().get()
|
||||
|
||||
if get_payments.yoomoney_token == "None":
|
||||
assets_symbol = "➖"
|
||||
else:
|
||||
assets_symbol = "➕"
|
||||
|
||||
if get_payments.status_yoomoney == "True":
|
||||
status_kb = ikb(f"{assets_symbol} | Статус: Включено ✅", data="payment_yoomoney_status:False")
|
||||
else:
|
||||
status_kb = ikb(f"{assets_symbol} | Статус: Выключено ❌", data="payment_yoomoney_status:True")
|
||||
|
||||
keyboard.row(
|
||||
ikb("Информация ♻️", data="payment_yoomoney_check"),
|
||||
).row(
|
||||
ikb("Баланс 💰", data="payment_yoomoney_balance"),
|
||||
).row(
|
||||
ikb("Изменить 🖍", data="payment_yoomoney_edit"),
|
||||
).row(
|
||||
ikb("", data="..."),
|
||||
).row(
|
||||
status_kb,
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Управление - Звёзды
|
||||
async def payment_stars_finl() -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_payments = await Paymentsx().get()
|
||||
|
||||
assets_symbol = "➕"
|
||||
|
||||
if get_payments.status_stars == "True":
|
||||
status_kb = ikb(f"{assets_symbol} | Статус: Включено ✅", data="payment_stars_status:False")
|
||||
else:
|
||||
status_kb = ikb(f"{assets_symbol} | Статус: Выключено ❌", data="payment_stars_status:True")
|
||||
|
||||
keyboard.row(
|
||||
ikb("Информация ♻️", data="payment_stars_check"),
|
||||
).row(
|
||||
ikb("Баланс 💰", data="payment_stars_balance"),
|
||||
).row(
|
||||
ikb("Изменить курс 🖍", data="payment_stars_edit"),
|
||||
).row(
|
||||
ikb("", data="..."),
|
||||
).row(
|
||||
status_kb,
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
################################################################################
|
||||
################################## НАСТРОЙКИ ###################################
|
||||
# Основные настройки
|
||||
async def settings_finl() -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_settings = await Settingsx().get()
|
||||
|
||||
# Текст для FAQ
|
||||
if get_settings.misc_faq == "None":
|
||||
faq_kb = ikb("Не установлено ❌", data="settings_edit_faq")
|
||||
else:
|
||||
faq_kb = ikb(f"{get_settings.misc_faq[:15]}... ✅", data="settings_edit_faq")
|
||||
|
||||
# Контакты поддержки
|
||||
if get_settings.misc_support == "None":
|
||||
support_kb = ikb("Не установлена ❌", data="settings_edit_support")
|
||||
else:
|
||||
support_kb = ikb(f"@{get_settings.misc_support} ✅", data="settings_edit_support")
|
||||
|
||||
# Вебхук дискорда
|
||||
if get_settings.misc_discord_webhook_url == "None":
|
||||
discord_webhook_kb = ikb("Отсутствует ❌", data="settings_edit_discord_webhook")
|
||||
else:
|
||||
discord_webhook_kb = ikb(f"{get_settings.misc_discord_webhook_name} ✅", data="settings_edit_discord_webhook")
|
||||
|
||||
# Текстовый хостинг по умолчанию
|
||||
hosting_text_default_kb = ikb(get_settings.misc_hosting_text.title(), data="settings_edit_hosting_text")
|
||||
|
||||
# Скрытие категорий без товаров
|
||||
if get_settings.misc_hide_category == "True":
|
||||
hide_category_kb = ikb("Скрыты", data="settings_edit_hide_category:False")
|
||||
else:
|
||||
hide_category_kb = ikb("Отображены", data="settings_edit_hide_category:True")
|
||||
|
||||
# Скрытие позиций без товаров
|
||||
if get_settings.misc_hide_position == "True":
|
||||
hide_position_kb = ikb("Скрыты", data="settings_edit_hide_position:False")
|
||||
else:
|
||||
hide_position_kb = ikb("Отображены", data="settings_edit_hide_position:True")
|
||||
|
||||
# Метод добавления товаров
|
||||
if get_settings.misc_method_prod == "skip":
|
||||
method_prod_kb = ikb("Через строку", data="settings_edit_method_prod:every")
|
||||
else:
|
||||
method_prod_kb = ikb("На каждой строке", data="settings_edit_method_prod:skip")
|
||||
|
||||
keyboard.row(
|
||||
ikb("❔ FAQ", data="..."), faq_kb,
|
||||
).row(
|
||||
ikb("☎️ Поддержка", data="..."), support_kb,
|
||||
).row(
|
||||
ikb("🧿 Дискорд Webhook", url="https://teletype.in/@djimbox/djimboshop-discord"), discord_webhook_kb,
|
||||
).row(
|
||||
ikb("🗯 Текстовый хостинг", data="..."), hosting_text_default_kb,
|
||||
).row(
|
||||
ikb("🎁 Категории без товаров", data="..."), hide_category_kb,
|
||||
).row(
|
||||
ikb("🎁 Позиции без товаров", data="..."), hide_position_kb,
|
||||
).row(
|
||||
ikb("🎁 Метод добавления", data="..."), method_prod_kb,
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Выключатели
|
||||
async def settings_status_finl() -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_settings = await Settingsx().get()
|
||||
|
||||
status_work_kb = ikb("Включены ✅", data="settings_status_work:False")
|
||||
status_buy_kb = ikb("Включены ✅", data="settings_status_buy:False")
|
||||
status_refill_kb = ikb("Включены ✅", data="settings_status_refill:False")
|
||||
notification_buy_kb = ikb("Включены 🔔", data="settings_notification_buy:False")
|
||||
notification_refill_kb = ikb("Включены 🔔", data="settings_notification_refill:False")
|
||||
|
||||
if get_settings.status_buy == "False":
|
||||
status_buy_kb = ikb("Выключены ❌", data="settings_status_buy:True")
|
||||
if get_settings.status_work == "False":
|
||||
status_work_kb = ikb("Выключены ❌", data="settings_status_work:True")
|
||||
if get_settings.status_refill == "False":
|
||||
status_refill_kb = ikb("Выключены ❌", data="settings_status_refill:True")
|
||||
if get_settings.notification_buy == "False":
|
||||
notification_buy_kb = ikb("Выключены 🔕", data="settings_notification_buy:True")
|
||||
if get_settings.notification_refill == "False":
|
||||
notification_refill_kb = ikb("Выключены 🔕", data="settings_notification_refill:True")
|
||||
|
||||
keyboard.row(
|
||||
ikb("⛔ Тех. работы", data="..."), status_work_kb,
|
||||
).row(
|
||||
ikb("💰 Пополнения", data="..."), status_refill_kb,
|
||||
).row(
|
||||
ikb("🎁 Покупки", data="..."), status_buy_kb,
|
||||
).row(
|
||||
ikb("📢 Увед. о покупках", data="..."), notification_buy_kb,
|
||||
).row(
|
||||
ikb("📢 Увед. о пополнениях", data="..."), notification_refill_kb,
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
@@ -0,0 +1,188 @@
|
||||
# - *- coding: utf- 8 - *-
|
||||
from aiogram.types import InlineKeyboardMarkup
|
||||
from aiogram.utils.keyboard import InlineKeyboardBuilder
|
||||
|
||||
from tgbot.database import Categoryx, Positionx, Itemx
|
||||
from tgbot.keyboards.inline_helper import build_pagination_finl
|
||||
from tgbot.utils.const_functions import ikb
|
||||
|
||||
|
||||
# fp - flip page
|
||||
|
||||
################################################################################
|
||||
############################## ИЗМЕНЕНИЕ КАТЕГОРИИ #############################
|
||||
# Cтраницы выбора категории для изменения
|
||||
async def category_edit_swipe_fp(remover: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_categories = await Categoryx().get_all()
|
||||
|
||||
for count, select in enumerate(range(remover, len(get_categories))):
|
||||
if count < 10:
|
||||
category = get_categories[select]
|
||||
|
||||
keyboard.row(
|
||||
ikb(
|
||||
category.category_name,
|
||||
data=f"category_edit_open:{category.category_id}:{remover}",
|
||||
)
|
||||
)
|
||||
|
||||
buildp_kb = build_pagination_finl(get_categories, f"category_edit_swipe", remover)
|
||||
keyboard.row(*buildp_kb)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
################################################################################
|
||||
################################ СОЗДАНИЕ ПОЗИЦИИ ##############################
|
||||
# Страницы выбора категории для позиции
|
||||
async def position_add_swipe_fp(remover: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_categories = await Categoryx().get_all()
|
||||
|
||||
for count, select in enumerate(range(remover, len(get_categories))):
|
||||
if count < 10:
|
||||
category = get_categories[select]
|
||||
|
||||
keyboard.row(
|
||||
ikb(
|
||||
category.category_name,
|
||||
data=f"position_add_open:{category.category_id}",
|
||||
)
|
||||
)
|
||||
|
||||
buildp_kb = build_pagination_finl(get_categories, f"position_add_swipe", remover)
|
||||
keyboard.row(*buildp_kb)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
################################################################################
|
||||
############################### ИЗМЕНЕНИЕ ПОЗИЦИИ ##############################
|
||||
# Cтраницы категорий для изменения позиции
|
||||
async def position_edit_category_swipe_fp(remover: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_categories = await Categoryx().get_all()
|
||||
|
||||
for count, select in enumerate(range(remover, len(get_categories))):
|
||||
if count < 10:
|
||||
category = get_categories[select]
|
||||
|
||||
keyboard.row(
|
||||
ikb(
|
||||
category.category_name,
|
||||
data=f"position_edit_category_open:{category.category_id}"
|
||||
)
|
||||
)
|
||||
|
||||
buildp_kb = build_pagination_finl(get_categories, f"position_edit_category_swipe", remover)
|
||||
keyboard.row(*buildp_kb)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Cтраницы выбора позиции для изменения
|
||||
async def position_edit_swipe_fp(remover: int, category_id: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_positions = await Positionx().gets(category_id=category_id)
|
||||
|
||||
for count, select in enumerate(range(remover, len(get_positions))):
|
||||
if count < 10:
|
||||
position = get_positions[select]
|
||||
get_items = await Itemx().gets(position_id=position.position_id)
|
||||
|
||||
keyboard.row(
|
||||
ikb(
|
||||
f"{position.position_name} | {position.position_price}₽ | {len(get_items)} шт",
|
||||
data=f"position_edit_open:{position.position_id}:{remover}",
|
||||
)
|
||||
)
|
||||
|
||||
buildp_kb = build_pagination_finl(get_positions, f"position_edit_swipe:{category_id}", remover)
|
||||
keyboard.row(*buildp_kb)
|
||||
|
||||
keyboard.row(ikb("🔙 Вернуться", data="position_edit_category_swipe:0"))
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
################################################################################
|
||||
############################### ДОБАВЛЕНИЕ ТОВАРОВ #############################
|
||||
# Страницы категорий для добавления товаров
|
||||
async def item_add_category_swipe_fp(remover: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_categories = await Categoryx().get_all()
|
||||
|
||||
for count, select in enumerate(range(remover, len(get_categories))):
|
||||
if count < 10:
|
||||
category = get_categories[select]
|
||||
|
||||
keyboard.row(
|
||||
ikb(
|
||||
category.category_name,
|
||||
data=f"item_add_category_open:{category.category_id}:{remover}",
|
||||
)
|
||||
)
|
||||
|
||||
buildp_kb = build_pagination_finl(get_categories, f"item_add_category_swipe", remover)
|
||||
keyboard.row(*buildp_kb)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Страницы позиций для добавления товаров
|
||||
async def item_add_position_swipe_fp(remover: int, category_id: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_positions = await Positionx().gets(category_id=category_id)
|
||||
|
||||
for count, select in enumerate(range(remover, len(get_positions))):
|
||||
if count < 10:
|
||||
position = get_positions[select]
|
||||
get_items = await Itemx().gets(position_id=position.position_id)
|
||||
|
||||
keyboard.row(
|
||||
ikb(
|
||||
f"{position.position_name} | {position.position_price}₽ | {len(get_items)} шт",
|
||||
data=f"item_add_position_open:{position.position_id}",
|
||||
)
|
||||
)
|
||||
|
||||
buildp_kb = build_pagination_finl(get_positions, f"item_add_position_swipe:{category_id}", remover)
|
||||
keyboard.row(*buildp_kb)
|
||||
|
||||
keyboard.row(ikb("🔙 Вернуться", data="item_add_category_swipe:0"))
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
################################################################################
|
||||
################################ УДАЛЕНИЕ ТОВАРОВ ##############################
|
||||
# Страницы товаров для удаления
|
||||
async def item_delete_swipe_fp(remover: int, position_id: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_items = await Itemx().gets(position_id=position_id)
|
||||
|
||||
for count, select in enumerate(range(remover, len(get_items))):
|
||||
if count < 10:
|
||||
item = get_items[select]
|
||||
|
||||
keyboard.row(
|
||||
ikb(
|
||||
item.item_data,
|
||||
data=f"item_delete_open:{item.item_id}",
|
||||
)
|
||||
)
|
||||
|
||||
buildp_kb = build_pagination_finl(get_items, f"item_delete_swipe:{position_id}", remover)
|
||||
keyboard.row(*buildp_kb)
|
||||
|
||||
keyboard.row(ikb("🔙 Вернуться", data=f"position_edit_open:{position_id}:0"))
|
||||
|
||||
return keyboard.as_markup()
|
||||
@@ -0,0 +1,198 @@
|
||||
# - *- coding: utf- 8 - *-
|
||||
from aiogram import Bot
|
||||
from aiogram.types import InlineKeyboardMarkup
|
||||
from aiogram.utils.keyboard import InlineKeyboardBuilder
|
||||
|
||||
from tgbot.database import Positionx
|
||||
from tgbot.utils.const_functions import ikb
|
||||
|
||||
|
||||
################################################################################
|
||||
################################### КАТЕГОРИИ ##################################
|
||||
# Изменение категории
|
||||
async def category_edit_open_finl(bot: Bot, category_id: int, remover: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_bot = await bot.get_me()
|
||||
|
||||
keyboard.row(
|
||||
ikb("▪️ Изм. Название", data=f"category_edit_name:{category_id}:{remover}"),
|
||||
ikb("▪️ Добавить позицию", data=f"position_add_open:{category_id}"),
|
||||
).row(
|
||||
ikb("▪️ Скопировать ссылку", copy=f"t.me/{get_bot.username}?start=c_{category_id}"),
|
||||
ikb("▪️ Удалить", data=f"category_edit_delete:{category_id}:{remover}"),
|
||||
).row(
|
||||
ikb("🔙 Вернуться", data=f"category_edit_swipe:{remover}"),
|
||||
ikb("▪️ Обновить", data=f"category_edit_open:{category_id}:{remover}"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Подтверждение удаления категории
|
||||
def category_edit_delete_finl(category_id: int, remover: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("✅ Да, удалить", data=f"category_edit_delete_confirm:{category_id}:{remover}"),
|
||||
ikb("❌ Нет, отменить", data=f"category_edit_open:{category_id}:{remover}")
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Отмена изменения категории и возвращение
|
||||
def category_edit_cancel_finl(category_id: int, remover: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("❌ Отменить", data=f"category_edit_open:{category_id}:{remover}"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
################################################################################
|
||||
#################################### ПОЗИЦИИ ###################################
|
||||
# Кнопки при открытии позиции для изменения
|
||||
async def position_edit_open_finl(bot: Bot, position_id: int, remover: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_position = await Positionx().get_required(position_id=position_id)
|
||||
get_bot = await bot.get_me()
|
||||
|
||||
keyboard.row(
|
||||
ikb("▪️ Изм. Название", data=f"position_edit_name:{position_id}:{remover}"),
|
||||
ikb("▪️ Изм. Цену", data=f"position_edit_price:{position_id}:{remover}"),
|
||||
).row(
|
||||
ikb("▪️ Изм. Описание", data=f"position_edit_desc:{position_id}:{remover}"),
|
||||
ikb("▪️ Изм. Фото", data=f"position_edit_photo:{position_id}:{remover}"),
|
||||
).row(
|
||||
ikb("▪️ Добавить Товары", data=f"item_add_position_open:{position_id}"),
|
||||
ikb("▪️ Выгрузить Товары", data=f"position_edit_items:{position_id}:{remover}"),
|
||||
).row(
|
||||
ikb("▪️ Очистить Товары", data=f"position_edit_clear:{position_id}:{remover}"),
|
||||
ikb("▪️ Удалить Товар", data=f"item_delete_swipe:{position_id}:0"),
|
||||
).row(
|
||||
ikb("▪️ Скопировать ссылку", copy=f"t.me/{get_bot.username}?start=p_{position_id}"),
|
||||
ikb("▪️ Удалить Позицию", data=f"position_edit_delete:{position_id}:{remover}"),
|
||||
).row(
|
||||
ikb("🔙 Вернуться", data=f"position_edit_swipe:{get_position.category_id}:{remover}"),
|
||||
ikb("▪️ Обновить", data=f"position_edit_open:{position_id}:{remover}"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Подтверждение удаления позиции
|
||||
def position_edit_delete_finl(position_id: int, remover: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("✅ Да, удалить", data=f"position_edit_delete_confirm:{position_id}:{remover}"),
|
||||
ikb("❌ Нет, отменить", data=f"position_edit_open:{position_id}:{remover}")
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Подтверждение очистки позиции
|
||||
def position_edit_clear_finl(position_id: int, remover: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("✅ Да, очистить", data=f"position_edit_clear_confirm:{position_id}:{remover}"),
|
||||
ikb("❌ Нет, отменить", data=f"position_edit_open:{position_id}:{remover}")
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Отмена изменения позиции и возвращение
|
||||
def position_edit_cancel_finl(position_id: int, remover: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("❌ Отменить", data=f"position_edit_open:{position_id}:{remover}"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
################################################################################
|
||||
##################################### ТОВАРЫ ###################################
|
||||
# Отмена изменения позиции и возвращение
|
||||
def item_add_finish_finl(position_id: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("✅ Завершить загрузку", data=f"item_add_position_finish:{position_id}"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Удаление товара
|
||||
def item_delete_finl(item_id: int, position_id: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("▪️ Удалить товар", data=f"item_delete_confirm:{item_id}"),
|
||||
).row(
|
||||
ikb("🔙 Вернуться", data=f"item_delete_swipe:{position_id}:0"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
################################################################################
|
||||
############################### УДАЛЕНИЕ РАЗДЕЛОВ ##############################
|
||||
# Выбор раздела для удаления
|
||||
def products_removes_finl() -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("🗃 Удалить все категории", data=f"prod_removes_categories"),
|
||||
).row(
|
||||
ikb("📁 Удалить все позиции", data=f"prod_removes_positions"),
|
||||
).row(
|
||||
ikb("🎁 Удалить все товары", data=f"prod_removes_items"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Удаление всех категорий
|
||||
def products_removes_categories_finl() -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("✅ Да, удалить все", data="prod_removes_categories_confirm"),
|
||||
ikb("❌ Нет, отменить", data="prod_removes_return")
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Удаление всех позиций
|
||||
def products_removes_positions_finl() -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("✅ Да, удалить все", data="prod_removes_positions_confirm"),
|
||||
ikb("❌ Нет, отменить", data="prod_removes_return")
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Удаление всех товаров
|
||||
def products_removes_items_finl() -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("✅ Да, удалить все", data="prod_removes_items_confirm"),
|
||||
ikb("❌ Нет, отменить", data="prod_removes_return")
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
@@ -0,0 +1,82 @@
|
||||
# - *- coding: utf- 8 - *-
|
||||
import math
|
||||
from typing import List
|
||||
|
||||
from aiogram.types import InlineKeyboardButton
|
||||
|
||||
from tgbot.utils.const_functions import ikb
|
||||
|
||||
|
||||
# Генерация пагинации страниц
|
||||
def build_pagination_finl(
|
||||
get_list: List[object],
|
||||
button_data: str,
|
||||
remover: int,
|
||||
) -> List[InlineKeyboardButton]:
|
||||
save_kb = []
|
||||
|
||||
if len(get_list) % 10 == 0:
|
||||
remover_page = len(get_list)
|
||||
else:
|
||||
remover_page = len(get_list) - len(get_list) % 10
|
||||
|
||||
if len(get_list) % 10 == 0 and remover_page == len(get_list):
|
||||
remover_page -= 10
|
||||
|
||||
if remover >= len(get_list): remover -= 10
|
||||
if remover < 0: remover = 0
|
||||
|
||||
if len(get_list) <= 10:
|
||||
...
|
||||
elif len(get_list) > 10 and remover < 10:
|
||||
if len(get_list) > 20:
|
||||
save_kb += [
|
||||
ikb(f"1/{math.ceil(len(get_list) / 10)}", data="..."),
|
||||
ikb("➡️", data=f"{button_data}:{remover + 10}"),
|
||||
ikb("⏩", data=f"{button_data}:{remover_page}"),
|
||||
]
|
||||
else:
|
||||
save_kb += [
|
||||
ikb(f"1/{math.ceil(len(get_list) / 10)}", data="..."),
|
||||
ikb("➡️", data=f"{button_data}:{remover + 10}"),
|
||||
]
|
||||
elif remover + 10 >= len(get_list):
|
||||
if len(get_list) > 20:
|
||||
save_kb += [
|
||||
ikb("⏪", data=f"{button_data}:0"),
|
||||
ikb("⬅️", data=f"{button_data}:{remover - 10}"),
|
||||
ikb(f"{str(remover + 10)[:-1]}/{math.ceil(len(get_list) / 10)}", data="..."),
|
||||
]
|
||||
else:
|
||||
save_kb += [
|
||||
ikb("⬅️", data=f"{button_data}:{remover - 10}"),
|
||||
ikb(f"{str(remover + 10)[:-1]}/{math.ceil(len(get_list) / 10)}", data="..."),
|
||||
]
|
||||
else:
|
||||
if len(get_list) > 20:
|
||||
if remover >= 20:
|
||||
save_kb += [
|
||||
ikb("⏪", data=f"{button_data}:0"),
|
||||
ikb("⬅️", data=f"{button_data}:{remover - 10}"),
|
||||
ikb(f"{str(remover + 10)[:-1]}/{math.ceil(len(get_list) / 10)}", data="..."),
|
||||
ikb("➡️", data=f"{button_data}:{remover + 10}"),
|
||||
]
|
||||
else:
|
||||
save_kb += [
|
||||
ikb("⬅️", data=f"{button_data}:{remover - 10}"),
|
||||
ikb(f"{str(remover + 10)[:-1]}/{math.ceil(len(get_list) / 10)}", data="..."),
|
||||
ikb("➡️", data=f"{button_data}:{remover + 10}"),
|
||||
]
|
||||
|
||||
if remover_page - 10 > remover:
|
||||
save_kb += [
|
||||
ikb("⏩", data=f"{button_data}:{remover_page}"),
|
||||
]
|
||||
else:
|
||||
save_kb += [
|
||||
ikb("⬅️", data=f"{button_data}:{remover - 10}"),
|
||||
ikb(f"{str(remover + 10)[:-1]}/{math.ceil(len(get_list) / 10)}", data="..."),
|
||||
ikb("➡️", data=f"{button_data}:{remover + 10}"),
|
||||
]
|
||||
|
||||
return save_kb
|
||||
@@ -0,0 +1,84 @@
|
||||
# - *- coding: utf- 8 - *-
|
||||
from typing import Union
|
||||
|
||||
from aiogram.types import InlineKeyboardMarkup
|
||||
from aiogram.utils.keyboard import InlineKeyboardBuilder
|
||||
|
||||
from tgbot.database import Paymentsx
|
||||
from tgbot.utils.const_functions import ikb
|
||||
|
||||
|
||||
################################################################################
|
||||
#################################### ПРОЧЕЕ ####################################
|
||||
# Открытие своего профиля
|
||||
def user_profile_finl() -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("💰 Пополнить", data="user_refill"),
|
||||
ikb("🎁 Мои покупки", data="user_purchases"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Ссылка на поддержку
|
||||
def user_support_finl(support_login: str) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("💌 Написать в поддержку", url=f"https://t.me/{support_login}"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
################################################################################
|
||||
################################### ПЛАТЕЖИ ####################################
|
||||
# Выбор способа пополнения
|
||||
async def refill_method_finl() -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_payments = await Paymentsx().get()
|
||||
|
||||
if get_payments.status_cryptobot == "True":
|
||||
keyboard.row(ikb("🔷 CryptoBot", data="user_refill_method:Cryptobot"))
|
||||
if get_payments.status_yoomoney == "True":
|
||||
keyboard.row(ikb("🔮 ЮMoney", data="user_refill_method:Yoomoney"))
|
||||
if get_payments.status_stars == "True":
|
||||
keyboard.row(ikb("⭐️ Звёзды", data="user_refill_method:Stars"))
|
||||
|
||||
keyboard.row(ikb("🔙 Вернуться", data="user_profile"))
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Проверка платежа
|
||||
def refill_bill_finl(pay_link: str, pay_receipt: Union[str, int], pay_method: str) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("🌀 Перейти к оплате", url=pay_link),
|
||||
).row(
|
||||
ikb("🔄 Проверить оплату", data=f"Pay:{pay_method}:{pay_receipt}"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Выбор способа пополнения при нехватке баланса во время покупки товара
|
||||
async def refill_method_buy_finl() -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_payments = await Paymentsx().get()
|
||||
|
||||
if get_payments.status_cryptobot == "True":
|
||||
keyboard.row(ikb("🔷 CryptoBot", data="user_refill_method:Cryptobot"))
|
||||
if get_payments.status_yoomoney == "True":
|
||||
keyboard.row(ikb("🔮 ЮMoney", data="user_refill_method:Yoomoney"))
|
||||
if get_payments.status_stars == "True":
|
||||
keyboard.row(ikb("⭐️ Звёзды", data="user_refill_method:Stars"))
|
||||
|
||||
keyboard.row(ikb("❌ Закрыть", data="close_this"))
|
||||
|
||||
return keyboard.as_markup()
|
||||
@@ -0,0 +1,98 @@
|
||||
# - *- coding: utf- 8 - *-
|
||||
from aiogram.types import InlineKeyboardMarkup
|
||||
from aiogram.utils.keyboard import InlineKeyboardBuilder
|
||||
|
||||
from tgbot.database import Itemx
|
||||
from tgbot.keyboards.inline_helper import build_pagination_finl
|
||||
from tgbot.utils.const_functions import ikb
|
||||
from tgbot.utils.products_functions import get_positions_items, get_categories_items
|
||||
|
||||
|
||||
# fp - flip page
|
||||
|
||||
|
||||
################################################################################
|
||||
################################ ПОКУПКИ ТОВАРОВ ###############################
|
||||
# Страницы категорий при покупке товара
|
||||
async def prod_item_category_swipe_fp(remover: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_categories = await get_categories_items()
|
||||
|
||||
for count, select in enumerate(range(remover, len(get_categories))):
|
||||
if count < 10:
|
||||
category = get_categories[select]
|
||||
|
||||
keyboard.row(
|
||||
ikb(
|
||||
category.category_name,
|
||||
data=f"buy_category_open:{category.category_id}:0",
|
||||
)
|
||||
)
|
||||
|
||||
buildp_kb = build_pagination_finl(get_categories, f"buy_category_swipe", remover)
|
||||
keyboard.row(*buildp_kb)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Страницы позиций для покупки товаров
|
||||
async def prod_item_position_swipe_fp(remover: int, category_id: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
get_positions = await get_positions_items(category_id)
|
||||
|
||||
for count, select in enumerate(range(remover, len(get_positions))):
|
||||
if count < 10:
|
||||
position = get_positions[select]
|
||||
get_items = await Itemx().gets(position_id=get_positions[select].position_id)
|
||||
|
||||
keyboard.row(
|
||||
ikb(
|
||||
f"{position.position_name} | {position.position_price}₽ | {len(get_items)} шт",
|
||||
data=f"buy_position_open:{position.position_id}:{remover}",
|
||||
)
|
||||
)
|
||||
|
||||
buildp_kb = build_pagination_finl(get_positions, f"buy_position_swipe:{category_id}", remover)
|
||||
keyboard.row(*buildp_kb)
|
||||
|
||||
keyboard.row(ikb("🔙 Вернуться", data=f"buy_category_swipe:0"))
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
################################################################################
|
||||
################################ НАЛИЧИЕ ТОВАРОВ ###############################
|
||||
# Страницы наличия товаров
|
||||
def prod_available_swipe_fp(remover_now: int, remover_max: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
if remover_max > 1:
|
||||
if remover_now > 1 and remover_max >= 3:
|
||||
keyboard.add(
|
||||
ikb("⏪", data=f"user_available_swipe:{0}"),
|
||||
)
|
||||
|
||||
if remover_now >= 1:
|
||||
keyboard.add(
|
||||
ikb("⬅️", data=f"user_available_swipe:{remover_now - 1}"),
|
||||
)
|
||||
|
||||
keyboard.add(
|
||||
ikb(f"{remover_now + 1}/{remover_max}", data="...")
|
||||
)
|
||||
|
||||
if remover_now + 1 < remover_max:
|
||||
keyboard.add(
|
||||
ikb("➡️", data=f"user_available_swipe:{remover_now + 1}"),
|
||||
)
|
||||
|
||||
if remover_now + 1 < remover_max - 1 and remover_max >= 3:
|
||||
keyboard.add(
|
||||
ikb("⏩", data=f"user_available_swipe:{remover_max - 1}"),
|
||||
)
|
||||
|
||||
keyboard.adjust(5)
|
||||
|
||||
return keyboard.as_markup()
|
||||
@@ -0,0 +1,41 @@
|
||||
# - *- coding: utf- 8 - *-
|
||||
from aiogram.types import InlineKeyboardMarkup
|
||||
from aiogram.utils.keyboard import InlineKeyboardBuilder
|
||||
|
||||
from tgbot.utils.const_functions import ikb
|
||||
|
||||
|
||||
# Открытие позиции для просмотра
|
||||
def products_open_finl(position_id: int, category_id: int, remover: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("💰 Купить товар", data=f"buy_item_open:{position_id}:{remover}"),
|
||||
).row(
|
||||
ikb("🔙 Вернуться", data=f"buy_category_open:{category_id}:{remover}"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Подтверждение покупки товара
|
||||
def products_buy_confirm_finl(position_id: int, category_id: int, get_count: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("✅ Подтвердить", data=f"buy_item_confirm:{position_id}:{get_count}"),
|
||||
ikb("❌ Отменить", data=f"buy_position_open:{position_id}:0"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
|
||||
|
||||
# Возврат к позиции при отмене ввода
|
||||
def products_return_finl(position_id: int, category_id: int) -> InlineKeyboardMarkup:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
ikb("🔙 Вернуться", data=f"buy_position_open:{position_id}:0"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup()
|
||||
@@ -0,0 +1,80 @@
|
||||
# - *- coding: utf- 8 - *-
|
||||
from aiogram.types import ReplyKeyboardMarkup
|
||||
from aiogram.utils.keyboard import ReplyKeyboardBuilder
|
||||
|
||||
from tgbot.data.config import get_admins
|
||||
from tgbot.utils.const_functions import rkb
|
||||
|
||||
|
||||
# Главное меню
|
||||
def menu_frep(user_id: int) -> ReplyKeyboardMarkup:
|
||||
keyboard = ReplyKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
rkb("🎁 Купить"), rkb("👤 Профиль"), rkb("🧮 Наличие товаров"),
|
||||
).row(
|
||||
rkb("☎️ Поддержка"), rkb("❔ FAQ"),
|
||||
)
|
||||
|
||||
if user_id in get_admins():
|
||||
keyboard.row(
|
||||
rkb("🎁 Управление товарами"), rkb("📊 Статистика"),
|
||||
).row(
|
||||
rkb("⚙️ Настройки"), rkb("🔆 Общие функции"), rkb("🔑 Платежные системы"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup(resize_keyboard=True)
|
||||
|
||||
|
||||
# Платежные системы
|
||||
def payments_frep() -> ReplyKeyboardMarkup:
|
||||
keyboard = ReplyKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
rkb("🔷 CryptoBot"), rkb("🔮 ЮMoney"), rkb("⭐️ Звёзды"),
|
||||
).row(
|
||||
rkb("🔙 Главное меню"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup(resize_keyboard=True)
|
||||
|
||||
|
||||
# Общие функции
|
||||
def functions_frep() -> ReplyKeyboardMarkup:
|
||||
keyboard = ReplyKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
rkb("🔍 Поиск"), rkb("📢 Рассылка"),
|
||||
).row(
|
||||
rkb("🔙 Главное меню"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup(resize_keyboard=True)
|
||||
|
||||
|
||||
# Настройки бота
|
||||
def settings_frep() -> ReplyKeyboardMarkup:
|
||||
keyboard = ReplyKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
rkb("🖍 Изменить данные"), rkb("🕹 Выключатели"),
|
||||
).row(
|
||||
rkb("🔙 Главное меню"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup(resize_keyboard=True)
|
||||
|
||||
|
||||
# Управление товарами
|
||||
def items_frep() -> ReplyKeyboardMarkup:
|
||||
keyboard = ReplyKeyboardBuilder()
|
||||
|
||||
keyboard.row(
|
||||
rkb("📁 Создать позицию ➕"), rkb("🗃 Создать категорию ➕"),
|
||||
).row(
|
||||
rkb("📁 Изменить позицию 🖍"), rkb("🗃 Изменить категорию 🖍"),
|
||||
).row(
|
||||
rkb("🔙 Главное меню"), rkb("🎁 Добавить товары ➕"), rkb("❌ Удаление"),
|
||||
)
|
||||
|
||||
return keyboard.as_markup(resize_keyboard=True)
|
||||
Reference in New Issue
Block a user