diff --git a/pyrogram/methods/bots/create_invoice_link.py b/pyrogram/methods/bots/create_invoice_link.py
index 3fc5e8f674..8469ceb823 100644
--- a/pyrogram/methods/bots/create_invoice_link.py
+++ b/pyrogram/methods/bots/create_invoice_link.py
@@ -16,10 +16,11 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+from datetime import datetime
from typing import Union, List, Optional
import pyrogram
-from pyrogram import raw, types
+from pyrogram import utils, raw, types
class CreateInvoiceLink:
@@ -31,6 +32,7 @@ async def create_invoice_link(
currency: str,
prices: List["types.LabeledPrice"],
provider_token: Optional[str] = None,
+ subscription_period: datetime = None,
max_tip_amount: Optional[int] = None,
suggested_tip_amounts: Optional[List[int]] = None,
start_parameter: Optional[str] = None,
@@ -73,6 +75,11 @@ async def create_invoice_link(
provider_token (``str``, *optional*):
Payment provider token, obtained via `@BotFather `_. Pass an empty string for payments in `Telegram Stars `_.
+ subscription_period (:py:obj:`~datetime.datetime`, *optional*):
+ The number of seconds the subscription will be active for before the next payment.
+ The currency must be set to “XTR” (Telegram Stars) if the parameter is used.
+ Currently, it must always be 2592000 (30 days) if specified.
+
max_tip_amount (``int``, *optional*):
The maximum accepted amount for tips in the smallest units of the currency (integer, **not** float/double). For example, for a maximum tip of ``US$ 1.45`` pass ``max_tip_amount = 145``. See the exp parameter in `currencies.json `_, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in `Telegram Stars `_.
@@ -148,7 +155,8 @@ async def create_invoice_link(
phone_to_provider=send_phone_number_to_provider,
email_to_provider=send_email_to_provider,
max_tip_amount=max_tip_amount,
- suggested_tip_amounts=suggested_tip_amounts
+ suggested_tip_amounts=suggested_tip_amounts,
+ subscription_period=utils.datetime_to_timestamp(subscription_period)
),
payload=payload.encode() if isinstance(payload, str) else payload,
provider=provider_token,
diff --git a/pyrogram/methods/messages/forward_messages.py b/pyrogram/methods/messages/forward_messages.py
index fe98f7d2c2..1b874462fa 100644
--- a/pyrogram/methods/messages/forward_messages.py
+++ b/pyrogram/methods/messages/forward_messages.py
@@ -82,7 +82,6 @@ async def forward_messages(
The relevant Stars will be withdrawn from the bot's balance.
For bots only.
-
Returns:
:obj:`~pyrogram.types.Message` | List of :obj:`~pyrogram.types.Message`: In case *message_ids* was not
a list, a single message is returned, otherwise a list of messages is returned.
diff --git a/pyrogram/methods/payments/get_star_gifts.py b/pyrogram/methods/payments/get_star_gifts.py
index 0cfb470c6e..01fec19e22 100644
--- a/pyrogram/methods/payments/get_star_gifts.py
+++ b/pyrogram/methods/payments/get_star_gifts.py
@@ -25,9 +25,9 @@ class GetStarGifts:
async def get_star_gifts(
self: "pyrogram.Client",
) -> List["types.StarGift"]:
- """Get all available star gifts to send.
+ """Get all available star gifts that can be sent to other users.
- .. include:: /_includes/usable-by/users.rst
+ .. include:: /_includes/usable-by/users-bots.rst
Returns:
List of :obj:`~pyrogram.types.StarGift`: On success, a list of star gifts is returned.
diff --git a/pyrogram/methods/payments/send_star_gift.py b/pyrogram/methods/payments/send_star_gift.py
index 06e90792d2..8e9c98ecd3 100644
--- a/pyrogram/methods/payments/send_star_gift.py
+++ b/pyrogram/methods/payments/send_star_gift.py
@@ -59,6 +59,7 @@ async def send_star_gift(
hide_my_name (``bool``, *optional*):
If True, your name will be hidden from visitors to the gift recipient's profile.
+ For userbots only.
Defaults to None.
Returns:
diff --git a/pyrogram/types/messages_and_media/star_gift.py b/pyrogram/types/messages_and_media/star_gift.py
index 4fedd7805f..e9c3debcc8 100644
--- a/pyrogram/types/messages_and_media/star_gift.py
+++ b/pyrogram/types/messages_and_media/star_gift.py
@@ -82,6 +82,10 @@ class StarGift(Object):
is_sold_out (``bool``, *optional*):
True, if the star gift is sold out.
+
+ is_converted (``bool``, *optional*):
+ True, if the gift was converted to Telegram Stars.
+ Only for the receiver of the gift.
"""
def __init__(
@@ -104,7 +108,8 @@ def __init__(
is_limited: Optional[bool] = None,
is_name_hidden: Optional[bool] = None,
is_saved: Optional[bool] = None,
- is_sold_out: Optional[bool] = None
+ is_sold_out: Optional[bool] = None,
+ is_converted: Optional[bool] = None
):
super().__init__(client)
@@ -125,6 +130,7 @@ def __init__(
self.is_name_hidden = is_name_hidden
self.is_saved = is_saved
self.is_sold_out = is_sold_out
+ self.is_converted = is_converted
@staticmethod
async def _parse(
@@ -187,7 +193,7 @@ async def _parse_action(
message: "raw.base.Message",
users: dict
) -> "StarGift":
- action = message.action
+ action = message.action # type: raw.types.MessageActionStarGift
doc = action.gift.sticker
attributes = {type(i): i for i in doc.attributes}
@@ -209,6 +215,7 @@ async def _parse_action(
is_limited=getattr(action.gift, "limited", None),
is_name_hidden=getattr(action, "name_hidden", None),
is_saved=getattr(action, "saved", None),
+ is_converted=getattr(action, "converted", None),
from_user=types.User._parse(client, users.get(utils.get_raw_peer_id(message.peer_id))),
message_id=message.id,
caption=caption,
diff --git a/pyrogram/types/messages_and_media/successful_payment.py b/pyrogram/types/messages_and_media/successful_payment.py
index 90ae415acf..14c29671d7 100644
--- a/pyrogram/types/messages_and_media/successful_payment.py
+++ b/pyrogram/types/messages_and_media/successful_payment.py
@@ -16,8 +16,10 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+from datetime import datetime
from typing import Union, Optional
+from pyrogram import utils
from pyrogram import raw
from pyrogram import types
from ..object import Object
@@ -49,13 +51,16 @@ class SuccessfulPayment(Object):
Payment information provided by the user. Only available to the bot that received the payment.
is_recurring (``bool``, *optional*):
- True, if this is a recurring payment.
+ True, if the payment is a recurring payment for a subscription.
is_first_recurring (``bool``, *optional*):
- True, if this is the first recurring payment.
+ True, if the payment is the first payment for a subscription.
invoice_slug (``str``, *optional*):
Name of the invoice.
+
+ subscription_expiration_date (:py:obj:`~datetime.datetime`, *optional*):
+ Expiration date of the subscription, in Unix time; for recurring payments only.
"""
def __init__(
@@ -69,7 +74,8 @@ def __init__(
order_info: Optional["types.OrderInfo"] = None,
is_recurring: Optional[bool] = None,
is_first_recurring: Optional[bool] = None,
- invoice_slug: Optional[str] = None
+ invoice_slug: Optional[str] = None,
+ subscription_expiration_date: datetime = None,
):
super().__init__()
@@ -83,6 +89,7 @@ def __init__(
self.is_recurring = is_recurring
self.is_first_recurring = is_first_recurring
self.invoice_slug = invoice_slug
+ self.subscription_expiration_date = subscription_expiration_date
@staticmethod
def _parse(
@@ -136,4 +143,5 @@ def _parse(
is_recurring=getattr(successful_payment, "recurring_used", None),
is_first_recurring=getattr(successful_payment, "recurring_init", None),
invoice_slug=getattr(successful_payment, "invoice_slug", None),
+ subscription_expiration_date=utils.timestamp_to_datetime(successful_payment.subscription_until_date),
)