def METHOD_NAME(
    username: str,
    link_type: Literal["start", "startgroup"],
    payload: str,
    encode: bool = False,
    encoder: Optional[Callable[[bytes], bytes]] = None,
) -> str:
    """
    Create deep link.
    :param username:
    :param link_type: `start` or `startgroup`
    :param payload: any string-convertible data
    :param encode: encode payload with base64url or custom encoder
    :param encoder: custom encoder callable
    :return: deeplink
    """
    if not isinstance(payload, str):
        payload = str(payload)
    if encode or encoder:
        payload = encode_payload(payload, encoder=encoder)
    if re.search(BAD_PATTERN, payload):
        raise ValueError(
            "Wrong payload! Only A-Z, a-z, 0-9, _ and - are allowed. "
            "Pass `encode=True` or encode payload manually."
        )
    if len(payload) > 64:
        raise ValueError("Payload must be up to 64 characters long.")
    return create_telegram_link(username, **{cast(str, link_type): payload})