File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -1836,7 +1836,6 @@ class MessageLimit(IntEnum):
1836
1836
:paramref:`~telegram.Bot.edit_message_text.text` parameter of
1837
1837
:meth:`telegram.Bot.edit_message_text`.
1838
1838
"""
1839
- # TODO this constant is not used. helpers.py contains 64 as a number
1840
1839
DEEP_LINK_LENGTH = 64
1841
1840
""":obj:`int`: Maximum number of characters for a deep link."""
1842
1841
# TODO this constant is not used anywhere
Original file line number Diff line number Diff line change 36
36
from typing import TYPE_CHECKING , Optional , Union
37
37
38
38
from telegram ._utils .types import MarkdownVersion
39
- from telegram .constants import MessageType
39
+ from telegram .constants import MessageLimit , MessageType
40
40
41
41
if TYPE_CHECKING :
42
42
from telegram import Message , Update
@@ -173,7 +173,8 @@ def create_deep_linked_url(
173
173
:obj:`str`: An URL to start the bot with specific parameters.
174
174
175
175
Raises:
176
- :exc:`ValueError`: If the length of the :paramref:`payload` exceeds 64 characters,
176
+ :exc:`ValueError`: If the length of the :paramref:`payload` exceeds \
177
+ :tg-const:`telegram.constants.MessageLimit.DEEP_LINK_LENGTH` characters,
177
178
contains invalid characters, or if the :paramref:`bot_username` is less than 4
178
179
characters.
179
180
"""
@@ -184,8 +185,10 @@ def create_deep_linked_url(
184
185
if not payload :
185
186
return base_url
186
187
187
- if len (payload ) > 64 :
188
- raise ValueError ("The deep-linking payload must not exceed 64 characters." )
188
+ if len (payload ) > MessageLimit .DEEP_LINK_LENGTH :
189
+ raise ValueError (
190
+ f"The deep-linking payload must not exceed { MessageLimit .DEEP_LINK_LENGTH } characters."
191
+ )
189
192
190
193
if not re .match (r"^[A-Za-z0-9_-]+$" , payload ):
191
194
raise ValueError (
You can’t perform that action at this time.
0 commit comments