mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
Add convert_star_gift method
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
d4649275e9
commit
f23f450c62
3 changed files with 78 additions and 0 deletions
|
|
@ -348,6 +348,7 @@ def pyrogram_api():
|
||||||
Payments
|
Payments
|
||||||
apply_gift_code
|
apply_gift_code
|
||||||
check_gift_code
|
check_gift_code
|
||||||
|
convert_star_gift
|
||||||
create_invoice_link
|
create_invoice_link
|
||||||
get_payment_form
|
get_payment_form
|
||||||
get_star_gifts
|
get_star_gifts
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,13 @@
|
||||||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from .apply_gift_code import ApplyGiftCode
|
from .apply_gift_code import ApplyGiftCode
|
||||||
|
<<<<<<< HEAD
|
||||||
from .check_giftcode import CheckGiftCode
|
from .check_giftcode import CheckGiftCode
|
||||||
from .create_invoice_link import CreateInvoiceLink
|
from .create_invoice_link import CreateInvoiceLink
|
||||||
|
=======
|
||||||
|
from .check_gift_code import CheckGiftCode
|
||||||
|
from .convert_star_gift import ConvertStarGift
|
||||||
|
>>>>>>> 1473842c6 (Add convert_star_gift method)
|
||||||
from .get_payment_form import GetPaymentForm
|
from .get_payment_form import GetPaymentForm
|
||||||
from .get_star_gifts import GetStarGifts
|
from .get_star_gifts import GetStarGifts
|
||||||
from .get_stars_transactions import GetStarsTransactions
|
from .get_stars_transactions import GetStarsTransactions
|
||||||
|
|
@ -34,6 +39,7 @@ from .send_star_gift import SendStarGift
|
||||||
class Payments(
|
class Payments(
|
||||||
ApplyGiftCode,
|
ApplyGiftCode,
|
||||||
CheckGiftCode,
|
CheckGiftCode,
|
||||||
|
ConvertStarGift,
|
||||||
CreateInvoiceLink,
|
CreateInvoiceLink,
|
||||||
GetPaymentForm,
|
GetPaymentForm,
|
||||||
GetStarGifts,
|
GetStarGifts,
|
||||||
|
|
|
||||||
71
pyrogram/methods/payments/convert_star_gift.py
Normal file
71
pyrogram/methods/payments/convert_star_gift.py
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
# Pyrofork - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrofork.
|
||||||
|
#
|
||||||
|
# Pyrofork is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Pyrofork 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 General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import raw
|
||||||
|
|
||||||
|
|
||||||
|
class ConvertStarGift:
|
||||||
|
async def convert_star_gift(
|
||||||
|
self: "pyrogram.Client",
|
||||||
|
chat_id: Union[int, str],
|
||||||
|
message_id: int
|
||||||
|
) -> bool:
|
||||||
|
"""Convert star gift to stars.
|
||||||
|
|
||||||
|
.. include:: /_includes/usable-by/users.rst
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
chat_id (``int`` | ``str``):
|
||||||
|
Unique identifier (int) or username (str) of the target chat.
|
||||||
|
For your personal cloud (Saved Messages) you can simply use "me" or "self".
|
||||||
|
For a contact that exists in your Telegram address book you can use his phone number (str).
|
||||||
|
|
||||||
|
message_id (``int``):
|
||||||
|
Unique message identifier of star gift.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
``bool``: On success, True is returned.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
# Convert gift
|
||||||
|
app.convert_star_gift(chat_id=chat_id, message_id=123)
|
||||||
|
"""
|
||||||
|
peer = await self.resolve_peer(chat_id)
|
||||||
|
|
||||||
|
if isinstance(peer, raw.types.InputPeerUser):
|
||||||
|
peer = raw.types.InputUser(user_id=peer.user_id, access_hash=peer.access_hash)
|
||||||
|
elif isinstance(peer, raw.types.InputPeerSelf):
|
||||||
|
peer = raw.types.InputUserSelf()
|
||||||
|
else:
|
||||||
|
raise ValueError("chat_id must belong to a user.")
|
||||||
|
|
||||||
|
r = await self.invoke(
|
||||||
|
raw.functions.payments.ConvertStarGift(
|
||||||
|
user_id=peer,
|
||||||
|
msg_id=message_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return r
|
||||||
Loading…
Reference in a new issue