docs: def parse_username(username):
      """
      Parses the given username or channel access hash, given
      a string, username or URL. Returns a tuple consisting of
      both the stripped, lowercase username and whether it is
      a joinchat/ hash (in which case is not lowercase'd).
  
      Returns ``(None, False)`` if the ``username`` or link is not valid.
      """
      username = username.strip()
      m = USERNAME_RE.match(username) or TG_JOIN_RE.match(username)
      if m:
          username = username[m.end():]
          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
      else:
          return None, False