Skip to content

Update methods for MTProto API layer 227#128

Open
5hojib wants to merge 2 commits into
betafrom
jules-15791912205650888094-eca68639
Open

Update methods for MTProto API layer 227#128
5hojib wants to merge 2 commits into
betafrom
jules-15791912205650888094-eca68639

Conversation

@5hojib

@5hojib 5hojib commented Jul 8, 2026

Copy link
Copy Markdown
Member

This PR updates several Pyrogram bound methods to include the allow_paid_stars parameter, bringing them in line with the MTProto API layer 227 changes. Tests pass and ty type checking is happy with the modified files.


PR created automatically by Jules for task 15791912205650888094 started by @5hojib

Summary by Sourcery

Add support for Telegram MTProto layer 227 paid stars in various message-sending helpers.

New Features:

  • Allow specifying an allow_paid_stars amount when sending invoices, media, dice, stickers, voice and web page messages via Pyrogram methods.

Enhancements:

  • Document the new allow_paid_stars parameter alongside existing allow_paid_broadcast options in the affected sending methods.

- Add `allow_paid_stars` parameter to message-sending methods based on new API schema
- Formatted updated files
- Checked for type issues
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@sourcery-ai

sourcery-ai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds support for the MTProto allow_paid_stars parameter across several Pyrogram send* methods, including public signatures, documentation, and wiring through to the underlying raw API calls.

Flow diagram for allow_paid_stars propagation in send methods

flowchart TD
    BotCode[Bot code calls send_audio, send_document, send_sticker, send_video_note, send_voice, send_web_page, send_dice, send_invoice]
    SendMethods[Pyrogram send methods expose allow_paid_stars parameter in their signatures and docs]
    RawAPI[Underlying raw send calls include allow_paid_stars field alongside allow_paid_floodskip]

    BotCode --> SendMethods
    SendMethods --> RawAPI
Loading

File-Level Changes

Change Details Files
Expose the new allow_paid_stars parameter on business.send_invoice and pass it through to the underlying MTProto request.
  • Extend send_invoice signature with an optional allow_paid_stars: int parameter adjacent to allow_paid_broadcast.
  • Document allow_paid_stars in the send_invoice docstring, describing it as the amount of stars to pay for the message for bots.
  • Include allow_paid_stars when constructing the raw SendMedia/related MTProto request so it is forwarded to Telegram.
pyrogram/methods/business/send_invoice.py
Expose the new allow_paid_stars parameter on multiple message-sending helpers and forward it to the MTProto layer.
  • Extend send_audio, send_dice, send_document, send_sticker, send_video_note, send_voice, and send_web_page signatures with an optional allow_paid_stars: int parameter next to allow_paid_broadcast.
  • Update each method’s docstring to describe allow_paid_stars as the number of stars to pay for the message for bots only, right after the allow_paid_broadcast description.
  • Pass allow_paid_stars through to the corresponding raw functions (e.g., SendMedia / send_message variants) by setting the allow_paid_stars field alongside allow_paid_floodskip/allow_paid_broadcast.
pyrogram/methods/messages/send_audio.py
pyrogram/methods/messages/send_dice.py
pyrogram/methods/messages/send_document.py
pyrogram/methods/messages/send_sticker.py
pyrogram/methods/messages/send_video_note.py
pyrogram/methods/messages/send_voice.py
pyrogram/methods/messages/send_web_page.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In all updated method docstrings, the descriptive line Pass True to allow the message to ignore regular broadcast limits... now appears visually associated with allow_paid_stars; it would be clearer to keep that description directly under allow_paid_broadcast and group the new allow_paid_stars description separately so each parameter's behavior is unambiguous.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In all updated method docstrings, the descriptive line `Pass True to allow the message to ignore regular broadcast limits...` now appears visually associated with `allow_paid_stars`; it would be clearer to keep that description directly under `allow_paid_broadcast` and group the new `allow_paid_stars` description separately so each parameter's behavior is unambiguous.

## Individual Comments

### Comment 1
<location path="pyrogram/methods/messages/send_audio.py" line_range="144-146" />
<code_context>

             allow_paid_broadcast (``bool``, *optional*):
+
+            allow_paid_stars (``int``, *optional*):
+                Pass the amount of stars to pay for the message; for bots only
                 Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only

             quote_entities (List of :obj:`~pyrogram.types.MessageEntity`, *optional*):
</code_context>
<issue_to_address>
**issue:** The docstring section for `allow_paid_broadcast` and `allow_paid_stars` is now ambiguous and misaligned with the parameter headings.

The `allow_paid_stars` block is currently inserted between the `allow_paid_broadcast` heading and its description (`Pass True to allow the message to ignore regular broadcast limits...`), making that description appear to apply to `allow_paid_stars` and leaving `allow_paid_broadcast` without a clear explanation. Please reorder so each parameter’s heading and description are contiguous (e.g., keep the full `allow_paid_broadcast` section together, then add `allow_paid_stars`), and apply the same fix to the other modified methods for consistency.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +144 to 146
allow_paid_stars (``int``, *optional*):
Pass the amount of stars to pay for the message; for bots only
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: The docstring section for allow_paid_broadcast and allow_paid_stars is now ambiguous and misaligned with the parameter headings.

