Skip to content

Commit

Permalink
improve: add copy text button
Browse files Browse the repository at this point in the history
  • Loading branch information
erfjab committed Nov 4, 2024
1 parent 1062423 commit 4dafb74
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
aiogram==3.10.0
aiogram==3.14.0
python-decouple==3.8
SQLAlchemy==2.0.31
pydantic==2.8.2
Expand Down
1 change: 1 addition & 0 deletions routers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
14 changes: 12 additions & 2 deletions utils/keys.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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()
2 changes: 1 addition & 1 deletion utils/lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <b>HolderBot</b> 🤖 [{VERSION}]\nDeveloped and designed by <b>{OWNER}</b>"
Expand Down

0 comments on commit 4dafb74

Please sign in to comment.