Skip to content

Commit 7ce7a41

Browse files
Add bot support in get_stars_balance
1 parent 074910c commit 7ce7a41

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

pyrogram/methods/payments/get_stars_balance.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@ class GetStarsBalance:
2626
async def get_stars_balance(
2727
self: "pyrogram.Client",
2828
chat_id: Optional[Union[int, str]] = None,
29-
) -> int:
29+
) -> float:
3030
"""Get the current Telegram Stars balance of the current account.
3131
32-
.. include:: /_includes/usable-by/users.rst
32+
.. include:: /_includes/usable-by/users-bots.rst
3333
3434
Parameters:
3535
chat_id (``int`` | ``str``, *optional*):
3636
Unique identifier (int) or username (str) of the target chat.
3737
For your personal cloud (Saved Messages) you can simply use "me" or "self".
3838
3939
Returns:
40-
``int``: On success, the current stars balance is returned.
40+
``float``: On success, the current stars balance is returned.
4141
4242
Example:
4343
.. code-block:: python
4444
45-
# Get stars balance
45+
# Get stars balance of current account
4646
await app.get_stars_balance()
4747
4848
# Get stars balance of a bot
@@ -54,9 +54,11 @@ async def get_stars_balance(
5454
peer = await self.resolve_peer(chat_id)
5555

5656
r = await self.invoke(
57-
raw.functions.payments.GetStarsStatus(
58-
peer=peer
57+
raw.functions.payments.GetStarsTransactions(
58+
peer=peer,
59+
offset="",
60+
limit=0
5961
)
6062
)
6163

62-
return r.balance.amount
64+
return r.balance.amount + r.balance.nanos / 1e9

0 commit comments

Comments
 (0)