The allow_paid_stars block is currently inserted between the allow_paid_broadcast heading and its description (Pass True to allow the message to ignore regular broadcast limits...), making that description appear to apply to allow_paid_stars and leaving allow_paid_broadcast without a clear explanation. Please reorder so each parameter’s heading and description are contiguous (e.g., keep the full allow_paid_broadcast section together, then add allow_paid_stars), and apply the same fix to the other modified methods for consistency.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the allow_paid_stars parameter to various message-sending methods (including send_invoice, send_audio, send_dice, send_document, send_sticker, send_video_note, send_voice, and send_web_page) to support paying with stars. However, there is a recurring copy-paste error in the docstrings across all modified files: the description for allow_paid_broadcast was misplaced under allow_paid_stars, leaving allow_paid_broadcast undocumented. Please correct these docstrings to properly document both parameters.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +94 to +96

allow_paid_stars (``int``, *optional*):
Pass the amount of stars to pay for the message; for bots only

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a copy-paste error in the docstring. The description for allow_paid_broadcast has been misplaced under allow_paid_stars, leaving allow_paid_broadcast undocumented and duplicating/misplacing the text under allow_paid_stars.

Please update the docstring to correctly document both parameters:

            allow_paid_broadcast (``bool``, *optional*):
                Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only

            allow_paid_stars (``int``, *optional*):
                Pass the amount of stars to pay for the message; for bots only

Comment thread pyrogram/methods/messages/send_audio.py Outdated
Comment on lines +143 to +145

allow_paid_stars (``int``, *optional*):
Pass the amount of stars to pay for the message; for bots only

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a copy-paste error in the docstring. The description for allow_paid_broadcast has been misplaced under allow_paid_stars, leaving allow_paid_broadcast undocumented and duplicating/misplacing the text under allow_paid_stars.

Please update the docstring to correctly document both parameters:

            allow_paid_broadcast (``bool``, *optional*):
                Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only

            allow_paid_stars (``int``, *optional*):
                Pass the amount of stars to pay for the message; for bots only

Comment thread pyrogram/methods/messages/send_dice.py Outdated
Comment on lines +98 to +100

allow_paid_stars (``int``, *optional*):
Pass the amount of stars to pay for the message; for bots only

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a copy-paste error in the docstring. The description for allow_paid_broadcast has been misplaced under allow_paid_stars, leaving allow_paid_broadcast undocumented and duplicating/misplacing the text under allow_paid_stars.

Please update the docstring to correctly document both parameters:

            allow_paid_broadcast (``bool``, *optional*):
                Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only

            allow_paid_stars (``int``, *optional*):
                Pass the amount of stars to pay for the message; for bots only

Comment on lines +135 to +137

allow_paid_stars (``int``, *optional*):
Pass the amount of stars to pay for the message; for bots only

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a copy-paste error in the docstring. The description for allow_paid_broadcast has been misplaced under allow_paid_stars, leaving allow_paid_broadcast undocumented and duplicating/misplacing the text under allow_paid_stars.

Please update the docstring to correctly document both parameters:

            allow_paid_broadcast (``bool``, *optional*):
                Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only

            allow_paid_stars (``int``, *optional*):
                Pass the amount of stars to pay for the message; for bots only

Comment on lines +111 to +113

allow_paid_stars (``int``, *optional*):
Pass the amount of stars to pay for the message; for bots only

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a copy-paste error in the docstring. The description for allow_paid_broadcast has been misplaced under allow_paid_stars, leaving allow_paid_broadcast undocumented and duplicating/misplacing the text under allow_paid_stars.

Please update the docstring to correctly document both parameters:

            allow_paid_broadcast (``bool``, *optional*):
                Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only

            allow_paid_stars (``int``, *optional*):
                Pass the amount of stars to pay for the message; for bots only

Comment on lines +124 to +126

allow_paid_stars (``int``, *optional*):
Pass the amount of stars to pay for the message; for bots only

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a copy-paste error in the docstring. The description for allow_paid_broadcast has been misplaced under allow_paid_stars, leaving allow_paid_broadcast undocumented and duplicating/misplacing the text under allow_paid_stars.

Please update the docstring to correctly document both parameters:

            allow_paid_broadcast (``bool``, *optional*):
                Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only

            allow_paid_stars (``int``, *optional*):
                Pass the amount of stars to pay for the message; for bots only

Comment thread pyrogram/methods/messages/send_voice.py Outdated
Comment on lines +123 to +125

allow_paid_stars (``int``, *optional*):
Pass the amount of stars to pay for the message; for bots only

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a copy-paste error in the docstring. The description for allow_paid_broadcast has been misplaced under allow_paid_stars, leaving allow_paid_broadcast undocumented and duplicating/misplacing the text under allow_paid_stars.

Please update the docstring to correctly document both parameters:

            allow_paid_broadcast (``bool``, *optional*):
                Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only

            allow_paid_stars (``int``, *optional*):
                Pass the amount of stars to pay for the message; for bots only

Comment on lines +109 to +111

allow_paid_stars (``int``, *optional*):
Pass the amount of stars to pay for the message; for bots only

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a copy-paste error in the docstring. The description for allow_paid_broadcast has been misplaced under allow_paid_stars, leaving allow_paid_broadcast undocumented and duplicating/misplacing the text under allow_paid_stars.

Please update the docstring to correctly document both parameters:

            allow_paid_broadcast (``bool``, *optional*):
                Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots

            allow_paid_stars (``int``, *optional*):
                Pass the amount of stars to pay for the message; for bots only

- Update docstrings for `allow_paid_stars`
- Add `allow_paid_stars` to multiple message sending methods
- Fix `file.id` attribute check in send methods
- Formatted with ruff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant