refactor: remove Alembic migrations and Discord integration

This commit is contained in:
2026-07-15 15:55:25 +05:00
parent e8cff0f7ed
commit ec5ae395f3
24 changed files with 559 additions and 1718 deletions
+100 -30
View File
@@ -21,7 +21,11 @@ from tgbot.database import (
ModelUser,
)
from tgbot.keyboards.inline_admin import profile_edit_finl
from tgbot.keyboards.inline_admin_products import position_edit_open_finl, category_edit_open_finl, item_delete_finl
from tgbot.keyboards.inline_admin_products import (
position_edit_open_finl,
category_edit_open_finl,
item_delete_finl,
)
from tgbot.keyboards.inline_user import user_profile_finl
from tgbot.keyboards.inline_user_products import products_open_finl
from tgbot.services.api_hosting_text import HostingAPI
@@ -68,7 +72,7 @@ async def position_open_user(bot: Bot, user_id: int, position_id: int, remover:
await bot.send_message(
chat_id=user_id,
text=ded(f"""
<b>🎁 Покупка товара</b>{hide_link(get_position.position_photo)}
<b>🎁 Покупка товара</b>
➖➖➖➖➖➖➖➖➖➖
▪️ Название: <code>{get_position.position_name}</code>
▪️ Категория: <code>{get_category.category_name}</code>
@@ -78,7 +82,6 @@ async def position_open_user(bot: Bot, user_id: int, position_id: int, remover:
"""),
link_preview_options=LinkPreviewOptions(show_above_text=True),
reply_markup=products_open_finl(position_id, get_position.category_id, remover),
)
@@ -114,7 +117,7 @@ async def open_profile_admin(bot: Bot, user_id: int, get_user: ModelUser):
async def refill_open_admin(bot: Bot, user_id: int, get_refill: ModelRefill):
get_user = await Userx().get_required(user_id=get_refill.user_id)
if get_refill.refill_method in ['Form', 'Nickname', 'Number', 'QIWI']:
if get_refill.refill_method in ["Form", "Nickname", "Number", "QIWI"]:
pay_method = "QIWI 🥝"
elif get_refill.refill_method == "Yoomoney":
pay_method = "ЮMoney 🔮"
@@ -138,7 +141,9 @@ async def refill_open_admin(bot: Bot, user_id: int, get_refill: ModelRefill):
# Открытие покупки админом
async def purchase_open_admin(bot: Bot, arSession: ARS, user_id: int, get_purchase: ModelPurchases):
async def purchase_open_admin(
bot: Bot, arSession: ARS, user_id: int, get_purchase: ModelPurchases
):
get_user = await Userx().get_required(user_id=get_purchase.user_id)
link_items = await (
@@ -172,8 +177,18 @@ async def purchase_open_admin(bot: Bot, arSession: ARS, user_id: int, get_purcha
# Открытие категории админом
async def category_open_admin(bot: Bot, user_id: int, category_id: int, remover: int):
profit_amount_all, profit_amount_day, profit_amount_week, profit_amount_month = 0, 0, 0, 0
profit_count_all, profit_count_day, profit_count_week, profit_count_month = 0, 0, 0, 0
profit_amount_all, profit_amount_day, profit_amount_week, profit_amount_month = (
0,
0,
0,
0,
)
profit_count_all, profit_count_day, profit_count_week, profit_count_month = (
0,
0,
0,
0,
)
get_items = await Itemx().gets(category_id=category_id)
get_category = await Categoryx().get_required(category_id=category_id)
@@ -217,8 +232,18 @@ async def category_open_admin(bot: Bot, user_id: int, category_id: int, remover:
# Открытие позиции админом
async def position_open_admin(bot: Bot, position_id: int, user_id: int):
profit_amount_all, profit_amount_day, profit_amount_week, profit_amount_month = 0, 0, 0, 0
profit_count_all, profit_count_day, profit_count_week, profit_count_month = 0, 0, 0, 0
profit_amount_all, profit_amount_day, profit_amount_week, profit_amount_month = (
0,
0,
0,
0,
)
profit_count_all, profit_count_day, profit_count_week, profit_count_month = (
0,
0,
0,
0,
)
get_items = await Itemx().gets(position_id=position_id)
get_position = await Positionx().get_required(position_id=position_id)
@@ -227,12 +252,6 @@ async def position_open_admin(bot: Bot, position_id: int, user_id: int):
get_settings = await Settingsx().get()
get_purchases = await Purchasesx().gets(purchase_position_id=position_id)
# Наличие фото
if get_position.position_photo != "None":
position_photo_text = "<code>Присутствует ✅</code>"
else:
position_photo_text = "<code>Отсутствует ❌</code>"
# Наличие описания
if get_position.position_desc != "None":
position_desc = f"{get_position.position_desc}"
@@ -257,14 +276,13 @@ async def position_open_admin(bot: Bot, position_id: int, user_id: int):
await bot.send_message(
chat_id=user_id,
text=ded(f"""
<b>📁 Редактирование позиции</b>{hide_link(get_position.position_photo)}
<b>📁 Редактирование позиции</b>
➖➖➖➖➖➖➖➖➖➖
▪️ Категория: <code>{get_category.category_name}</code>
▪️ Позиция: <code>{get_position.position_name}</code>
▪️ Стоимость: <code>{get_position.position_price}₽</code>
▪️ Количество: <code>{len(get_items)}шт</code>
▪️ Дата создания: <code>{convert_date(get_category.category_unix)}</code>
▪️ Изображение: {position_photo_text}
▪️ Описание: {position_desc}
💸 Продаж за День: <code>{profit_count_day}шт</code> - <code>{round(profit_amount_day, 2)}₽</code>
@@ -274,7 +292,6 @@ async def position_open_admin(bot: Bot, position_id: int, user_id: int):
"""),
link_preview_options=LinkPreviewOptions(show_above_text=True),
reply_markup=await position_edit_open_finl(bot, position_id, 0),
)
@@ -303,11 +320,38 @@ async def item_open_admin(bot: Bot, item_id: int, user_id: int):
################################################################################
# Статистика бота
async def get_statistics() -> str:
refill_amount_all, refill_amount_day, refill_amount_week, refill_amount_month = 0, 0, 0, 0
refill_count_all, refill_count_day, refill_count_week, refill_count_month = 0, 0, 0, 0
profit_amount_all, profit_amount_day, profit_amount_week, profit_amount_month = 0, 0, 0, 0
profit_count_all, profit_count_day, profit_count_week, profit_count_month = 0, 0, 0, 0
users_all, users_day, users_week, users_month, users_money_have, users_money_give = 0, 0, 0, 0, 0, 0
refill_amount_all, refill_amount_day, refill_amount_week, refill_amount_month = (
0,
0,
0,
0,
)
refill_count_all, refill_count_day, refill_count_week, refill_count_month = (
0,
0,
0,
0,
)
profit_amount_all, profit_amount_day, profit_amount_week, profit_amount_month = (
0,
0,
0,
0,
)
profit_count_all, profit_count_day, profit_count_week, profit_count_month = (
0,
0,
0,
0,
)
(
users_all,
users_day,
users_week,
users_month,
users_money_have,
users_money_give,
) = (0, 0, 0, 0, 0, 0)
refill_cryptobot_count, refill_cryptobot_amount = 0, 0
refill_yoomoney_count, refill_yoomoney_amount = 0, 0
refill_stars_count, refill_stars_amount = 0, 0
@@ -375,12 +419,28 @@ async def get_statistics() -> str:
# Даты обновления статистики
all_days = [
'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота', 'Воскресенье',
"Понедельник",
"Вторник",
"Среда",
"Четверг",
"Пятница",
"Суббота",
"Воскресенье",
]
all_months = [
'Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь',
'Октябрь', 'Ноябрь', 'Декабрь'
"Январь",
"Февраль",
"Март",
"Апрель",
"Май",
"Июнь",
"Июль",
"Август",
"Сентябрь",
"Октябрь",
"Ноябрь",
"Декабрь",
]
now_day = datetime.now().day
@@ -388,12 +448,22 @@ async def get_statistics() -> str:
now_month = datetime.now().month
now_year = datetime.now().year
unix_day = int(datetime.strptime(f"{now_day}.{now_month}.{now_year} 0:0:0", "%d.%m.%Y %H:%M:%S").timestamp())
unix_day = int(
datetime.strptime(
f"{now_day}.{now_month}.{now_year} 0:0:0", "%d.%m.%Y %H:%M:%S"
).timestamp()
)
unix_week = unix_day - (now_week * 86400)
week_day = int(datetime.fromtimestamp(unix_week, pytz.timezone(BOT_TIMEZONE)).strftime("%d"))
week_month = int(datetime.fromtimestamp(unix_week, pytz.timezone(BOT_TIMEZONE)).strftime("%m"))
week_week = int(datetime.fromtimestamp(unix_week, pytz.timezone(BOT_TIMEZONE)).weekday())
week_day = int(
datetime.fromtimestamp(unix_week, pytz.timezone(BOT_TIMEZONE)).strftime("%d")
)
week_month = int(
datetime.fromtimestamp(unix_week, pytz.timezone(BOT_TIMEZONE)).strftime("%m")
)
week_week = int(
datetime.fromtimestamp(unix_week, pytz.timezone(BOT_TIMEZONE)).weekday()
)
return ded(f"""
<b>📊 СТАТИСТИКА БОТА</b>