Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion 1 telegram/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1835,7 +1835,6 @@ class MessageLimit(IntEnum):
:paramref:`~telegram.Bot.edit_message_text.text` parameter of
:meth:`telegram.Bot.edit_message_text`.
"""
# TODO this constant is not used. helpers.py contains 64 as a number
DEEP_LINK_LENGTH = 64
""":obj:`int`: Maximum number of characters for a deep link."""
# TODO this constant is not used anywhere
Expand Down
11 changes: 7 additions & 4 deletions 11 telegram/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from typing import TYPE_CHECKING, Optional, Union

from telegram._utils.types import MarkdownVersion
from telegram.constants import MessageType
from telegram.constants import MessageLimit, MessageType

if TYPE_CHECKING:
from telegram import Message, Update
Expand Down Expand Up @@ -173,7 +173,8 @@ def create_deep_linked_url(
:obj:`str`: An URL to start the bot with specific parameters.

Raises:
:exc:`ValueError`: If the length of the :paramref:`payload` exceeds 64 characters,
:exc:`ValueError`: If the length of the :paramref:`payload` exceeds \
:tg-const:`telegram.constants.MessageLimit.DEEP_LINK_LENGTH` characters,
contains invalid characters, or if the :paramref:`bot_username` is less than 4
characters.
"""
Expand All @@ -184,8 +185,10 @@ def create_deep_linked_url(
if not payload:
return base_url

if len(payload) > 64:
raise ValueError("The deep-linking payload must not exceed 64 characters.")
if len(payload) > MessageLimit.DEEP_LINK_LENGTH:
raise ValueError(
f"The deep-linking payload must not exceed {MessageLimit.DEEP_LINK_LENGTH} characters."
)

if not re.match(r"^[A-Za-z0-9_-]+$", payload):
raise ValueError(
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.