From 4dafb745da3f8960ef6903b1b41e2f4ee2a3c6fe Mon Sep 17 00:00:00 2001 From: Erfan Date: Tue, 5 Nov 2024 01:37:25 +0330 Subject: [PATCH] improve: add copy text button --- requirements.txt | 2 +- routers/user.py | 1 + utils/keys.py | 14 ++++++++++++-- utils/lang.py | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index bad9087..71ee103 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -aiogram==3.10.0 +aiogram==3.14.0 python-decouple==3.8 SQLAlchemy==2.0.31 pydantic==2.8.2 diff --git a/routers/user.py b/routers/user.py index 0b854c1..d04624f 100644 --- a/routers/user.py +++ b/routers/user.py @@ -219,6 +219,7 @@ async def user_create_inbounds_save(callback: CallbackQuery, state: FSMContext): await callback.message.answer_photo( caption=text_info.user_info(new_user), photo=BufferedInputFile(qr_bytes, filename="qr_code.png"), + reply_markup=BotKeyboards.user(new_user) ) else: await callback.message.answer( diff --git a/utils/keys.py b/utils/keys.py index 1509600..3b06013 100644 --- a/utils/keys.py +++ b/utils/keys.py @@ -1,7 +1,7 @@ -from aiogram.types import InlineKeyboardMarkup +from aiogram.types import InlineKeyboardMarkup, CopyTextButton from aiogram.utils.keyboard import InlineKeyboardBuilder, InlineKeyboardButton -from marzban import ProxyInbound, Admin +from marzban import ProxyInbound, Admin, UserResponse from utils.lang import KeyboardTexts from models import ( @@ -172,3 +172,13 @@ def users() -> InlineKeyboardMarkup: ), ) return kb.adjust(2).as_markup() + + @staticmethod + def user(user: UserResponse) -> InlineKeyboardMarkup: + kb = InlineKeyboardBuilder() + + kb.button( + text=KeyboardTexts.UserCreateLinkCopy, + copy_text=CopyTextButton(text=user.subscription_url) + ) + return kb.as_markup() \ No newline at end of file diff --git a/utils/lang.py b/utils/lang.py index fbb596d..b7b8b7a 100644 --- a/utils/lang.py +++ b/utils/lang.py @@ -16,7 +16,7 @@ class KeyboardTexts(str, Enum): UsersMenu = "👥 Users" UsersAddInbound = "➕ Add inbound" UsersDeleteInbound = "➖ Delete inbound" - + UserCreateLinkCopy = "To copy the link, please click." class MessageTexts(str, Enum): Start = f"Welcome to HolderBot 🤖 [{VERSION}]\nDeveloped and designed by {OWNER}"