mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
Add transfer_business_account_stars method
Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
parent
b6c615df7a
commit
a1e3f0f5db
4 changed files with 78 additions and 1 deletions
|
|
@ -417,6 +417,7 @@ def pyrogram_api():
|
||||||
get_business_connection
|
get_business_connection
|
||||||
get_business_account_gifts
|
get_business_account_gifts
|
||||||
get_business_account_star_balance
|
get_business_account_star_balance
|
||||||
|
transfer_business_account_stars
|
||||||
""",
|
""",
|
||||||
authorization="""
|
authorization="""
|
||||||
Authorization
|
Authorization
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ BOT_GAMES_DISABLED Bot games cannot be used in this type of chat
|
||||||
BOT_GROUPS_BLOCKED This bot can't be added to groups
|
BOT_GROUPS_BLOCKED This bot can't be added to groups
|
||||||
BOT_INLINE_DISABLED The inline feature of the bot is disabled
|
BOT_INLINE_DISABLED The inline feature of the bot is disabled
|
||||||
BOT_INVALID This is not a valid bot
|
BOT_INVALID This is not a valid bot
|
||||||
|
BOT_INVOICE_INVALID The provided invoice is invalid
|
||||||
BOT_METHOD_INVALID The method can't be used by bots
|
BOT_METHOD_INVALID The method can't be used by bots
|
||||||
BOT_MISSING This method can only be run by a bot
|
BOT_MISSING This method can only be run by a bot
|
||||||
BOT_ONESIDE_NOT_AVAIL Bots can't pin messages for one side only in private chats
|
BOT_ONESIDE_NOT_AVAIL Bots can't pin messages for one side only in private chats
|
||||||
|
|
@ -46,6 +47,7 @@ BROADCAST_CALLS_DISABLED Broadcast calls disabled
|
||||||
BROADCAST_ID_INVALID The channel is invalid
|
BROADCAST_ID_INVALID The channel is invalid
|
||||||
BROADCAST_PUBLIC_VOTERS_FORBIDDEN Polls with public voters cannot be sent in channels
|
BROADCAST_PUBLIC_VOTERS_FORBIDDEN Polls with public voters cannot be sent in channels
|
||||||
BROADCAST_REQUIRED The request can only be used with a channel
|
BROADCAST_REQUIRED The request can only be used with a channel
|
||||||
|
BUSINESS_BOT_MISSING Business bot missing
|
||||||
BUTTON_DATA_INVALID The button callback data is invalid or too large
|
BUTTON_DATA_INVALID The button callback data is invalid or too large
|
||||||
BUTTON_ID_INVALID The button_id parameter is invalid
|
BUTTON_ID_INVALID The button_id parameter is invalid
|
||||||
BUTTON_TEXT_INVALID The specified button text is invalid
|
BUTTON_TEXT_INVALID The specified button text is invalid
|
||||||
|
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ from .delete_business_messages import DeleteBusinessMessages
|
||||||
from .get_business_connection import GetBusinessConnection
|
from .get_business_connection import GetBusinessConnection
|
||||||
from .get_business_account_gifts import GetBusinessAccountGifts
|
from .get_business_account_gifts import GetBusinessAccountGifts
|
||||||
from .get_business_account_star_balance import GetBusinessAccountStarBalance
|
from .get_business_account_star_balance import GetBusinessAccountStarBalance
|
||||||
|
from .transfer_business_account_stars import TransferBusinessAccountStars
|
||||||
|
|
||||||
|
|
||||||
class TelegramBusiness(
|
class TelegramBusiness(
|
||||||
|
|
@ -31,6 +32,7 @@ class TelegramBusiness(
|
||||||
DeleteBusinessMessages,
|
DeleteBusinessMessages,
|
||||||
GetBusinessConnection,
|
GetBusinessConnection,
|
||||||
GetBusinessAccountGifts,
|
GetBusinessAccountGifts,
|
||||||
GetBusinessAccountStarBalance
|
GetBusinessAccountStarBalance,
|
||||||
|
TransferBusinessAccountStars,
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
72
pyrogram/methods/business/transfer_business_account_stars.py
Normal file
72
pyrogram/methods/business/transfer_business_account_stars.py
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrogram.
|
||||||
|
#
|
||||||
|
# Pyrogram 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.
|
||||||
|
#
|
||||||
|
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import raw
|
||||||
|
|
||||||
|
|
||||||
|
class TransferBusinessAccountStars:
|
||||||
|
async def transfer_business_account_stars(
|
||||||
|
self: "pyrogram.Client",
|
||||||
|
business_connection_id: str,
|
||||||
|
star_count: int,
|
||||||
|
) -> bool:
|
||||||
|
"""Transfers Telegram Stars from the business account balance to the bot’s balance.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Requires the `can_transfer_stars` business bot right.
|
||||||
|
|
||||||
|
.. include:: /_includes/usable-by/users.rst
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
business_connection_id (``str``):
|
||||||
|
Unique identifier of the business connection.
|
||||||
|
|
||||||
|
star_count (``int`` | ``str``):
|
||||||
|
Number of Telegram Stars to transfer, 1-10000.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
``bool``: On success, True is returned.
|
||||||
|
"""
|
||||||
|
# Why telegram won't let us just use InputPeerSelf :(
|
||||||
|
if self.me:
|
||||||
|
bot_id = self.me.id
|
||||||
|
else:
|
||||||
|
bot_id = (
|
||||||
|
await self.invoke(raw.functions.users.GetUsers(id=[raw.types.InputPeerSelf()]))
|
||||||
|
)[0].id
|
||||||
|
|
||||||
|
invoice = raw.types.InputInvoiceBusinessBotTransferStars(
|
||||||
|
bot=await self.resolve_peer(bot_id), stars=star_count
|
||||||
|
)
|
||||||
|
|
||||||
|
payment_form = await self.invoke(
|
||||||
|
raw.functions.payments.GetPaymentForm(invoice=invoice),
|
||||||
|
business_connection_id=business_connection_id,
|
||||||
|
)
|
||||||
|
|
||||||
|
await self.invoke(
|
||||||
|
raw.functions.payments.SendStarsForm(
|
||||||
|
form_id=payment_form.form_id,
|
||||||
|
invoice=invoice,
|
||||||
|
),
|
||||||
|
business_connection_id=business_connection_id,
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
Loading…
Reference in a new issue