1.1.6 Улучшен валидатор username и добавлен валидатор нормального вида слов

This commit is contained in:
Verum
2025-02-25 16:59:25 +07:00
parent c2ba5b147d
commit a1f7647ba8
3 changed files with 7 additions and 1 deletions

View File

@@ -5,3 +5,4 @@
from .email_valid import * from .email_valid import *
from .username import * from .username import *
from .url_valid import * from .url_valid import *
from .normal_word import *

View File

@@ -0,0 +1,5 @@
# BotLibrary/validators/normal_word.py
# Нормализирует вид слова автоматически
async def normal_words(word : str = "Тестовое слово") -> str:
return word.lower().capitalize()

View File

@@ -15,5 +15,5 @@ def username(message: Message) -> str:
:return: Строка с юзернеймом пользователя или его ID. :return: Строка с юзернеймом пользователя или его ID.
""" """
if message.from_user: if message.from_user:
return f"@{message.from_user.username}" if message.from_user.username else str(message.from_user.id) return f"@{message.from_user.username}" if message.from_user.username else f"@{message.from_user.id}"
return "@Unknown_User" # Если from_user отсутствует return "@Unknown_User" # Если from_user отсутствует