Resolves the given invite link. Returns a tuple of
    ``(link creator user id, global chat id, random int)``.

    Note that for broadcast channels, the link creator
    user ID will be zero to protect their identity.
    Normal chats and megagroup channels will have such ID.

    Note that the chat ID may not be accurate for chats
    with a link that were upgraded to megagroup, since
    the link can remain the same, but the chat ID will
    be correct once a new link is generated.

def resolve_invite_link(link):
    """
    Resolves the given invite link. Returns a tuple of
    ``(link creator user id, global chat id, random int)``.

    Note that for broadcast channels, the link creator
    user ID will be zero to protect their identity.
    Normal chats and megagroup channels will have such ID.

    Note that the chat ID may not be accurate for chats
    with a link that were upgraded to megagroup, since
    the link can remain the same, but the chat ID will
    be correct once a new link is generated.
    """
    link_hash, is_link = parse_username(link)
    if not is_link:
        # Perhaps the user passed the link hash directly
        link_hash = link

    try:
        return struct.unpack('>LLQ', _decode_telegram_base64(link_hash))
    except (struct.error, TypeError):
        return None, None, None