Remove Telegram URL prefix when finding a user by username

This commit is contained in:
hteppl
2024-12-26 03:36:54 +03:00
parent 729e5ab87a
commit 0df1c98407
+2 -1
View File
@@ -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
)