feat: add DISPLAY_NAME_RESTRICTION_ENABLED toggle
Allows disabling the display name restriction middleware via .env. Users with special characters in their Telegram name (e.g. "@") were blocked from using the bot entirely. Default: true (enabled). Set DISPLAY_NAME_RESTRICTION_ENABLED=false to disable.
This commit is contained in:
@@ -436,6 +436,7 @@ class Settings(BaseSettings):
|
|||||||
MULENPAY_LANGUAGE: str = 'ru'
|
MULENPAY_LANGUAGE: str = 'ru'
|
||||||
MULENPAY_VAT_CODE: int = 0
|
MULENPAY_VAT_CODE: int = 0
|
||||||
|
|
||||||
|
DISPLAY_NAME_RESTRICTION_ENABLED: bool = True
|
||||||
DISPLAY_NAME_BANNED_KEYWORDS: str = '\n'.join(DEFAULT_DISPLAY_NAME_BANNED_KEYWORDS)
|
DISPLAY_NAME_BANNED_KEYWORDS: str = '\n'.join(DEFAULT_DISPLAY_NAME_BANNED_KEYWORDS)
|
||||||
MULENPAY_PAYMENT_SUBJECT: int = 4
|
MULENPAY_PAYMENT_SUBJECT: int = 4
|
||||||
MULENPAY_PAYMENT_MODE: int = 4
|
MULENPAY_PAYMENT_MODE: int = 4
|
||||||
|
|||||||
@@ -85,6 +85,9 @@ class DisplayNameRestrictionMiddleware(BaseMiddleware):
|
|||||||
if not user or user.is_bot:
|
if not user or user.is_bot:
|
||||||
return await handler(event, data)
|
return await handler(event, data)
|
||||||
|
|
||||||
|
if not settings.DISPLAY_NAME_RESTRICTION_ENABLED:
|
||||||
|
return await handler(event, data)
|
||||||
|
|
||||||
display_name = self._build_display_name(user)
|
display_name = self._build_display_name(user)
|
||||||
username = user.username or ''
|
username = user.username or ''
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user