mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-29 12:53:44 +03:00
Handle more parsing username cases (closes #630)
This commit is contained in:
parent
7f35ed59c6
commit
359cdcd772
|
@ -27,7 +27,7 @@ from .tl.types import (
|
||||||
from .tl.types.contacts import ResolvedPeer
|
from .tl.types.contacts import ResolvedPeer
|
||||||
|
|
||||||
USERNAME_RE = re.compile(
|
USERNAME_RE = re.compile(
|
||||||
r'@|(?:https?://)?(?:telegram\.(?:me|dog)|t\.me)/(joinchat/)?'
|
r'@|(?:https?://)?(?:www\.)?(?:telegram\.(?:me|dog)|t\.me)/(joinchat/)?'
|
||||||
)
|
)
|
||||||
|
|
||||||
VALID_USERNAME_RE = re.compile(r'^[a-zA-Z][\w\d]{3,30}[a-zA-Z\d]$')
|
VALID_USERNAME_RE = re.compile(r'^[a-zA-Z][\w\d]{3,30}[a-zA-Z\d]$')
|
||||||
|
@ -366,6 +366,8 @@ def parse_username(username):
|
||||||
is_invite = bool(m.group(1))
|
is_invite = bool(m.group(1))
|
||||||
if is_invite:
|
if is_invite:
|
||||||
return username, True
|
return username, True
|
||||||
|
else:
|
||||||
|
username = username.rstrip('/')
|
||||||
|
|
||||||
if VALID_USERNAME_RE.match(username):
|
if VALID_USERNAME_RE.match(username):
|
||||||
return username.lower(), False
|
return username.lower(), False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user