Skip to content

Commit 66f8ad4

Browse files
Update methods and types to Layer 194
1 parent 8e5c740 commit 66f8ad4

File tree

6 files changed

+33
-10
lines changed

6 files changed

+33
-10
lines changed

pyrogram/methods/bots/create_invoice_link.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
from datetime import datetime
1920
from typing import Union, List, Optional
2021

2122
import pyrogram
22-
from pyrogram import raw, types
23+
from pyrogram import utils, raw, types
2324

2425

2526
class CreateInvoiceLink:
@@ -31,6 +32,7 @@ async def create_invoice_link(
3132
currency: str,
3233
prices: List["types.LabeledPrice"],
3334
provider_token: Optional[str] = None,
35+
subscription_period: datetime = None,
3436
max_tip_amount: Optional[int] = None,
3537
suggested_tip_amounts: Optional[List[int]] = None,
3638
start_parameter: Optional[str] = None,
@@ -73,6 +75,11 @@ async def create_invoice_link(
7375
provider_token (``str``, *optional*):
7476
Payment provider token, obtained via `@BotFather <https://t.me/botfather>`_. Pass an empty string for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
7577
78+
subscription_period (:py:obj:`~datetime.datetime`, *optional*):
79+
The number of seconds the subscription will be active for before the next payment.
80+
The currency must be set to “XTR” (Telegram Stars) if the parameter is used.
81+
Currently, it must always be 2592000 (30 days) if specified.
82+
7683
max_tip_amount (``int``, *optional*):
7784
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 <https://core.telegram.org/bots/payments/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 <https://t.me/BotNews/90>`_.
7885
@@ -148,7 +155,8 @@ async def create_invoice_link(
148155
phone_to_provider=send_phone_number_to_provider,
149156
email_to_provider=send_email_to_provider,
150157
max_tip_amount=max_tip_amount,
151-
suggested_tip_amounts=suggested_tip_amounts
158+
suggested_tip_amounts=suggested_tip_amounts,
159+
subscription_period=utils.datetime_to_timestamp(subscription_period)
152160
),
153161
payload=payload.encode() if isinstance(payload, str) else payload,
154162
provider=provider_token,

pyrogram/methods/messages/forward_messages.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ async def forward_messages(
8282
The relevant Stars will be withdrawn from the bot's balance.
8383
For bots only.
8484
85-
8685
Returns:
8786
:obj:`~pyrogram.types.Message` | List of :obj:`~pyrogram.types.Message`: In case *message_ids* was not
8887
a list, a single message is returned, otherwise a list of messages is returned.

pyrogram/methods/payments/get_star_gifts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class GetStarGifts:
2525
async def get_star_gifts(
2626
self: "pyrogram.Client",
2727
) -> List["types.StarGift"]:
28-
"""Get all available star gifts to send.
28+
"""Get all available star gifts that can be sent to other users.
2929
30-
.. include:: /_includes/usable-by/users.rst
30+
.. include:: /_includes/usable-by/users-bots.rst
3131
3232
Returns:
3333
List of :obj:`~pyrogram.types.StarGift`: On success, a list of star gifts is returned.

pyrogram/methods/payments/send_star_gift.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ async def send_star_gift(
5959
6060
hide_my_name (``bool``, *optional*):
6161
If True, your name will be hidden from visitors to the gift recipient's profile.
62+
For userbots only.
6263
Defaults to None.
6364
6465
Returns:

pyrogram/types/messages_and_media/star_gift.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ class StarGift(Object):
8282
8383
is_sold_out (``bool``, *optional*):
8484
True, if the star gift is sold out.
85+
86+
is_converted (``bool``, *optional*):
87+
True, if the gift was converted to Telegram Stars.
88+
Only for the receiver of the gift.
8589
"""
8690

8791
def __init__(
@@ -104,7 +108,8 @@ def __init__(
104108
is_limited: Optional[bool] = None,
105109
is_name_hidden: Optional[bool] = None,
106110
is_saved: Optional[bool] = None,
107-
is_sold_out: Optional[bool] = None
111+
is_sold_out: Optional[bool] = None,
112+
is_converted: Optional[bool] = None
108113
):
109114
super().__init__(client)
110115

@@ -125,6 +130,7 @@ def __init__(
125130
self.is_name_hidden = is_name_hidden
126131
self.is_saved = is_saved
127132
self.is_sold_out = is_sold_out
133+
self.is_converted = is_converted
128134

129135
@staticmethod
130136
async def _parse(
@@ -187,7 +193,7 @@ async def _parse_action(
187193
message: "raw.base.Message",
188194
users: dict
189195
) -> "StarGift":
190-
action = message.action
196+
action = message.action # type: raw.types.MessageActionStarGift
191197

192198
doc = action.gift.sticker
193199
attributes = {type(i): i for i in doc.attributes}
@@ -209,6 +215,7 @@ async def _parse_action(
209215
is_limited=getattr(action.gift, "limited", None),
210216
is_name_hidden=getattr(action, "name_hidden", None),
211217
is_saved=getattr(action, "saved", None),
218+
is_converted=getattr(action, "converted", None),
212219
from_user=types.User._parse(client, users.get(utils.get_raw_peer_id(message.peer_id))),
213220
message_id=message.id,
214221
caption=caption,

pyrogram/types/messages_and_media/successful_payment.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
from datetime import datetime
1920
from typing import Union, Optional
2021

22+
from pyrogram import utils
2123
from pyrogram import raw
2224
from pyrogram import types
2325
from ..object import Object
@@ -49,13 +51,16 @@ class SuccessfulPayment(Object):
4951
Payment information provided by the user. Only available to the bot that received the payment.
5052
5153
is_recurring (``bool``, *optional*):
52-
True, if this is a recurring payment.
54+
True, if the payment is a recurring payment for a subscription.
5355
5456
is_first_recurring (``bool``, *optional*):
55-
True, if this is the first recurring payment.
57+
True, if the payment is the first payment for a subscription.
5658
5759
invoice_slug (``str``, *optional*):
5860
Name of the invoice.
61+
62+
subscription_expiration_date (:py:obj:`~datetime.datetime`, *optional*):
63+
Expiration date of the subscription, in Unix time; for recurring payments only.
5964
"""
6065

6166
def __init__(
@@ -69,7 +74,8 @@ def __init__(
6974
order_info: Optional["types.OrderInfo"] = None,
7075
is_recurring: Optional[bool] = None,
7176
is_first_recurring: Optional[bool] = None,
72-
invoice_slug: Optional[str] = None
77+
invoice_slug: Optional[str] = None,
78+
subscription_expiration_date: datetime = None,
7379
):
7480
super().__init__()
7581

@@ -83,6 +89,7 @@ def __init__(
8389
self.is_recurring = is_recurring
8490
self.is_first_recurring = is_first_recurring
8591
self.invoice_slug = invoice_slug
92+
self.subscription_expiration_date = subscription_expiration_date
8693

8794
@staticmethod
8895
def _parse(
@@ -136,4 +143,5 @@ def _parse(
136143
is_recurring=getattr(successful_payment, "recurring_used", None),
137144
is_first_recurring=getattr(successful_payment, "recurring_init", None),
138145
invoice_slug=getattr(successful_payment, "invoice_slug", None),
146+
subscription_expiration_date=utils.timestamp_to_datetime(successful_payment.subscription_until_date),
139147
)

0 commit comments

Comments
 (0)