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

Api 9.0 general#4782

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
Bibo-Joshi merged 8 commits intoapi_9.0fromapi_9.0-general
May 6, 2025
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
4 changes: 4 additions & 0 deletionschanges/unreleased/4756.JT5nmUmGRG6qDEh5ScMn5f.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,3 +36,7 @@ closes_threads = []
uid = "4773"
author_uid = "aelkheir"
closes_threads = []
[[pull_requests]]
uid = "4782"
author_uid = "Bibo-Joshi"
closes_threads = []
1 change: 1 addition & 0 deletionsdocs/source/telegram.at-tree.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -136,6 +136,7 @@ Available Types
telegram.paidmediapreview
telegram.paidmediapurchased
telegram.paidmediavideo
telegram.paidmessagepricechanged
telegram.photosize
telegram.poll
telegram.pollanswer
Expand Down
6 changes: 6 additions & 0 deletionsdocs/source/telegram.paidmeessagepricechanged.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
PaidMessagePriceChanged
=======================

.. autoclass:: telegram.PaidMessagePriceChanged
:members:
:show-inheritance:
2 changes: 2 additions & 0 deletionstelegram/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -200,6 +200,7 @@
"PaidMediaPreview",
"PaidMediaPurchased",
"PaidMediaVideo",
"PaidMessagePriceChanged",
"PassportData",
"PassportElementError",
"PassportElementErrorDataField",
Expand DownExpand Up@@ -493,6 +494,7 @@
PaidMediaPurchased,
PaidMediaVideo,
)
from ._paidmessagepricechanged import PaidMessagePriceChanged
from ._passport.credentials import (
Credentials,
DataCredentials,
Expand Down
28 changes: 28 additions & 0 deletionstelegram/_message.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,6 +55,7 @@
from telegram._messageautodeletetimerchanged import MessageAutoDeleteTimerChanged
from telegram._messageentity import MessageEntity
from telegram._paidmedia import PaidMediaInfo
from telegram._paidmessagepricechanged import PaidMessagePriceChanged
from telegram._passport.passportdata import PassportData
from telegram._payment.invoice import Invoice
from telegram._payment.refundedpayment import RefundedPayment
Expand DownExpand Up@@ -445,6 +446,10 @@ class Message(MaybeInaccessibleMessage):
`More about Telegram Login >> <https://core.telegram.org/widgets/login>`_.
author_signature (:obj:`str`, optional): Signature of the post author for messages in
channels, or the custom title of an anonymous group administrator.
paid_star_count (:obj:`int`, optional): The number of Telegram Stars that were paid by the
sender of the message to send it

.. versionadded:: NEXT.VERSION
passport_data (:class:`telegram.PassportData`, optional): Telegram Passport data.
poll (:class:`telegram.Poll`, optional): Message is a native poll,
information about the poll.
Expand DownExpand Up@@ -551,6 +556,10 @@ class Message(MaybeInaccessibleMessage):
giveaway without public winners was completed

.. versionadded:: 20.8
paid_message_price_changed (:class:`telegram.PaidMessagePriceChanged`, optional): Service
message: the price for paid messages has changed in the chat

.. versionadded:: NEXT.VERSION
external_reply (:class:`telegram.ExternalReplyInfo`, optional): Information about the
message that is being replied to, which may come from another chat or forum topic.

Expand DownExpand Up@@ -781,6 +790,10 @@ class Message(MaybeInaccessibleMessage):
`More about Telegram Login >> <https://core.telegram.org/widgets/login>`_.
author_signature (:obj:`str`): Optional. Signature of the post author for messages in
channels, or the custom title of an anonymous group administrator.
paid_star_count (:obj:`int`): Optional. The number of Telegram Stars that were paid by the
sender of the message to send it

.. versionadded:: NEXT.VERSION
passport_data (:class:`telegram.PassportData`): Optional. Telegram Passport data.

Examples:
Expand DownExpand Up@@ -887,6 +900,10 @@ class Message(MaybeInaccessibleMessage):
giveaway without public winners was completed

.. versionadded:: 20.8
paid_message_price_changed (:class:`telegram.PaidMessagePriceChanged`): Optional. Service
message: the price for paid messages has changed in the chat

.. versionadded:: NEXT.VERSION
external_reply (:class:`telegram.ExternalReplyInfo`): Optional. Information about the
message that is being replied to, which may come from another chat or forum topic.

Expand DownExpand Up@@ -1008,6 +1025,8 @@ class Message(MaybeInaccessibleMessage):
"new_chat_photo",
"new_chat_title",
"paid_media",
"paid_message_price_changed",
"paid_star_count",
"passport_data",
"photo",
"pinned_message",
Expand DownExpand Up@@ -1131,6 +1150,8 @@ def __init__(
refunded_payment: Optional[RefundedPayment] = None,
gift: Optional[GiftInfo] = None,
unique_gift: Optional[UniqueGiftInfo] = None,
paid_message_price_changed: Optional[PaidMessagePriceChanged] = None,
paid_star_count: Optional[int] = None,
*,
api_kwargs: Optional[JSONDict] = None,
):
Expand DownExpand Up@@ -1236,6 +1257,10 @@ def __init__(
self.refunded_payment: Optional[RefundedPayment] = refunded_payment
self.gift: Optional[GiftInfo] = gift
self.unique_gift: Optional[UniqueGiftInfo] = unique_gift
self.paid_message_price_changed: Optional[PaidMessagePriceChanged] = (
paid_message_price_changed
)
self.paid_star_count: Optional[int] = paid_star_count

self._effective_attachment = DEFAULT_NONE

Expand DownExpand Up@@ -1372,6 +1397,9 @@ def de_json(cls, data: JSONDict, bot: Optional["Bot"] = None) -> "Message":
)
data["gift"] = de_json_optional(data.get("gift"), GiftInfo, bot)
data["unique_gift"] = de_json_optional(data.get("unique_gift"), UniqueGiftInfo, bot)
data["paid_message_price_changed"] = de_json_optional(
data.get("paid_message_price_changed"), PaidMessagePriceChanged, bot
)

# Unfortunately, this needs to be here due to cyclic imports
from telegram._giveaway import ( # pylint: disable=import-outside-toplevel
Expand Down
55 changes: 55 additions & 0 deletionstelegram/_paidmessagepricechanged.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env python
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2025
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser Public License for more details.
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that describes a price change of a paid message."""
from typing import Optional

from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict


class PaidMessagePriceChanged(TelegramObject):
"""Describes a service message about a change in the price of paid messages within a chat.

Objects of this class are comparable in terms of equality. Two objects of this class are
considered equal, if their :attr:`paid_message_star_count` is equal.

.. versionadded:: NEXT.VERSION

Args:
paid_message_star_count (:obj:`int`): The new number of Telegram Stars that must be paid by
non-administrator users of the supergroup chat for each sent message

Attributes:
paid_message_star_count (:obj:`int`): The new number of Telegram Stars that must be paid by
non-administrator users of the supergroup chat for each sent message
"""

__slots__ = ("paid_message_star_count",)

def __init__(
self,
paid_message_star_count: int,
*,
api_kwargs: Optional[JSONDict] = None,
) -> None:
super().__init__(api_kwargs=api_kwargs)
self.paid_message_star_count: int = paid_message_star_count

self._id_attrs = (self.paid_message_star_count,)
self._freeze()
21 changes: 17 additions & 4 deletionstelegram/constants.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -956,8 +956,12 @@ class ChatSubscriptionLimit(IntEnum):
""":obj:`int`: The number of seconds the subscription will be active."""
MIN_PRICE = 1
""":obj:`int`: Amount of stars a user pays, minimum amount the subscription can be set to."""
MAX_PRICE = 2500
""":obj:`int`: Amount of stars a user pays, maximum amount the subscription can be set to."""
MAX_PRICE = 10000
""":obj:`int`: Amount of stars a user pays, maximum amount the subscription can be set to.

.. versionchanged:: NEXT.VERSION
Bot API 9.0 changed the value to 10000.
"""


class BackgroundTypeLimit(IntEnum):
Expand DownExpand Up@@ -2143,6 +2147,11 @@ class MessageType(StringEnum):

.. versionadded:: 21.4
"""
PAID_MESSAGE_PRICE_CHANGED = "paid_message_price_changed"
""":obj:`str`: Messages with :attr:`telegram.Message.paid_message_price_changed`.

.. versionadded:: Next.VERSION
"""
PASSPORT_DATA = "passport_data"
""":obj:`str`: Messages with :attr:`telegram.Message.passport_data`."""
PHOTO = "photo"
Expand DownExpand Up@@ -3288,12 +3297,14 @@ class InvoiceLimit(IntEnum):

.. versionadded:: 21.6
"""
MAX_STAR_COUNT =2500
MAX_STAR_COUNT =10000
""":obj:`int`: Maximum amount of starts that must be paid to buy access to a paid media
passed as :paramref:`~telegram.Bot.send_paid_media.star_count` parameter of
:meth:`telegram.Bot.send_paid_media`.

.. versionadded:: 21.6
.. versionchanged:: NEXT.VERSION
Bot API 9.0 changed the value to 10000.
"""
SUBSCRIPTION_PERIOD = dtm.timedelta(days=30).total_seconds()
""":obj:`int`: The period of time for which the subscription is active before
Expand All@@ -3302,11 +3313,13 @@ class InvoiceLimit(IntEnum):

.. versionadded:: 21.8
"""
SUBSCRIPTION_MAX_PRICE =2500
SUBSCRIPTION_MAX_PRICE =10000
""":obj:`int`: The maximum price of a subscription created wtih
:meth:`telegram.Bot.create_invoice_link`.

.. versionadded:: 21.9
.. versionchanged:: NEXT.VERSION
Bot API 9.0 changed the value to 10000.
"""


Expand Down
15 changes: 15 additions & 0 deletionstelegram/ext/filters.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1935,6 +1935,7 @@ def filter(self, update: Update) -> bool:
or StatusUpdate.NEW_CHAT_MEMBERS.check_update(update)
or StatusUpdate.NEW_CHAT_PHOTO.check_update(update)
or StatusUpdate.NEW_CHAT_TITLE.check_update(update)
or StatusUpdate.PAID_MESSAGE_PRICE_CHANGED.check_update(update)
or StatusUpdate.PINNED_MESSAGE.check_update(update)
or StatusUpdate.PROXIMITY_ALERT_TRIGGERED.check_update(update)
or StatusUpdate.REFUNDED_PAYMENT.check_update(update)
Expand DownExpand Up@@ -2176,6 +2177,20 @@ def filter(self, message: Message) -> bool:
NEW_CHAT_TITLE = _NewChatTitle(name="filters.StatusUpdate.NEW_CHAT_TITLE")
"""Messages that contain :attr:`telegram.Message.new_chat_title`."""

class _PaidMessagePriceChanged(MessageFilter):
__slots__ = ()

def filter(self, message: Message) -> bool:
return bool(message.paid_message_price_changed)

PAID_MESSAGE_PRICE_CHANGED = _PaidMessagePriceChanged(
name="filters.StatusUpdate.PAID_MESSAGE_PRICE_CHANGED"
)
"""Messages that contain :attr:`telegram.Message.paid_message_price_changed`.

.. versionadded:: NEXT.VERSION
"""

class _PinnedMessage(MessageFilter):
__slots__ = ()

Expand Down
5 changes: 5 additions & 0 deletionstests/ext/test_filters.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1108,6 +1108,11 @@ def test_filters_status_update(self, update):
assert filters.StatusUpdate.UNIQUE_GIFT.check_update(update)
update.message.unique_gift = None

update.message.paid_message_price_changed = "paid_message_price_changed"
assert filters.StatusUpdate.ALL.check_update(update)
assert filters.StatusUpdate.PAID_MESSAGE_PRICE_CHANGED.check_update(update)
update.message.paid_message_price_changed = None

def test_filters_forwarded(self, update, message_origin_user):
assert filters.FORWARDED.check_update(update)
update.message.forward_origin = MessageOriginHiddenUser(dtm.datetime.utcnow(), 1)
Expand Down
1 change: 1 addition & 0 deletionstests/test_constants.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -203,6 +203,7 @@ def is_type_attribute(name: str) -> bool:
"via_bot",
"is_from_offline",
"show_caption_above_media",
"paid_star_count",
}

@pytest.mark.parametrize(
Expand Down
5 changes: 5 additions & 0 deletionstests/test_message.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -50,6 +50,7 @@
MessageOriginChat,
PaidMediaInfo,
PaidMediaPreview,
PaidMessagePriceChanged,
PassportData,
PhotoSize,
Poll,
Expand DownExpand Up@@ -328,6 +329,8 @@ def message(bot):
{"show_caption_above_media": True},
{"paid_media": PaidMediaInfo(5, [PaidMediaPreview(10, 10, 10)])},
{"refunded_payment": RefundedPayment("EUR", 243, "payload", "charge_id", "provider_id")},
{"paid_star_count": 291},
{"paid_message_price_changed": PaidMessagePriceChanged(291)},
],
ids=[
"reply",
Expand DownExpand Up@@ -403,6 +406,8 @@ def message(bot):
"show_caption_above_media",
"paid_media",
"refunded_payment",
"paid_star_count",
"paid_message_price_changed",
],
)
def message_params(bot, request):
Expand Down
70 changes: 70 additions & 0 deletionstests/test_paidmessagepricechanged.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env python
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2025
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser Public License for more details.
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].

import pytest

from telegram import Dice, PaidMessagePriceChanged
from tests.auxil.slots import mro_slots


class PaidMessagePriceChangedTestBase:
paid_message_star_count = 291


@pytest.fixture(scope="module")
def paid_message_price_changed():
return PaidMessagePriceChanged(PaidMessagePriceChangedTestBase.paid_message_star_count)


class TestPaidMessagePriceChangedWithoutRequest(PaidMessagePriceChangedTestBase):
def test_slot_behaviour(self, paid_message_price_changed):
for attr in paid_message_price_changed.__slots__:
assert (
getattr(paid_message_price_changed, attr, "err") != "err"
), f"got extra slot '{attr}'"
assert len(mro_slots(paid_message_price_changed)) == len(
set(mro_slots(paid_message_price_changed))
), "duplicate slot"

def test_to_dict(self, paid_message_price_changed):
pmpc_dict = paid_message_price_changed.to_dict()
assert isinstance(pmpc_dict, dict)
assert pmpc_dict["paid_message_star_count"] == self.paid_message_star_count

def test_de_json(self, offline_bot):
json_dict = {"paid_message_star_count": self.paid_message_star_count}
pmpc = PaidMessagePriceChanged.de_json(json_dict, offline_bot)
assert isinstance(pmpc, PaidMessagePriceChanged)
assert pmpc.paid_message_star_count == self.paid_message_star_count
assert pmpc.api_kwargs == {}

def test_equality(self):
pmpc1 = PaidMessagePriceChanged(self.paid_message_star_count)
pmpc2 = PaidMessagePriceChanged(self.paid_message_star_count)
pmpc3 = PaidMessagePriceChanged(3)
dice = Dice(5, "emoji")

assert pmpc1 == pmpc2
assert hash(pmpc1) == hash(pmpc2)

assert pmpc1 != pmpc3
assert hash(pmpc1) != hash(pmpc3)

assert pmpc1 != dice
assert hash(pmpc1) != hash(dice)
Loading

[8]ページ先頭

©2009-2025 Movatter.jp