Thanks to visit codestin.com
Credit goes to github.com

Skip to content

API 7.6 - ChatFullInfo.can_send_paid_media #4344

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2024
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
11 changes: 11 additions & 0 deletions telegram/_chatfullinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ class ChatFullInfo(_ChatBase):
chats.
location (:class:`telegram.ChatLocation`, optional): For supergroups, the location to which
the supergroup is connected.
can_send_paid_media (:obj:`bool`, optional): :obj:`True`, if paid media messages can be
sent or forwarded to the channel chat. The field is available only for channel chats.

.. versionadded:: NEXT.VERSION

Attributes:
id (:obj:`int`): Unique identifier for this chat.
Expand Down Expand Up @@ -345,6 +349,10 @@ class ChatFullInfo(_ChatBase):
chats.
location (:class:`telegram.ChatLocation`): Optional. For supergroups, the location to which
the supergroup is connected.
can_send_paid_media (:obj:`bool`): Optional. :obj:`True`, if paid media messages can be
sent or forwarded to the channel chat. The field is available only for channel chats.

.. versionadded:: NEXT.VERSION

.. _accent colors: https://core.telegram.org/bots/api#accent-colors
.. _topics: https://telegram.org/blog/topics-in-groups-collectible-usernames#topics-in-groups
Expand All @@ -360,6 +368,7 @@ class ChatFullInfo(_ChatBase):
"business_intro",
"business_location",
"business_opening_hours",
"can_send_paid_media",
"can_set_sticker_set",
"custom_emoji_sticker_set_name",
"description",
Expand Down Expand Up @@ -434,6 +443,7 @@ def __init__(
custom_emoji_sticker_set_name: Optional[str] = None,
linked_chat_id: Optional[int] = None,
location: Optional[ChatLocation] = None,
can_send_paid_media: Optional[bool] = None,
*,
api_kwargs: Optional[JSONDict] = None,
):
Expand Down Expand Up @@ -496,6 +506,7 @@ def __init__(
self.business_intro: Optional[BusinessIntro] = business_intro
self.business_location: Optional[BusinessLocation] = business_location
self.business_opening_hours: Optional[BusinessOpeningHours] = business_opening_hours
self.can_send_paid_media: Optional[bool] = can_send_paid_media

@classmethod
def de_json(
Expand Down
27 changes: 17 additions & 10 deletions tests/test_chatfullinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ def chat_full_info(bot):
bio=TestChatFullInfoBase.bio,
linked_chat_id=TestChatFullInfoBase.linked_chat_id,
location=TestChatFullInfoBase.location,
has_private_forwards=True,
has_protected_content=True,
has_visible_history=True,
join_to_send_messages=True,
join_by_request=True,
has_restricted_voice_and_video_messages=True,
is_forum=True,
has_private_forwards=TestChatFullInfoBase.has_private_forwards,
has_protected_content=TestChatFullInfoBase.has_protected_content,
has_visible_history=TestChatFullInfoBase.has_visible_history,
join_to_send_messages=TestChatFullInfoBase.join_to_send_messages,
join_by_request=TestChatFullInfoBase.join_by_request,
has_restricted_voice_and_video_messages=(
TestChatFullInfoBase.has_restricted_voice_and_video_messages
),
is_forum=TestChatFullInfoBase.is_forum,
active_usernames=TestChatFullInfoBase.active_usernames,
emoji_status_custom_emoji_id=TestChatFullInfoBase.emoji_status_custom_emoji_id,
emoji_status_expiration_date=TestChatFullInfoBase.emoji_status_expiration_date,
Expand All @@ -76,10 +78,11 @@ def chat_full_info(bot):
business_intro=TestChatFullInfoBase.business_intro,
business_location=TestChatFullInfoBase.business_location,
business_opening_hours=TestChatFullInfoBase.business_opening_hours,
birthdate=Birthdate(1, 1),
birthdate=TestChatFullInfoBase.birthdate,
personal_chat=TestChatFullInfoBase.personal_chat,
first_name="first_name",
last_name="last_name",
first_name=TestChatFullInfoBase.first_name,
last_name=TestChatFullInfoBase.last_name,
can_send_paid_media=TestChatFullInfoBase.can_send_paid_media,
)
chat.set_bot(bot)
chat._unfreeze()
Expand Down Expand Up @@ -136,6 +139,7 @@ class TestChatFullInfoBase:
personal_chat = Chat(3, "private", "private")
first_name = "first_name"
last_name = "last_name"
can_send_paid_media = True


class TestChatFullInfoWithoutRequest(TestChatFullInfoBase):
Expand Down Expand Up @@ -188,6 +192,7 @@ def test_de_json(self, bot):
"personal_chat": self.personal_chat.to_dict(),
"first_name": self.first_name,
"last_name": self.last_name,
"can_send_paid_media": self.can_send_paid_media,
}
cfi = ChatFullInfo.de_json(json_dict, bot)
assert cfi.id == self.id_
Expand Down Expand Up @@ -232,6 +237,7 @@ def test_de_json(self, bot):
assert cfi.first_name == self.first_name
assert cfi.last_name == self.last_name
assert cfi.max_reaction_count == self.max_reaction_count
assert cfi.can_send_paid_media == self.can_send_paid_media

def test_de_json_localization(self, bot, raw_bot, tz_bot):
json_dict = {
Expand Down Expand Up @@ -305,6 +311,7 @@ def test_to_dict(self, chat_full_info):
assert cfi_dict["personal_chat"] == cfi.personal_chat.to_dict()
assert cfi_dict["first_name"] == cfi.first_name
assert cfi_dict["last_name"] == cfi.last_name
assert cfi_dict["can_send_paid_media"] == cfi.can_send_paid_media

assert cfi_dict["max_reaction_count"] == cfi.max_reaction_count

Expand Down
Loading