From 359cdcd77282b73c9a1f844dde2a718e06cc8cad Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 22 Feb 2018 10:27:12 +0100 Subject: [PATCH] Handle more parsing username cases (closes #630) --- telethon/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/telethon/utils.py b/telethon/utils.py index 607897e4..fdadbd1c 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -27,7 +27,7 @@ from .tl.types import ( from .tl.types.contacts import ResolvedPeer 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]$') @@ -366,6 +366,8 @@ def parse_username(username): is_invite = bool(m.group(1)) if is_invite: return username, True + else: + username = username.rstrip('/') if VALID_USERNAME_RE.match(username): return username.lower(), False