first commit

This commit is contained in:
2026-05-25 01:12:43 +03:00
commit bfc22efe24
83 changed files with 8903 additions and 0 deletions
View File
+55
View File
@@ -0,0 +1,55 @@
# Aiogram imports
from aiogram.utils.keyboard import ReplyKeyboardBuilder, InlineKeyboardBuilder
from aiogram.types import InlineKeyboardButton, KeyboardButton
def get_back_to_main_kb():
builder = ReplyKeyboardBuilder()
builder.row(KeyboardButton(text="↩️ Вернуться в меню"))
return builder.as_markup(resize_keyboard=True)
def get_back_kb():
builder = ReplyKeyboardBuilder()
builder.row(KeyboardButton(text="↩️ Назад"))
return builder.as_markup(resize_keyboard=True)
def get_skip_kb():
builder = ReplyKeyboardBuilder()
builder.add(KeyboardButton(text="↪️ Пропустить"), KeyboardButton(text="↩️ Назад"))
builder.adjust(1)
return builder.as_markup(resize_keyboard=True)
def get_mailer_finish_kb():
builder = ReplyKeyboardBuilder()
builder.add(
KeyboardButton(text="🟢 Начать рассылку"), KeyboardButton(text="↩️ Назад")
)
builder.adjust(1)
return builder.as_markup(resize_keyboard=True, is_persistent=True)
def get_mailer_btn_ikb(buttons_preset: list[str] | None):
builder = InlineKeyboardBuilder()
if buttons_preset:
for row in buttons_preset:
for btn_name, btn_url in row:
builder.row(InlineKeyboardButton(text=btn_name, url=btn_url))
return builder.as_markup()
+95
View File
@@ -0,0 +1,95 @@
# Aiogram imports
from aiogram.utils.keyboard import (
ReplyKeyboardBuilder,
KeyboardButton,
InlineKeyboardBuilder,
)
from aiogram.types import (
ReplyKeyboardMarkup,
InlineKeyboardMarkup,
InlineKeyboardButton,
)
def get_main_menu_kb():
builder = ReplyKeyboardBuilder()
builder.row(KeyboardButton(text="📊 Статистика"), KeyboardButton(text="✉️ Рассылка"))
builder.row(
KeyboardButton(text="🚫 Черный список"), KeyboardButton(text="⚙️ Настройки")
)
builder.row(
KeyboardButton(text="📑 Список пользователей"),
KeyboardButton(text="👮‍♂️ Управление админами"),
)
builder.row(KeyboardButton(text="🔚 Выйти"))
return builder.as_markup(resize_keyboard=True, is_persistent=True)
def get_add_admins_kb():
builder = ReplyKeyboardBuilder()
builder.row(KeyboardButton(text=" Добавить"), KeyboardButton(text=" Удалить"))
builder.row(KeyboardButton(text="↩️ Вернуться в меню"))
return builder.as_markup(resize_keyboard=True, is_persistent=True)
def get_back_kb():
builder = ReplyKeyboardBuilder()
builder.row(KeyboardButton(text="↩️ Назад"))
return builder.as_markup(resize_keyboard=True)
def get_settings_kb() -> ReplyKeyboardMarkup:
builder = ReplyKeyboardBuilder()
builder.add(KeyboardButton(text="↩️ Вернуться в меню"))
builder.adjust(2)
return builder.as_markup(resize_keyboard=True, is_persistent=True)
def get_blacklist_kb():
builder = ReplyKeyboardBuilder()
builder.row(KeyboardButton(text="👁 Открыть список"))
builder.row(KeyboardButton(text=" Добавить"), KeyboardButton(text=" Удалить"))
builder.row(KeyboardButton(text="↩️ Вернуться в меню"))
return builder.as_markup(resize_keyboard=True, is_persistent=True)
def get_bookList_ikb(
prefix: str, offset: int, max_offset: int, items: list[tuple], element_col: int = 10
) -> InlineKeyboardMarkup:
builder = InlineKeyboardBuilder()
for item_id, item_name in items[offset * element_col : (offset + 1) * element_col]:
builder.row(
InlineKeyboardButton(
text=f"{item_name}", callback_data=f"{prefix}_pick_{item_id}"
)
)
builder.row(
InlineKeyboardButton(text="⬅️", callback_data=f"{prefix}_prev"),
InlineKeyboardButton(text="➡️", callback_data=f"{prefix}_next"),
)
return builder.as_markup()
+3
View File
@@ -0,0 +1,3 @@
# Aiogram imports
from aiogram.utils.keyboard import InlineKeyboardBuilder
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
+132
View File
@@ -0,0 +1,132 @@
# Aiogram imports
from aiogram.types import InlineKeyboardMarkup, KeyboardButton, ReplyKeyboardMarkup
from aiogram.utils.keyboard import InlineKeyboardBuilder, ReplyKeyboardBuilder
from decouple import config
import pytz
QUESTION_CATEGORIES = [
("💼 Работа", "labor"),
("🛒 Защита прав потребителей", "consumer"),
("🏠 Жилье / аренда", "housing"),
("👪 Семья", "family"),
("💰 Долги / займы", "civil"),
("📄 Договоры", "civil"),
("⚖️ Суд / процесс", "procedural"),
("❓ Другое", "other"),
]
USER_TYPES = [
("Физлицо", "physical_person"),
("ИП", "individual_entrepreneur"),
("ООО", "company"),
]
CATEGORY_BY_TEXT = {text: code for text, code in QUESTION_CATEGORIES}
USER_TYPE_BY_TEXT = {text: code for text, code in USER_TYPES}
USER_TYPE_LABEL_BY_CODE = {code: text for text, code in USER_TYPES}
TZ = pytz.timezone(config("TIMEZONE"))
def get_main_menu_kb() -> ReplyKeyboardMarkup:
builder = ReplyKeyboardBuilder()
builder.row(KeyboardButton(text="⚖️ Задать вопрос"))
builder.row(
KeyboardButton(text="📚 Мои консультации"),
KeyboardButton(text="👤 Профиль"),
)
builder.row(KeyboardButton(text="️ Помощь"))
return builder.as_markup(resize_keyboard=True, is_persistent=True)
def get_categories_kb() -> ReplyKeyboardMarkup:
builder = ReplyKeyboardBuilder()
for text, _ in QUESTION_CATEGORIES:
builder.add(KeyboardButton(text=text))
builder.add(KeyboardButton(text="↩️ В меню"))
builder.adjust(1)
return builder.as_markup(resize_keyboard=True, is_persistent=True)
def get_back_to_menu_kb() -> ReplyKeyboardMarkup:
builder = ReplyKeyboardBuilder()
builder.row(KeyboardButton(text="↩️ В меню"))
return builder.as_markup(resize_keyboard=True)
def get_profile_kb() -> ReplyKeyboardMarkup:
builder = ReplyKeyboardBuilder()
builder.row(KeyboardButton(text="🌍 Изменить регион"))
builder.row(KeyboardButton(text="👔 Изменить тип пользователя"))
builder.row(KeyboardButton(text="🗑 Удалить мои данные"))
builder.row(KeyboardButton(text="↩️ В меню"))
return builder.as_markup(resize_keyboard=True, is_persistent=True)
def get_user_types_kb() -> ReplyKeyboardMarkup:
builder = ReplyKeyboardBuilder()
for text, _ in USER_TYPES:
builder.add(KeyboardButton(text=text))
builder.add(KeyboardButton(text="↩️ В меню"))
builder.adjust(1)
return builder.as_markup(resize_keyboard=True)
def get_delete_profile_kb() -> ReplyKeyboardMarkup:
builder = ReplyKeyboardBuilder()
builder.row(KeyboardButton(text="✅ Да, удалить"))
builder.row(KeyboardButton(text="↩️ В меню"))
return builder.as_markup(resize_keyboard=True)
def get_consultations_ikb(consultations: list) -> InlineKeyboardMarkup:
builder = InlineKeyboardBuilder()
for consultation in consultations:
title = consultation.title or consultation.category
updated_at = consultation.updated_at.astimezone(TZ).strftime("%d.%m.%Y")
builder.row(
ai_button(
text=f"{title[:48]}{updated_at}",
callback_data=f"consultation:open:{consultation.id}",
)
)
return builder.as_markup()
def get_consultation_actions_ikb(consultation_id: int) -> InlineKeyboardMarkup:
builder = InlineKeyboardBuilder()
builder.row(
ai_button(
text="🔁 Продолжить",
callback_data=f"consultation:continue:{consultation_id}",
)
)
builder.row(
ai_button(
text="🗑 Удалить",
callback_data=f"consultation:delete:{consultation_id}",
)
)
return builder.as_markup()
def ai_button(text: str, callback_data: str):
from aiogram.types import InlineKeyboardButton
return InlineKeyboardButton(text=text, callback_data=callback_data)