|
| 1 | +# Pyrogram - Telegram MTProto API Client Library for Python |
| 2 | +# Copyright (C) 2017-present Dan <https://github.com/delivrance> |
| 3 | +# |
| 4 | +# This file is part of Pyrogram. |
| 5 | +# |
| 6 | +# Pyrogram is free software: you can redistribute it and/or modify |
| 7 | +# it under the terms of the GNU Lesser General Public License as published |
| 8 | +# by the Free Software Foundation, either version 3 of the License, or |
| 9 | +# (at your option) any later version. |
| 10 | +# |
| 11 | +# Pyrogram is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +# GNU Lesser General Public License for more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU Lesser General Public License |
| 17 | +# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + |
| 19 | +from typing import Union |
| 20 | + |
| 21 | +import pyrogram |
| 22 | +from pyrogram import raw |
| 23 | + |
| 24 | + |
| 25 | +class EditUserStarSubscription: |
| 26 | + async def edit_user_star_subscription( |
| 27 | + self: "pyrogram.Client", |
| 28 | + user_id: Union[int, str], |
| 29 | + telegram_payment_charge_id: str, |
| 30 | + is_canceled: bool, |
| 31 | + ) -> bool: |
| 32 | + """Cancels or re-enables Telegram Star subscription for a user. |
| 33 | +
|
| 34 | + .. include:: /_includes/usable-by/bots.rst |
| 35 | +
|
| 36 | + Parameters: |
| 37 | + user_id (``int`` | ``str``): |
| 38 | + Unique identifier (int) or username (str) of the target user. |
| 39 | +
|
| 40 | + telegram_payment_charge_id (``str``): |
| 41 | + Telegram payment identifier of the subscription. |
| 42 | +
|
| 43 | + is_canceled (``bool``): |
| 44 | + Pass True to cancel the subscription. |
| 45 | + Pass False to allow the user to enable it. |
| 46 | +
|
| 47 | + Returns: |
| 48 | + ``bool``: On success, True is returned. |
| 49 | + """ |
| 50 | + return await self.invoke( |
| 51 | + raw.functions.payments.BotCancelStarsSubscription( |
| 52 | + user_id=await self.resolve_peer(user_id), |
| 53 | + charge_id=telegram_payment_charge_id, |
| 54 | + restore=is_canceled, |
| 55 | + ) |
| 56 | + ) |
0 commit comments