mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-06 15:14:52 +00:00
pyrofork: Add get_stars_transaction_by_id method
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
c880277a4e
commit
56621a6f4d
5 changed files with 143 additions and 1 deletions
|
|
@ -379,6 +379,7 @@ def pyrogram_api():
|
||||||
create_invoice_link
|
create_invoice_link
|
||||||
get_business_connection
|
get_business_connection
|
||||||
get_stars_transactions
|
get_stars_transactions
|
||||||
|
get_stars_transactions_by_id
|
||||||
""",
|
""",
|
||||||
authorization="""
|
authorization="""
|
||||||
Authorization
|
Authorization
|
||||||
|
|
@ -601,6 +602,7 @@ def pyrogram_api():
|
||||||
""",
|
""",
|
||||||
business="""
|
business="""
|
||||||
Telegram Business
|
Telegram Business
|
||||||
|
InputStarsTransaction
|
||||||
StarsStatus
|
StarsStatus
|
||||||
StarsTransaction
|
StarsTransaction
|
||||||
""",
|
""",
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@
|
||||||
from .create_invoice_link import CreateInvoiceLink
|
from .create_invoice_link import CreateInvoiceLink
|
||||||
from .get_business_connection import GetBusinessConnection
|
from .get_business_connection import GetBusinessConnection
|
||||||
from .get_stars_transactions import GetStarsTransactions
|
from .get_stars_transactions import GetStarsTransactions
|
||||||
|
from .get_stars_transactions_by_id import GetStarsTransactionsById
|
||||||
|
|
||||||
|
|
||||||
class TelegramBusiness(
|
class TelegramBusiness(
|
||||||
CreateInvoiceLink,
|
CreateInvoiceLink,
|
||||||
GetBusinessConnection,
|
GetBusinessConnection,
|
||||||
GetStarsTransactions
|
GetStarsTransactions,
|
||||||
|
GetStarsTransactionsById
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
87
pyrogram/methods/business/get_stars_transactions_by_id.py
Normal file
87
pyrogram/methods/business/get_stars_transactions_by_id.py
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
# Pyrofork - Telegram MTProto API Client Library for Python
|
||||||
|
# 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/>.
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import raw
|
||||||
|
from pyrogram import types
|
||||||
|
from typing import Union, List
|
||||||
|
|
||||||
|
|
||||||
|
class GetStarsTransactionsById:
|
||||||
|
async def get_stars_transactions_by_id(
|
||||||
|
self: "pyrogram.Client",
|
||||||
|
transaction_ids: Union[
|
||||||
|
"types.InputStarsTransaction",
|
||||||
|
List["types.InputStarsTransaction"]
|
||||||
|
],
|
||||||
|
chat_id: Union[int, str] = "me"
|
||||||
|
) -> "types.StarsStatus":
|
||||||
|
"""Get stars transactions by transaction id.
|
||||||
|
|
||||||
|
.. include:: /_includes/usable-by/users-bots.rst
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
transaction_ids (:obj:`~pyrogram.types.InputStarsTransaction` | List of :obj:`~pyrogram.types.InputStarsTransaction`):
|
||||||
|
Pass a single transaction identifier or an iterable of transaction ids (as integers) to get the content of the
|
||||||
|
transaction themselves
|
||||||
|
|
||||||
|
chat_id (``int`` | ``str``, *optional*):
|
||||||
|
Unique identifier (int) or username (str) of the target user.
|
||||||
|
You can also use chat public link in form of *t.me/<username>* (str).
|
||||||
|
default to self.
|
||||||
|
only for bots.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
# get one transaction by id
|
||||||
|
from pyrogram.types import InputStarsTransaction
|
||||||
|
app.get_stars_transactions_by_id(InputStarsTransaction(id="transaction_id"))
|
||||||
|
|
||||||
|
# get multiple transactions by id
|
||||||
|
from pyrogram.types import InputStarsTransaction
|
||||||
|
app.get_stars_transactions_by_id([
|
||||||
|
InputStarsTransaction(id="transaction_id_1"),
|
||||||
|
InputStarsTransaction(id="transaction_id_2")
|
||||||
|
])
|
||||||
|
|
||||||
|
# get one transaction by id from a specific user
|
||||||
|
from pyrogram.types import InputStarsTransaction
|
||||||
|
app.get_stars_transactions_by_id(InputStarsTransaction(id="transaction_id"), chat_id="username")
|
||||||
|
|
||||||
|
# get multiple transaction by id from a specific user
|
||||||
|
from pyrogram.types import InputStarsTransaction
|
||||||
|
app.get_stars_transactions_by_id([
|
||||||
|
InputStarsTransaction(id="transaction_id_1"),
|
||||||
|
InputStarsTransaction(id="transaction_id_2")
|
||||||
|
], chat_id="username")
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
:obj:`~pyrogram.types.StarsStatus`: On success, a :obj:`~pyrogram.types.StarsStatus` object is returned.
|
||||||
|
"""
|
||||||
|
peer = await self.resolve_peer(chat_id)
|
||||||
|
is_iterable = not isinstance(transaction_ids, types.InputStarsTransaction)
|
||||||
|
ids = [await transaction_ids.write()] if not is_iterable else [await x.write() for x in transaction_ids]
|
||||||
|
|
||||||
|
r = await self.invoke(
|
||||||
|
raw.functions.payments.GetStarsTransactionsByID(
|
||||||
|
peer=peer,
|
||||||
|
id=ids
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return types.StarsStatus._parse(self, r)
|
||||||
|
|
@ -16,10 +16,12 @@
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from .input_stars_transaction import InputStarsTransaction
|
||||||
from .stars_status import StarsStatus
|
from .stars_status import StarsStatus
|
||||||
from .stars_transaction import StarsTransaction
|
from .stars_transaction import StarsTransaction
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
"InputStarsTransaction",
|
||||||
"StarsStatus",
|
"StarsStatus",
|
||||||
"StarsTransaction"
|
"StarsTransaction"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
49
pyrogram/types/business/input_stars_transaction.py
Normal file
49
pyrogram/types/business/input_stars_transaction.py
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
# Pyrofork - Telegram MTProto API Client Library for Python
|
||||||
|
# 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/>.
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
|
||||||
|
from pyrogram import raw
|
||||||
|
from ..object import Object
|
||||||
|
|
||||||
|
class InputStarsTransaction(Object):
|
||||||
|
"""Content of a stars transaction.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
id (``str``):
|
||||||
|
Unique transaction identifier.
|
||||||
|
|
||||||
|
is_refund (``bool``, *optional*):
|
||||||
|
True, If the transaction is a refund.
|
||||||
|
"""
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
id: str,
|
||||||
|
is_refund: bool = None
|
||||||
|
):
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.id = id
|
||||||
|
self.is_refund = is_refund
|
||||||
|
|
||||||
|
async def write(self):
|
||||||
|
return raw.types.InputStarsTransaction(
|
||||||
|
id=self.id,
|
||||||
|
refund=self.is_refund
|
||||||
|
)
|
||||||
Loading…
Reference in a new issue