Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Start using MessageLimit.DEEP_LINK_LENGTH constant#4597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall 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 deletiontelegram/constants.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionstelegram/helpers.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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 importMessageLimit,MessageType

if TYPE_CHECKING:
from telegram import Message, Update
Expand DownExpand 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

[8]ページ先頭

©2009-2025 Movatter.jp