admin管理员组

文章数量:1123587

I have an error that I stumble upon. I can't figure out if there's something wrong with my code, or if this error occurs because I've tried to make an incorrect request from this account many times before, and now I'm temporarily (or permanently) banned. Last print says An error occurred: RPCError 400: STARGIFT_USAGE_LIMITED (caused by SendStarsFormRequest)

The purpose of the code: I want to buy a gift from my userbot's stars balance (currency='XTR') and send it to my friend.

this is the part of my code:

with TelegramClient(SESSION_NAME, API_ID, API_HASH) as client:
    print("Userbot is running...")

    try:
        recipient = client.get_input_entity(RECIPIENT_USERNAME)

        invoice = InputInvoiceStarGift(
            user_id=recipient,
            gift_id=GIFT_ID,
            message=message,
            hide_name=HIDE_NAME
        )

        print(f"Generated Invoice: {invoice}")

        payment_form = client(GetPaymentFormRequest(invoice=invoice))

        if payment_form:
            print("Payment form retrieved successfully!")
            print(payment_form.stringify())

            payment_result = client(SendStarsFormRequest(
                form_id=payment_form.form_id,
                invoice=invoice
            ))

            print(f"Payment successful: {payment_result.stringify()}")

    except RPCError as e:
        print(f"An error occurred: {e}")
    except Exception as e:
        print(f"Unexpected error: {e}")

terminal:

    Userbot is running...
Generated Invoice: InputInvoiceStarGift(user_id=InputPeerUser(user_id=***, access_hash=***), gift_id=6003767644426076664, hide_name=False, include_upgrade=None, message=TextWithEntities(text='good day!', entities=[MessageEntityBold(offset=0, length=9)]))
Payment form retrieved successfully!
PaymentFormStarGift(
        form_id=7458202761376502076,
        invoice=Invoice(
                currency='XTR',
                prices=[
                        LabeledPrice(
                                label='Total',
                                amount=10
                        ),
                ],
                test=False,
                name_requested=False,
                phone_requested=False,
                email_requested=False,
                shipping_address_requested=False,
                flexible=False,
                phone_to_provider=False,
                email_to_provider=False,
                recurring=False,
                max_tip_amount=None,
                suggested_tip_amounts=[
                ],
                terms_url=None,
                subscription_period=None
        )
)
An error occurred: RPCError 400: STARGIFT_USAGE_LIMITED (caused by SendStarsFormRequest)

本文标签: telegram apitelethon RPCError 400 STARGIFTUSAGELIMITED (caused by SendStarsFormRequest)Stack Overflow