generated from geekiot/python-template
Add [verification]: add dialog without checking verification
This commit is contained in:
parent
00d87119d2
commit
0fb8c2ba6a
3 changed files with 96 additions and 12 deletions
|
|
@ -1,21 +1,62 @@
|
||||||
from aiogram.types import CallbackQuery, Message
|
from aiogram.types import CallbackQuery, Message
|
||||||
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from bot.handlers import unverified_registry
|
from bot.handlers import unverified_registry
|
||||||
from bot.utils.keyboards import get_menu_markup
|
from bot.services import VerificationStatus, verify_student
|
||||||
|
from bot.utils.keyboards import (
|
||||||
|
get_start_verification_markup,
|
||||||
|
get_verification_info_markup,
|
||||||
|
)
|
||||||
from bot.utils.types import ChatType
|
from bot.utils.types import ChatType
|
||||||
|
from database import TelegramUser
|
||||||
|
|
||||||
|
|
||||||
@unverified_registry.register(
|
@unverified_registry.register(
|
||||||
triggers="menu",
|
triggers="verification_start",
|
||||||
chat_types=ChatType.PRIVATE,
|
chat_types=ChatType.PRIVATE,
|
||||||
description="Menu Callback Unverified Description",
|
description="Callback For Start Verification Description",
|
||||||
is_callback=True,
|
is_callback=True,
|
||||||
)
|
)
|
||||||
async def cmd_menu(call: CallbackQuery) -> None:
|
async def call_start_verification(call: CallbackQuery) -> None:
|
||||||
if not isinstance(call.message, Message):
|
if not isinstance(call.message, Message):
|
||||||
return
|
return
|
||||||
|
|
||||||
await call.message.edit_text(
|
await call.message.edit_text(
|
||||||
"Menu Callback Unverified Text",
|
"Message Info Verification Text",
|
||||||
reply_markup=get_menu_markup(),
|
reply_markup=get_verification_info_markup(),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@unverified_registry.register(
|
||||||
|
triggers="verification_attempt",
|
||||||
|
chat_types=ChatType.PRIVATE,
|
||||||
|
description="Callback For Attempt Verification Description",
|
||||||
|
is_callback=True,
|
||||||
|
)
|
||||||
|
async def call_attempt_verification(
|
||||||
|
call: CallbackQuery,
|
||||||
|
session: AsyncSession,
|
||||||
|
telegram_user: TelegramUser,
|
||||||
|
) -> None:
|
||||||
|
if not isinstance(call.message, Message):
|
||||||
|
return
|
||||||
|
|
||||||
|
status = await verify_student(
|
||||||
|
tg_user=telegram_user,
|
||||||
|
name="DON'T FORGET TO REPLACE THIS STUPID BULLSHIT TEMPLATE",
|
||||||
|
student_id=12302,
|
||||||
|
group_id="abc",
|
||||||
|
session=session,
|
||||||
|
)
|
||||||
|
|
||||||
|
if status == VerificationStatus.SUCCESSFULLY_BOUND:
|
||||||
|
await call.message.edit_text(
|
||||||
|
"Sucessfully!",
|
||||||
|
reply_markup=None,
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
await call.message.edit_text(
|
||||||
|
f"Error: {status}",
|
||||||
|
reply_markup=get_start_verification_markup(),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
from aiogram.types import Message
|
from aiogram.types import Message
|
||||||
|
|
||||||
from bot.handlers import unverified_registry
|
from bot.handlers import unverified_registry
|
||||||
from bot.utils.keyboards import get_menu_markup
|
from bot.utils.keyboards import get_start_verification_markup
|
||||||
from bot.utils.types import ChatType
|
from bot.utils.types import ChatType
|
||||||
|
|
||||||
|
|
||||||
@unverified_registry.register(
|
@unverified_registry.register(
|
||||||
chat_types=ChatType.PRIVATE,
|
chat_types=ChatType.PRIVATE,
|
||||||
description="Menu Message Unverified Description",
|
description="Message For Start Verification Description",
|
||||||
)
|
)
|
||||||
async def cmd_menu(message: Message) -> None:
|
async def msg_start_verification(message: Message) -> None:
|
||||||
await message.answer(
|
await message.answer(
|
||||||
"Menu Message Unverified Text",
|
"Message For Start Verification Text",
|
||||||
reply_markup=get_menu_markup(),
|
reply_markup=get_start_verification_markup(),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
__all__ = ["get_menu_markup"]
|
__all__ = [
|
||||||
|
"get_start_verification_markup",
|
||||||
|
"get_verification_info_markup",
|
||||||
|
"get_menu_markup",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
from aiogram.utils.keyboard import (
|
from aiogram.utils.keyboard import (
|
||||||
|
|
@ -8,6 +12,45 @@ from aiogram.utils.keyboard import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_start_verification_markup() -> InlineKeyboardMarkup:
|
||||||
|
"""
|
||||||
|
Reply markup for the bot verification start menu.
|
||||||
|
"""
|
||||||
|
builder = InlineKeyboardBuilder()
|
||||||
|
builder.add(
|
||||||
|
InlineKeyboardButton(
|
||||||
|
text="Start Verification",
|
||||||
|
callback_data="verification_start",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return builder.as_markup()
|
||||||
|
|
||||||
|
|
||||||
|
def get_verification_info_markup() -> InlineKeyboardMarkup:
|
||||||
|
builder = InlineKeyboardBuilder()
|
||||||
|
builder.add(
|
||||||
|
InlineKeyboardButton(
|
||||||
|
text="Full name",
|
||||||
|
callback_data="verification_change_full_name",
|
||||||
|
),
|
||||||
|
InlineKeyboardButton(
|
||||||
|
text="Student ID",
|
||||||
|
callback_data="verification_change_student_id",
|
||||||
|
),
|
||||||
|
InlineKeyboardButton(
|
||||||
|
text="Group ID",
|
||||||
|
callback_data="verification_change_group_id",
|
||||||
|
),
|
||||||
|
InlineKeyboardButton(
|
||||||
|
text="Verify attempt",
|
||||||
|
callback_data="verification_attempt",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
builder.adjust(1)
|
||||||
|
|
||||||
|
return builder.as_markup()
|
||||||
|
|
||||||
|
|
||||||
def get_menu_markup() -> InlineKeyboardMarkup:
|
def get_menu_markup() -> InlineKeyboardMarkup:
|
||||||
"""
|
"""
|
||||||
Reply markup for the bot callback menu & message menu.
|
Reply markup for the bot callback menu & message menu.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue