Remove Telegram URL prefix when finding a user by username
This commit is contained in:
@@ -55,7 +55,8 @@ async def prompt_username(callback_query: CallbackQuery, state: FSMContext):
|
||||
async def handle_username_input(
|
||||
message: types.Message, state: FSMContext, session: Any
|
||||
):
|
||||
username = message.text.strip().lstrip("@")
|
||||
# Extract the username from a message text by removing leading '@' and the Telegram URL prefix
|
||||
username = message.text.strip().lstrip('@').replace('https://t.me/', '')
|
||||
user_record = await session.fetchrow(
|
||||
"SELECT tg_id FROM users WHERE username = $1", username
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user