forked from FOSS/AutoShop-Djimbo
refactor: remove Alembic migrations and Discord integration
This commit is contained in:
@@ -26,12 +26,23 @@ from tgbot.keyboards.inline_admin_products import (
|
||||
products_removes_items_finl,
|
||||
item_add_finish_finl,
|
||||
)
|
||||
from tgbot.services.api_discord import DiscordAPI
|
||||
from tgbot.services.api_hosting_text import HostingAPI
|
||||
from tgbot.utils.const_functions import clear_list, is_number, to_number, del_message, ded, clear_html, gen_id
|
||||
from tgbot.utils.const_functions import (
|
||||
clear_list,
|
||||
is_number,
|
||||
to_number,
|
||||
del_message,
|
||||
ded,
|
||||
clear_html,
|
||||
gen_id,
|
||||
)
|
||||
from tgbot.utils.misc.bot_logging import bot_logger
|
||||
from tgbot.utils.misc.bot_models import FSM, ARS
|
||||
from tgbot.utils.text_functions import category_open_admin, position_open_admin, item_open_admin
|
||||
from tgbot.utils.text_functions import (
|
||||
category_open_admin,
|
||||
position_open_admin,
|
||||
item_open_admin,
|
||||
)
|
||||
|
||||
router = Router(name=__name__)
|
||||
|
||||
@@ -123,8 +134,10 @@ async def prod_removes(message: Message, bot: Bot, state: FSM, arSession: ARS):
|
||||
################################################################################
|
||||
############################### СОЗДАНИЕ КАТЕГОРИИ #############################
|
||||
# Принятие названия категории для её создания
|
||||
@router.message(F.text, StateFilter('here_category_name'))
|
||||
async def prod_category_add_name_get(message: Message, bot: Bot, state: FSM, arSession: ARS):
|
||||
@router.message(F.text, StateFilter("here_category_name"))
|
||||
async def prod_category_add_name_get(
|
||||
message: Message, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
if len(message.text) > 50:
|
||||
return await message.answer(
|
||||
"<b>❌ Название не может превышать 50 символов</b>\n"
|
||||
@@ -143,7 +156,9 @@ async def prod_category_add_name_get(message: Message, bot: Bot, state: FSM, arS
|
||||
############################### ИЗМЕНЕНИЕ КАТЕГОРИИ ############################
|
||||
# Страница выбора категорий для редактирования
|
||||
@router.callback_query(F.data.startswith("category_edit_swipe:"))
|
||||
async def prod_category_edit_swipe(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_category_edit_swipe(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
remover = int(call.data.split(":")[1])
|
||||
|
||||
await call.message.edit_text(
|
||||
@@ -154,7 +169,9 @@ async def prod_category_edit_swipe(call: CallbackQuery, bot: Bot, state: FSM, ar
|
||||
|
||||
# Выбор текущей категории для редактирования
|
||||
@router.callback_query(F.data.startswith("category_edit_open:"))
|
||||
async def prod_category_edit_open(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_category_edit_open(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
category_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -167,7 +184,9 @@ async def prod_category_edit_open(call: CallbackQuery, bot: Bot, state: FSM, arS
|
||||
############################ САМО ИЗМЕНЕНИЕ КАТЕГОРИИ ##########################
|
||||
# Изменение названия категории
|
||||
@router.callback_query(F.data.startswith("category_edit_name:"))
|
||||
async def prod_category_edit_name(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_category_edit_name(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
category_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -184,10 +203,12 @@ async def prod_category_edit_name(call: CallbackQuery, bot: Bot, state: FSM, arS
|
||||
|
||||
|
||||
# Принятие нового названия для категории
|
||||
@router.message(F.text, StateFilter('here_category_edit_name'))
|
||||
async def prod_category_edit_name_get(message: Message, bot: Bot, state: FSM, arSession: ARS):
|
||||
category_id = (await state.get_data())['here_category_id']
|
||||
remover = (await state.get_data())['here_remover']
|
||||
@router.message(F.text, StateFilter("here_category_edit_name"))
|
||||
async def prod_category_edit_name_get(
|
||||
message: Message, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
category_id = (await state.get_data())["here_category_id"]
|
||||
remover = (await state.get_data())["here_remover"]
|
||||
|
||||
if len(message.text) > 50:
|
||||
return await message.answer(
|
||||
@@ -204,7 +225,9 @@ async def prod_category_edit_name_get(message: Message, bot: Bot, state: FSM, ar
|
||||
|
||||
# Удаление категории
|
||||
@router.callback_query(F.data.startswith("category_edit_delete:"))
|
||||
async def prod_category_edit_delete(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_category_edit_delete(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
category_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -216,7 +239,9 @@ async def prod_category_edit_delete(call: CallbackQuery, bot: Bot, state: FSM, a
|
||||
|
||||
# Подтверждение удаления категории
|
||||
@router.callback_query(F.data.startswith("category_edit_delete_confirm:"))
|
||||
async def prod_category_edit_delete_confirm(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_category_edit_delete_confirm(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
category_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -241,7 +266,9 @@ async def prod_category_edit_delete_confirm(call: CallbackQuery, bot: Bot, state
|
||||
############################### ДОБАВЛЕНИЕ ПОЗИЦИИ #############################
|
||||
# Cтраницы выбора категорий для расположения позиции
|
||||
@router.callback_query(F.data.startswith("position_add_swipe:"))
|
||||
async def prod_position_add_swipe(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_position_add_swipe(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
remover = int(call.data.split(":")[1])
|
||||
|
||||
await call.message.edit_text(
|
||||
@@ -252,7 +279,9 @@ async def prod_position_add_swipe(call: CallbackQuery, bot: Bot, state: FSM, arS
|
||||
|
||||
# Выбор категории для создания позиции
|
||||
@router.callback_query(F.data.startswith("position_add_open:"))
|
||||
async def prod_position_add_open(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_position_add_open(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
category_id = int(call.data.split(":")[1])
|
||||
|
||||
await state.update_data(here_category_id=category_id)
|
||||
@@ -262,8 +291,10 @@ async def prod_position_add_open(call: CallbackQuery, bot: Bot, state: FSM, arSe
|
||||
|
||||
|
||||
# Принятие названия для создания позиции
|
||||
@router.message(F.text, StateFilter('here_position_name'))
|
||||
async def prod_position_add_name_get(message: Message, bot: Bot, state: FSM, arSession: ARS):
|
||||
@router.message(F.text, StateFilter("here_position_name"))
|
||||
async def prod_position_add_name_get(
|
||||
message: Message, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
if len(message.text) > 50:
|
||||
return await message.answer(
|
||||
"<b>❌ Название не может превышать 50 символов</b>\n"
|
||||
@@ -277,12 +308,13 @@ async def prod_position_add_name_get(message: Message, bot: Bot, state: FSM, arS
|
||||
|
||||
|
||||
# Принятие цены позиции для её создания
|
||||
@router.message(F.text, StateFilter('here_position_price'))
|
||||
async def prod_position_add_price_get(message: Message, bot: Bot, state: FSM, arSession: ARS):
|
||||
@router.message(F.text, StateFilter("here_position_price"))
|
||||
async def prod_position_add_price_get(
|
||||
message: Message, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
if not is_number(message.text):
|
||||
return await message.answer(
|
||||
"<b>❌ Данные были введены неверно</b>\n"
|
||||
"📁 Введите цену для позиции",
|
||||
"<b>❌ Данные были введены неверно</b>\n" "📁 Введите цену для позиции",
|
||||
)
|
||||
|
||||
if to_number(message.text) > 10_000_000 or to_number(message.text) < 0:
|
||||
@@ -291,11 +323,10 @@ async def prod_position_add_price_get(message: Message, bot: Bot, state: FSM, ar
|
||||
"📁 Введите цену для позиции",
|
||||
)
|
||||
|
||||
category_id = (await state.get_data())['here_category_id']
|
||||
position_name = (await state.get_data())['here_position_name']
|
||||
category_id = (await state.get_data())["here_category_id"]
|
||||
position_name = (await state.get_data())["here_position_name"]
|
||||
position_price = to_number(message.text)
|
||||
position_desc = "None"
|
||||
position_photo = "None"
|
||||
position_id = gen_id(12)
|
||||
await state.clear()
|
||||
|
||||
@@ -305,7 +336,6 @@ async def prod_position_add_price_get(message: Message, bot: Bot, state: FSM, ar
|
||||
position_name=position_name,
|
||||
position_price=position_price,
|
||||
position_desc=position_desc,
|
||||
position_photo=position_photo,
|
||||
)
|
||||
|
||||
await position_open_admin(bot, position_id, message.from_user.id)
|
||||
@@ -315,7 +345,9 @@ async def prod_position_add_price_get(message: Message, bot: Bot, state: FSM, ar
|
||||
############################ РЕДАКТИРОВАНИЕ ПОЗИЦИИ ############################
|
||||
# Страницы выбора категории для редактирования позиции
|
||||
@router.callback_query(F.data.startswith("position_edit_category_swipe:"))
|
||||
async def prod_position_edit_category_swipe(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_position_edit_category_swipe(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
remover = int(call.data.split(":")[1])
|
||||
|
||||
await call.message.edit_text(
|
||||
@@ -326,7 +358,9 @@ async def prod_position_edit_category_swipe(call: CallbackQuery, bot: Bot, state
|
||||
|
||||
# Открытие категории для выбора позиции
|
||||
@router.callback_query(F.data.startswith("position_edit_category_open:"))
|
||||
async def prod_position_edit_category_open(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_position_edit_category_open(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
category_id = int(call.data.split(":")[1])
|
||||
|
||||
get_category = await Categoryx().get_required(category_id=category_id)
|
||||
@@ -338,12 +372,16 @@ async def prod_position_edit_category_open(call: CallbackQuery, bot: Bot, state:
|
||||
reply_markup=await position_edit_swipe_fp(0, category_id),
|
||||
)
|
||||
else:
|
||||
await call.answer(f"📁 Позиции в категории {get_category.category_name} отсутствуют")
|
||||
await call.answer(
|
||||
f"📁 Позиции в категории {get_category.category_name} отсутствуют"
|
||||
)
|
||||
|
||||
|
||||
# Страницы выбора позиции для редактирования
|
||||
@router.callback_query(F.data.startswith("position_edit_swipe:"))
|
||||
async def prod_position_edit_swipe(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_position_edit_swipe(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
category_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -357,7 +395,9 @@ async def prod_position_edit_swipe(call: CallbackQuery, bot: Bot, state: FSM, ar
|
||||
|
||||
# Выбор позиции для редактирования
|
||||
@router.callback_query(F.data.startswith("position_edit_open:"))
|
||||
async def prod_position_edit_open(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_position_edit_open(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
position_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -370,7 +410,9 @@ async def prod_position_edit_open(call: CallbackQuery, bot: Bot, state: FSM, arS
|
||||
############################ САМО ИЗМЕНЕНИЕ ПОЗИЦИИ ############################
|
||||
# Изменение названия позиции
|
||||
@router.callback_query(F.data.startswith("position_edit_name:"))
|
||||
async def prod_position_edit_name(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_position_edit_name(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
position_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -386,10 +428,12 @@ async def prod_position_edit_name(call: CallbackQuery, bot: Bot, state: FSM, arS
|
||||
|
||||
|
||||
# Принятие названия позиции для её изменения
|
||||
@router.message(F.text, StateFilter('here_position_edit_name'))
|
||||
async def prod_position_edit_name_get(message: Message, bot: Bot, state: FSM, arSession: ARS):
|
||||
position_id = (await state.get_data())['here_position_id']
|
||||
remover = (await state.get_data())['here_remover']
|
||||
@router.message(F.text, StateFilter("here_position_edit_name"))
|
||||
async def prod_position_edit_name_get(
|
||||
message: Message, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
position_id = (await state.get_data())["here_position_id"]
|
||||
remover = (await state.get_data())["here_remover"]
|
||||
|
||||
if len(message.text) > 50:
|
||||
return await message.answer(
|
||||
@@ -406,7 +450,9 @@ async def prod_position_edit_name_get(message: Message, bot: Bot, state: FSM, ar
|
||||
|
||||
# Изменение цены позиции
|
||||
@router.callback_query(F.data.startswith("position_edit_price:"))
|
||||
async def prod_position_edit_price(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_position_edit_price(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
position_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -422,10 +468,12 @@ async def prod_position_edit_price(call: CallbackQuery, bot: Bot, state: FSM, ar
|
||||
|
||||
|
||||
# Принятие цены позиции для её изменения
|
||||
@router.message(F.text, StateFilter('here_position_edit_price'))
|
||||
async def prod_position_edit_price_get(message: Message, bot: Bot, state: FSM, arSession: ARS):
|
||||
position_id = (await state.get_data())['here_position_id']
|
||||
remover = (await state.get_data())['here_remover']
|
||||
@router.message(F.text, StateFilter("here_position_edit_price"))
|
||||
async def prod_position_edit_price_get(
|
||||
message: Message, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
position_id = (await state.get_data())["here_position_id"]
|
||||
remover = (await state.get_data())["here_remover"]
|
||||
|
||||
if not is_number(message.text):
|
||||
return await message.answer(
|
||||
@@ -449,7 +497,9 @@ async def prod_position_edit_price_get(message: Message, bot: Bot, state: FSM, a
|
||||
|
||||
# Изменение описания позиции
|
||||
@router.callback_query(F.data.startswith("position_edit_desc:"))
|
||||
async def prod_position_edit_desc(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_position_edit_desc(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
position_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -469,10 +519,12 @@ async def prod_position_edit_desc(call: CallbackQuery, bot: Bot, state: FSM, arS
|
||||
|
||||
|
||||
# Принятие описания позиции для её изменения
|
||||
@router.message(F.text, StateFilter('here_position_edit_desc'))
|
||||
async def prod_position_edit_desc_get(message: Message, bot: Bot, state: FSM, arSession: ARS):
|
||||
position_id = (await state.get_data())['here_position_id']
|
||||
remover = (await state.get_data())['here_remover']
|
||||
@router.message(F.text, StateFilter("here_position_edit_desc"))
|
||||
async def prod_position_edit_desc_get(
|
||||
message: Message, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
position_id = (await state.get_data())["here_position_id"]
|
||||
remover = (await state.get_data())["here_remover"]
|
||||
|
||||
if len(message.text) > 1200:
|
||||
return await message.answer(
|
||||
@@ -510,74 +562,11 @@ async def prod_position_edit_desc_get(message: Message, bot: Bot, state: FSM, ar
|
||||
await position_open_admin(bot, position_id, message.from_user.id)
|
||||
|
||||
|
||||
# Изменение изображения позиции
|
||||
@router.callback_query(F.data.startswith("position_edit_photo:"))
|
||||
async def prod_position_edit_photo(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
position_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
get_settings = await Settingsx().get()
|
||||
|
||||
if get_settings.misc_discord_webhook_url == "None":
|
||||
return await call.answer("🧿 Отсутствует Дискорд вебхук, добавьте его в настройках", True)
|
||||
|
||||
await state.update_data(here_position_id=position_id)
|
||||
await state.update_data(here_remover=remover)
|
||||
await state.set_state("here_position_edit_photo")
|
||||
|
||||
await del_message(call.message)
|
||||
await call.message.answer(
|
||||
"<b>📁 Отправьте новое изображение для позиции</b>\n"
|
||||
"❕ Отправьте <code>0</code> чтобы пропустить.",
|
||||
reply_markup=position_edit_cancel_finl(position_id, remover),
|
||||
)
|
||||
|
||||
|
||||
# Принятие нового фото для позиции
|
||||
@router.message((F.text == "0") | F.photo, StateFilter('here_position_edit_photo'))
|
||||
async def prod_position_edit_photo_get(message: Message, bot: Bot, state: FSM, arSession: ARS):
|
||||
position_id = (await state.get_data())['here_position_id']
|
||||
remover = (await state.get_data())['here_remover']
|
||||
|
||||
get_settings = await Settingsx().get()
|
||||
|
||||
if get_settings.misc_discord_webhook_url == "None":
|
||||
return await message.answer(
|
||||
"<b>🧿 Отсутствует Дискорд вебхук, добавьте его в настройках</b>"
|
||||
)
|
||||
|
||||
position_photo = "None"
|
||||
|
||||
if message.photo is not None:
|
||||
cache_message = await message.answer(
|
||||
"<b>♻️ Подождите, фотография загружается...</b>"
|
||||
)
|
||||
|
||||
file_path = (await bot.get_file(message.photo[-1].file_id)).file_path
|
||||
photo_path = await bot.download_file(file_path)
|
||||
|
||||
pay_image_status, pay_image_url = await (
|
||||
await DiscordAPI.connect(
|
||||
bot=bot,
|
||||
arSession=arSession,
|
||||
update=message,
|
||||
)
|
||||
).upload_photo(photo_path.read())
|
||||
|
||||
if pay_image_status:
|
||||
position_photo = pay_image_url
|
||||
|
||||
await del_message(cache_message)
|
||||
|
||||
await state.clear()
|
||||
|
||||
await Positionx().update(position_id, position_photo=position_photo)
|
||||
await position_open_admin(bot, position_id, message.from_user.id)
|
||||
|
||||
|
||||
# Выгрузка товаров
|
||||
@router.callback_query(F.data.startswith("position_edit_items:"))
|
||||
async def prod_position_edit_items(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_position_edit_items(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
position_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -607,7 +596,9 @@ async def prod_position_edit_items(call: CallbackQuery, bot: Bot, state: FSM, ar
|
||||
|
||||
# Удаление позиции
|
||||
@router.callback_query(F.data.startswith("position_edit_delete:"))
|
||||
async def prod_position_edit_delete(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_position_edit_delete(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
position_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -621,7 +612,9 @@ async def prod_position_edit_delete(call: CallbackQuery, bot: Bot, state: FSM, a
|
||||
|
||||
# Подтверждение удаления позиции
|
||||
@router.callback_query(F.data.startswith("position_edit_delete_confirm:"))
|
||||
async def prod_position_edit_delete_confirm(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_position_edit_delete_confirm(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
position_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -636,7 +629,9 @@ async def prod_position_edit_delete_confirm(call: CallbackQuery, bot: Bot, state
|
||||
if len(get_positions) >= 1:
|
||||
await call.message.edit_text(
|
||||
"<b>📁 Выберите позицию для изменения 🖍</b>",
|
||||
reply_markup=await position_edit_swipe_fp(remover, get_position.category_id),
|
||||
reply_markup=await position_edit_swipe_fp(
|
||||
remover, get_position.category_id
|
||||
),
|
||||
)
|
||||
else:
|
||||
await del_message(call.message)
|
||||
@@ -644,7 +639,9 @@ async def prod_position_edit_delete_confirm(call: CallbackQuery, bot: Bot, state
|
||||
|
||||
# Очистка позиции
|
||||
@router.callback_query(F.data.startswith("position_edit_clear:"))
|
||||
async def prod_position_edit_clear(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_position_edit_clear(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
position_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -657,7 +654,9 @@ async def prod_position_edit_clear(call: CallbackQuery, bot: Bot, state: FSM, ar
|
||||
|
||||
# Согласие на очистку позиции
|
||||
@router.callback_query(F.data.startswith("position_edit_clear_confirm:"))
|
||||
async def prod_position_edit_clear_confirm(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_position_edit_clear_confirm(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
position_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -672,7 +671,9 @@ async def prod_position_edit_clear_confirm(call: CallbackQuery, bot: Bot, state:
|
||||
############################### ДОБАВЛЕНИЕ ТОВАРОВ #############################
|
||||
# Страницы выбора категории для добавления товара
|
||||
@router.callback_query(F.data.startswith("item_add_category_swipe:"))
|
||||
async def prod_item_add_category_swipe(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_item_add_category_swipe(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
remover = int(call.data.split(":")[1])
|
||||
|
||||
await call.message.edit_text(
|
||||
@@ -683,7 +684,9 @@ async def prod_item_add_category_swipe(call: CallbackQuery, bot: Bot, state: FSM
|
||||
|
||||
# Открытие категории для выбора позиции
|
||||
@router.callback_query(F.data.startswith("item_add_category_open:"))
|
||||
async def prod_item_add_category_open(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_item_add_category_open(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
category_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -698,12 +701,16 @@ async def prod_item_add_category_open(call: CallbackQuery, bot: Bot, state: FSM,
|
||||
reply_markup=await item_add_position_swipe_fp(0, category_id),
|
||||
)
|
||||
else:
|
||||
await call.answer(f"🎁 Позиции в категории {get_category.category_name} отсутствуют")
|
||||
await call.answer(
|
||||
f"🎁 Позиции в категории {get_category.category_name} отсутствуют"
|
||||
)
|
||||
|
||||
|
||||
# Страницы выбора позиции для добавления товара
|
||||
@router.callback_query(F.data.startswith("item_add_position_swipe:"))
|
||||
async def prod_item_add_position_swipe(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_item_add_position_swipe(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
category_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -714,8 +721,10 @@ async def prod_item_add_position_swipe(call: CallbackQuery, bot: Bot, state: FSM
|
||||
|
||||
|
||||
# Выбор позиции для добавления товаров
|
||||
@router.callback_query(F.data.startswith("item_add_position_open:"), flags={'rate': 0})
|
||||
async def prod_item_add_position_open(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
@router.callback_query(F.data.startswith("item_add_position_open:"), flags={"rate": 0})
|
||||
async def prod_item_add_position_open(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
position_id = int(call.data.split(":")[1])
|
||||
|
||||
get_position = await Positionx().get_required(position_id=position_id)
|
||||
@@ -734,9 +743,9 @@ async def prod_item_add_position_open(call: CallbackQuery, bot: Bot, state: FSM,
|
||||
<b>🎁 Отправляйте данные товаров</b>
|
||||
❗ Товары разделяются одной пустой строчкой. Пример:
|
||||
<code>Данные товара...
|
||||
|
||||
|
||||
Данные товара...
|
||||
|
||||
|
||||
Данные товара...</code>
|
||||
"""),
|
||||
reply_markup=item_add_finish_finl(position_id),
|
||||
@@ -755,12 +764,16 @@ async def prod_item_add_position_open(call: CallbackQuery, bot: Bot, state: FSM,
|
||||
|
||||
|
||||
# Завершение загрузки товаров
|
||||
@router.callback_query(F.data.startswith('item_add_position_finish:'), flags={'rate': 0})
|
||||
async def prod_item_add_finish(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
@router.callback_query(
|
||||
F.data.startswith("item_add_position_finish:"), flags={"rate": 0}
|
||||
)
|
||||
async def prod_item_add_finish(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
position_id = int(call.data.split(":")[1])
|
||||
|
||||
try:
|
||||
count_items = (await state.get_data())['here_add_item_count']
|
||||
count_items = (await state.get_data())["here_add_item_count"]
|
||||
except Exception:
|
||||
bot_logger.debug("В state нет счетчика добавленных товаров", exc_info=True)
|
||||
count_items = 0
|
||||
@@ -777,7 +790,7 @@ async def prod_item_add_finish(call: CallbackQuery, bot: Bot, state: FSM, arSess
|
||||
|
||||
|
||||
# Принятие данных товара
|
||||
@router.message(F.text, StateFilter('here_add_items'), flags={'rate': 0})
|
||||
@router.message(F.text, StateFilter("here_add_items"), flags={"rate": 0})
|
||||
async def prod_item_add_get(message: Message, bot: Bot, state: FSM, arSession: ARS):
|
||||
cache_message = await message.answer("<b>⌛ Ждите, товары добавляются..</b>")
|
||||
|
||||
@@ -788,9 +801,9 @@ async def prod_item_add_get(message: Message, bot: Bot, state: FSM, arSession: A
|
||||
else:
|
||||
get_items = clear_list(message.text.split("\n"))
|
||||
|
||||
item_count = (await state.get_data())['here_add_item_count']
|
||||
category_id = (await state.get_data())['here_add_item_category_id']
|
||||
position_id = (await state.get_data())['here_add_item_position_id']
|
||||
item_count = (await state.get_data())["here_add_item_count"]
|
||||
category_id = (await state.get_data())["here_add_item_category_id"]
|
||||
position_id = (await state.get_data())["here_add_item_position_id"]
|
||||
|
||||
await state.update_data(here_add_item_count=item_count + len(get_items))
|
||||
|
||||
@@ -811,7 +824,9 @@ async def prod_item_add_get(message: Message, bot: Bot, state: FSM, arSession: A
|
||||
############################### УДАЛЕНИЕ ТОВАРОВ ###############################
|
||||
# Страницы удаления товаров
|
||||
@router.callback_query(F.data.startswith("item_delete_swipe:"))
|
||||
async def prod_item_delete_swipe(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_item_delete_swipe(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
position_id = int(call.data.split(":")[1])
|
||||
remover = int(call.data.split(":")[2])
|
||||
|
||||
@@ -826,12 +841,16 @@ async def prod_item_delete_swipe(call: CallbackQuery, bot: Bot, state: FSM, arSe
|
||||
reply_markup=await item_delete_swipe_fp(remover, position_id),
|
||||
)
|
||||
else:
|
||||
await call.answer(f"🎁 Товары в позиции {get_position.position_name} отсутствуют", True)
|
||||
await call.answer(
|
||||
f"🎁 Товары в позиции {get_position.position_name} отсутствуют", True
|
||||
)
|
||||
|
||||
|
||||
# Удаление товара
|
||||
@router.callback_query(F.data.startswith("item_delete_open:"))
|
||||
async def prod_item_delete_open(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_item_delete_open(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
item_id = int(call.data.split(":")[1])
|
||||
|
||||
await del_message(call.message)
|
||||
@@ -840,7 +859,9 @@ async def prod_item_delete_open(call: CallbackQuery, bot: Bot, state: FSM, arSes
|
||||
|
||||
# Подтверждение удаления товара
|
||||
@router.callback_query(F.data.startswith("item_delete_confirm:"))
|
||||
async def prod_item_delete_confirm_open(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_item_delete_confirm_open(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
item_id = int(call.data.split(":")[1])
|
||||
|
||||
get_item = await Itemx().get_required(item_id=item_id)
|
||||
@@ -862,7 +883,9 @@ async def prod_item_delete_confirm_open(call: CallbackQuery, bot: Bot, state: FS
|
||||
############################### УДАЛЕНИЕ РАЗДЕЛОВ ##############################
|
||||
# Возвращение к меню удаления разделов
|
||||
@router.callback_query(F.data == "prod_removes_return")
|
||||
async def prod_removes_return(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_removes_return(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
await state.clear()
|
||||
|
||||
await call.message.edit_text(
|
||||
@@ -873,7 +896,9 @@ async def prod_removes_return(call: CallbackQuery, bot: Bot, state: FSM, arSessi
|
||||
|
||||
# Удаление всех категорий
|
||||
@router.callback_query(F.data == "prod_removes_categories")
|
||||
async def prod_removes_categories(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_removes_categories(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
get_categories = len(await Categoryx().get_all())
|
||||
get_positions = len(await Positionx().get_all())
|
||||
get_items = len(await Itemx().get_all())
|
||||
@@ -891,7 +916,9 @@ async def prod_removes_categories(call: CallbackQuery, bot: Bot, state: FSM, arS
|
||||
|
||||
# Подтверждение удаления всех категорий (позиций и товаров включительно)
|
||||
@router.callback_query(F.data == "prod_removes_categories_confirm")
|
||||
async def prod_removes_categories_confirm(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_removes_categories_confirm(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
get_categories = len(await Categoryx().get_all())
|
||||
get_positions = len(await Positionx().get_all())
|
||||
get_items = len(await Itemx().get_all())
|
||||
@@ -900,19 +927,19 @@ async def prod_removes_categories_confirm(call: CallbackQuery, bot: Bot, state:
|
||||
await Positionx().clear()
|
||||
await Itemx().clear()
|
||||
|
||||
await call.message.edit_text(
|
||||
ded(f"""
|
||||
await call.message.edit_text(ded(f"""
|
||||
<b>✅ Вы успешно удалили все категории</b>
|
||||
🗃 Категорий: <code>{get_categories}шт</code>
|
||||
📁 Позиций: <code>{get_positions}шт</code>
|
||||
🎁 Товаров: <code>{get_items}шт</code>
|
||||
""")
|
||||
)
|
||||
"""))
|
||||
|
||||
|
||||
# Удаление всех позиций
|
||||
@router.callback_query(F.data == "prod_removes_positions")
|
||||
async def prod_removes_positions(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_removes_positions(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
get_positions = len(await Positionx().get_all())
|
||||
get_items = len(await Itemx().get_all())
|
||||
|
||||
@@ -928,20 +955,20 @@ async def prod_removes_positions(call: CallbackQuery, bot: Bot, state: FSM, arSe
|
||||
|
||||
# Подтверждение удаления всех позиций (товаров включительно)
|
||||
@router.callback_query(F.data == "prod_removes_positions_confirm")
|
||||
async def prod_position_remove(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def prod_position_remove(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
get_positions = len(await Positionx().get_all())
|
||||
get_items = len(await Itemx().get_all())
|
||||
|
||||
await Positionx().clear()
|
||||
await Itemx().clear()
|
||||
|
||||
await call.message.edit_text(
|
||||
ded(f"""
|
||||
await call.message.edit_text(ded(f"""
|
||||
<b>✅ Вы успешно удалили все позиции</b>
|
||||
📁 Позиций: <code>{get_positions}шт</code>
|
||||
🎁 Товаров: <code>{get_items}шт</code>
|
||||
""")
|
||||
)
|
||||
"""))
|
||||
|
||||
|
||||
# Удаление всех товаров
|
||||
|
||||
@@ -5,7 +5,6 @@ from aiogram.types import CallbackQuery, Message
|
||||
|
||||
from tgbot.database import Settingsx, Userx
|
||||
from tgbot.keyboards.inline_admin import settings_status_finl, settings_finl
|
||||
from tgbot.services.api_discord import DiscordDJ, DiscordAPI
|
||||
from tgbot.utils.const_functions import ded
|
||||
from tgbot.utils.misc.bot_logging import bot_logger
|
||||
from tgbot.utils.misc.bot_models import FSM, ARS
|
||||
@@ -40,7 +39,9 @@ async def settings_status_edit(message: Message, bot: Bot, state: FSM, arSession
|
||||
################################## ВЫКЛЮЧАТЕЛИ #################################
|
||||
# Включение/выключение тех работ
|
||||
@router.callback_query(F.data.startswith("settings_status_work:"))
|
||||
async def settings_status_work(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def settings_status_work(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
get_status = call.data.split(":")[1]
|
||||
|
||||
get_user = await Userx().get_required(user_id=call.from_user.id)
|
||||
@@ -65,7 +66,9 @@ async def settings_status_work(call: CallbackQuery, bot: Bot, state: FSM, arSess
|
||||
|
||||
# Включение/выключение покупок
|
||||
@router.callback_query(F.data.startswith("settings_status_buy:"))
|
||||
async def settings_status_buy(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def settings_status_buy(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
get_status = call.data.split(":")[1]
|
||||
|
||||
get_user = await Userx().get_required(user_id=call.from_user.id)
|
||||
@@ -90,7 +93,9 @@ async def settings_status_buy(call: CallbackQuery, bot: Bot, state: FSM, arSessi
|
||||
|
||||
# Включение/выключение пополнений
|
||||
@router.callback_query(F.data.startswith("settings_status_refill:"))
|
||||
async def settings_status_refill(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def settings_status_refill(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
get_status = call.data.split(":")[1]
|
||||
|
||||
get_user = await Userx().get_required(user_id=call.from_user.id)
|
||||
@@ -113,7 +118,9 @@ async def settings_status_refill(call: CallbackQuery, bot: Bot, state: FSM, arSe
|
||||
|
||||
# Включение/выключение уведомлений о покупках
|
||||
@router.callback_query(F.data.startswith("settings_notification_buy:"))
|
||||
async def settings_notification_buy(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def settings_notification_buy(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
get_status = call.data.split(":")[1]
|
||||
|
||||
get_user = await Userx().get_required(user_id=call.from_user.id)
|
||||
@@ -136,7 +143,9 @@ async def settings_notification_buy(call: CallbackQuery, bot: Bot, state: FSM, a
|
||||
|
||||
# Включение/выключение уведомлений о пополнениях
|
||||
@router.callback_query(F.data.startswith("settings_notification_refill:"))
|
||||
async def settings_notification_refill(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def settings_notification_refill(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
get_status = call.data.split(":")[1]
|
||||
|
||||
get_user = await Userx().get_required(user_id=call.from_user.id)
|
||||
@@ -165,20 +174,20 @@ async def settings_faq_edit(call: CallbackQuery, bot: Bot, state: FSM, arSession
|
||||
await state.clear()
|
||||
|
||||
await state.set_state("here_settings_faq")
|
||||
await call.message.edit_text(
|
||||
ded("""
|
||||
await call.message.edit_text(ded("""
|
||||
<b>❔ Введите новый текст для FAQ</b>
|
||||
❕ Вы можете использовать заготовленный синтаксис и HTML разметку:
|
||||
▪️ <code>{username}</code> - логин пользоваля
|
||||
▪️ <code>{user_id}</code> - айди пользователя
|
||||
▪️ <code>{firstname}</code> - имя пользователя
|
||||
""")
|
||||
)
|
||||
"""))
|
||||
|
||||
|
||||
# Изменение поддержки
|
||||
@router.callback_query(F.data == "settings_edit_support")
|
||||
async def settings_support_edit(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def settings_support_edit(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
await state.clear()
|
||||
|
||||
await state.set_state("here_settings_support")
|
||||
@@ -190,7 +199,9 @@ async def settings_support_edit(call: CallbackQuery, bot: Bot, state: FSM, arSes
|
||||
|
||||
# Изменение отображения/скрытия категорий без товаров
|
||||
@router.callback_query(F.data.startswith("settings_edit_hide_category:"))
|
||||
async def settings_edit_hide_category(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def settings_edit_hide_category(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
status = call.data.split(":")[1]
|
||||
|
||||
await Settingsx().update(misc_hide_category=status)
|
||||
@@ -203,7 +214,9 @@ async def settings_edit_hide_category(call: CallbackQuery, bot: Bot, state: FSM,
|
||||
|
||||
# Изменение отображения/скрытия позиций без товаров
|
||||
@router.callback_query(F.data.startswith("settings_edit_hide_position:"))
|
||||
async def settings_edit_hide_position(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def settings_edit_hide_position(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
status = call.data.split(":")[1]
|
||||
|
||||
await Settingsx().update(misc_hide_position=status)
|
||||
@@ -216,7 +229,9 @@ async def settings_edit_hide_position(call: CallbackQuery, bot: Bot, state: FSM,
|
||||
|
||||
# Изменение метода добавления товаров
|
||||
@router.callback_query(F.data.startswith("settings_edit_method_prod:"))
|
||||
async def settings_edit_method_prod(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def settings_edit_method_prod(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
method = call.data.split(":")[1]
|
||||
|
||||
await Settingsx().update(misc_method_prod=method)
|
||||
@@ -227,32 +242,11 @@ async def settings_edit_method_prod(call: CallbackQuery, bot: Bot, state: FSM, a
|
||||
)
|
||||
|
||||
|
||||
# Изменение дискорд вебхука
|
||||
@router.callback_query(F.data == "settings_edit_discord_webhook")
|
||||
async def settings_discord_edit(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
await state.clear()
|
||||
|
||||
get_discord_public_webhook = await (
|
||||
DiscordDJ(
|
||||
arSession=arSession,
|
||||
bot=bot,
|
||||
)
|
||||
).export_webhook()
|
||||
|
||||
await state.set_state("here_settings_discord_webhook")
|
||||
await call.message.edit_text(
|
||||
ded(f"""
|
||||
<b>🧿 Отправьте новый вебхук дискорда</b>
|
||||
❕ Для удаления вебхука введите <code>0</code>
|
||||
❕ Вы можете использовать публичный вебхук, но ответственность за его использование лежит только на вас
|
||||
▪️ Публичный вебхук: <code>{get_discord_public_webhook}</code>
|
||||
""")
|
||||
)
|
||||
|
||||
|
||||
# Изменение текстового хостинга по умолчанию
|
||||
@router.callback_query(F.data == "settings_edit_hosting_text")
|
||||
async def settings_edit_hosting_text(call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS):
|
||||
async def settings_edit_hosting_text(
|
||||
call: CallbackQuery, bot: Bot, state: FSM, arSession: ARS
|
||||
):
|
||||
get_settings = await Settingsx().get()
|
||||
|
||||
if get_settings.misc_hosting_text == "telegraph":
|
||||
@@ -282,8 +276,7 @@ async def settings_faq_get(message: Message, bot: Bot, state: FSM, arSession: AR
|
||||
except Exception:
|
||||
bot_logger.debug("Некорректная HTML-разметка FAQ", exc_info=True)
|
||||
return await message.answer(
|
||||
"<b>❌ Ошибка синтаксиса HTML</b>\n"
|
||||
"❔ Введите новый текст для FAQ",
|
||||
"<b>❌ Ошибка синтаксиса HTML</b>\n" "❔ Введите новый текст для FAQ",
|
||||
)
|
||||
|
||||
await state.clear()
|
||||
@@ -310,67 +303,3 @@ async def settings_support_get(message: Message, bot: Bot, state: FSM, arSession
|
||||
"<b>🖍 Изменение данных бота</b>",
|
||||
reply_markup=await settings_finl(),
|
||||
)
|
||||
|
||||
|
||||
# Принятие дискорд вебхука
|
||||
@router.message(F.text, StateFilter("here_settings_discord_webhook"))
|
||||
async def settings_discord_get(message: Message, bot: Bot, state: FSM, arSession: ARS):
|
||||
get_discord_webhook = message.text
|
||||
|
||||
# Удаление вебхука
|
||||
if get_discord_webhook == "0":
|
||||
await Settingsx().update(
|
||||
misc_discord_webhook_url="None",
|
||||
misc_discord_webhook_name="None",
|
||||
)
|
||||
|
||||
return await message.answer(
|
||||
"<b>⚙️ Настройки бота</b>",
|
||||
reply_markup=await settings_finl(),
|
||||
)
|
||||
|
||||
# Добавление нового вебхука
|
||||
cache_message = await message.answer("<b>♻️ Проверка дискорд вебхука..</b>")
|
||||
|
||||
if "api" in get_discord_webhook and "webhooks" in get_discord_webhook:
|
||||
discord_webhook_status, discord_webhook_name = await (
|
||||
await DiscordAPI.connect(
|
||||
bot=bot,
|
||||
arSession=arSession,
|
||||
update=message,
|
||||
webhook_url=get_discord_webhook,
|
||||
skipping_error=True,
|
||||
)
|
||||
).check()
|
||||
|
||||
if discord_webhook_status:
|
||||
await state.clear()
|
||||
|
||||
await Settingsx().update(
|
||||
misc_discord_webhook_url=message.text,
|
||||
misc_discord_webhook_name=discord_webhook_name,
|
||||
)
|
||||
|
||||
return await cache_message.edit_text(
|
||||
"<b>⚙️ Настройки бота</b>",
|
||||
reply_markup=await settings_finl(),
|
||||
)
|
||||
|
||||
# Обработка ошибки добавления вебхука
|
||||
get_discord_public_webhook = await (
|
||||
DiscordDJ(
|
||||
arSession=arSession,
|
||||
bot=bot,
|
||||
)
|
||||
).export_webhook()
|
||||
|
||||
await cache_message.edit_text(
|
||||
ded(f"""
|
||||
<b>❌ Указан некорректный вебхук</b>
|
||||
➖➖➖➖➖➖➖➖➖➖
|
||||
🧿 Отправьте новый вебхук дискорда
|
||||
❕ Для удаления вебхука введите <code>0</code>
|
||||
❕ Вы можете использовать публичный вебхук, но ответственность за его использование лежит только на вас
|
||||
▪️ Публичный вебхук: <code>{get_discord_public_webhook}</code>
|
||||
""")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user