Skip to content

Commit

Permalink
Add allow_paid_broadcast parameter to send methods
Browse files Browse the repository at this point in the history
  • Loading branch information
KurimuzonAkuma committed Nov 1, 2024
1 parent b35f72e commit d0b982f
Show file tree
Hide file tree
Showing 23 changed files with 334 additions and 6 deletions.
8 changes: 8 additions & 0 deletions pyrogram/methods/bots/send_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ async def send_game(
reply_to_message_id: int = None,
reply_to_chat_id: Union[int, str] = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
Expand Down Expand Up @@ -76,6 +77,12 @@ async def send_game(
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
allow_paid_broadcast (``bool``, *optional*):
If True, you will be allowed to send up to 1000 messages per second.
Ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message.
The relevant Stars will be withdrawn from the bot's balance.
For bots only.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*):
An object for an inline keyboard. If empty, one ‘Play game_title’ button will be shown automatically.
If not empty, the first button must launch the game.
Expand Down Expand Up @@ -106,6 +113,7 @@ async def send_game(
),
random_id=self.rnd_id(),
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
reply_markup=await reply_markup.write(self) if reply_markup else None,
effect=effect_id
)
Expand Down
8 changes: 8 additions & 0 deletions pyrogram/methods/bots/send_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ async def send_invoice(
protect_content: Optional[bool] = None,
message_effect_id: Optional[int] = None,
reply_to_message_id: Optional[int] = None,
allow_paid_broadcast: bool = None,
reply_markup: Optional[Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
Expand Down Expand Up @@ -152,6 +153,12 @@ async def send_invoice(
message_effect_id (``int`` ``64-bit``, *optional*):
Unique identifier of the message effect to be added to the message; for private chats only.
allow_paid_broadcast (``bool``, *optional*):
If True, you will be allowed to send up to 1000 messages per second.
Ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message.
The relevant Stars will be withdrawn from the bot's balance.
For bots only.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
Expand Down Expand Up @@ -216,6 +223,7 @@ async def send_invoice(
),
random_id=self.rnd_id(),
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
reply_markup=await reply_markup.write(self) if reply_markup else None,
effect=message_effect_id,
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
Expand Down
2 changes: 2 additions & 0 deletions pyrogram/methods/messages/copy_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async def copy_message(
protect_content: bool = None,
has_spoiler: bool = None,
business_connection_id: str = None,
allow_paid_broadcast: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
Expand Down Expand Up @@ -137,6 +138,7 @@ async def copy_message(
schedule_date=schedule_date,
protect_content=protect_content,
has_spoiler=has_spoiler,
allow_paid_broadcast=allow_paid_broadcast,
reply_markup=reply_markup,
business_connection_id=business_connection_id
)
10 changes: 9 additions & 1 deletion pyrogram/methods/messages/forward_media_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ async def forward_media_group(
schedule_date: datetime = None,
hide_sender_name: bool = None,
hide_captions: bool = None,
protect_content: bool = None
protect_content: bool = None,
allow_paid_broadcast: bool = None
) -> List["types.Message"]:
"""Forward a media group by providing one of the message ids.
Expand Down Expand Up @@ -75,6 +76,12 @@ async def forward_media_group(
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
allow_paid_broadcast (``bool``, *optional*):
If True, you will be allowed to send up to 1000 messages per second.
Ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message.
The relevant Stars will be withdrawn from the bot's balance.
For bots only.
Returns:
List of :obj:`~pyrogram.types.Message`: On success, a list of forwarded messages is returned.
Expand All @@ -97,6 +104,7 @@ async def forward_media_group(
drop_author=hide_sender_name,
drop_media_captions=hide_captions,
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
top_msg_id=message_thread_id
)
)
Expand Down
11 changes: 10 additions & 1 deletion pyrogram/methods/messages/forward_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ async def forward_messages(
schedule_date: datetime = None,
hide_sender_name: bool = None,
hide_captions: bool = None,
protect_content: bool = None
protect_content: bool = None,
allow_paid_broadcast: bool = None
) -> Union["types.Message", List["types.Message"]]:
"""Forward messages of any kind.
Expand Down Expand Up @@ -75,6 +76,13 @@ async def forward_messages(
protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving.
allow_paid_broadcast (``bool``, *optional*):
If True, you will be allowed to send up to 1000 messages per second.
Ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message.
The relevant Stars will be withdrawn from the bot's balance.
For bots only.
Returns:
:obj:`~pyrogram.types.Message` | List of :obj:`~pyrogram.types.Message`: In case *message_ids* was not
a list, a single message is returned, otherwise a list of messages is returned.
Expand Down Expand Up @@ -103,6 +111,7 @@ async def forward_messages(
drop_author=hide_sender_name,
drop_media_captions=hide_captions,
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
top_msg_id=message_thread_id
)
)
Expand Down
8 changes: 8 additions & 0 deletions pyrogram/methods/messages/send_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ async def send_animation(
schedule_date: datetime = None,
protect_content: bool = None,
business_connection_id: str = None,
allow_paid_broadcast: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
Expand Down Expand Up @@ -158,6 +159,12 @@ async def send_animation(
business_connection_id (``str``, *optional*):
Unique identifier of the business connection on behalf of which the message will be sent.
allow_paid_broadcast (``bool``, *optional*):
If True, you will be allowed to send up to 1000 messages per second.
Ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message.
The relevant Stars will be withdrawn from the bot's balance.
For bots only.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
Expand Down Expand Up @@ -279,6 +286,7 @@ async def progress(current, total):
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
reply_markup=await reply_markup.write(self) if reply_markup else None,
effect=effect_id,
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
Expand Down
8 changes: 8 additions & 0 deletions pyrogram/methods/messages/send_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ async def send_audio(
schedule_date: datetime = None,
protect_content: bool = None,
business_connection_id: str = None,
allow_paid_broadcast: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
Expand Down Expand Up @@ -151,6 +152,12 @@ async def send_audio(
business_connection_id (``str``, *optional*):
Unique identifier of the business connection on behalf of which the message will be sent.
allow_paid_broadcast (``bool``, *optional*):
If True, you will be allowed to send up to 1000 messages per second.
Ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message.
The relevant Stars will be withdrawn from the bot's balance.
For bots only.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
Expand Down Expand Up @@ -272,6 +279,7 @@ async def progress(current, total):
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
reply_markup=await reply_markup.write(self) if reply_markup else None,
effect=effect_id,
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
Expand Down
8 changes: 8 additions & 0 deletions pyrogram/methods/messages/send_cached_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ async def send_cached_media(
has_spoiler: bool = None,
show_caption_above_media: bool = None,
business_connection_id: str = None,
allow_paid_broadcast: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
Expand Down Expand Up @@ -118,6 +119,12 @@ async def send_cached_media(
business_connection_id (``str``, *optional*):
Unique identifier of the business connection on behalf of which the message will be sent.
allow_paid_broadcast (``bool``, *optional*):
If True, you will be allowed to send up to 1000 messages per second.
Ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message.
The relevant Stars will be withdrawn from the bot's balance.
For bots only.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
Expand Down Expand Up @@ -151,6 +158,7 @@ async def send_cached_media(
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
reply_markup=await reply_markup.write(self) if reply_markup else None,
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
),
Expand Down
8 changes: 8 additions & 0 deletions pyrogram/methods/messages/send_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async def send_contact(
schedule_date: datetime = None,
protect_content: bool = None,
business_connection_id: str = None,
allow_paid_broadcast: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
Expand Down Expand Up @@ -115,6 +116,12 @@ async def send_contact(
business_connection_id (``str``, *optional*):
Unique identifier of the business connection on behalf of which the message will be sent.
allow_paid_broadcast (``bool``, *optional*):
If True, you will be allowed to send up to 1000 messages per second.
Ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message.
The relevant Stars will be withdrawn from the bot's balance.
For bots only.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
Expand Down Expand Up @@ -151,6 +158,7 @@ async def send_contact(
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
reply_markup=await reply_markup.write(self) if reply_markup else None,
effect=effect_id
),
Expand Down
8 changes: 8 additions & 0 deletions pyrogram/methods/messages/send_dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ async def send_dice(
schedule_date: datetime = None,
protect_content: bool = None,
business_connection_id: str = None,
allow_paid_broadcast: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
Expand Down Expand Up @@ -109,6 +110,12 @@ async def send_dice(
business_connection_id (``str``, *optional*):
Unique identifier of the business connection on behalf of which the message will be sent.
allow_paid_broadcast (``bool``, *optional*):
If True, you will be allowed to send up to 1000 messages per second.
Ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message.
The relevant Stars will be withdrawn from the bot's balance.
For bots only.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
Expand Down Expand Up @@ -148,6 +155,7 @@ async def send_dice(
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
reply_markup=await reply_markup.write(self) if reply_markup else None,
message="",
effect=effect_id
Expand Down
8 changes: 8 additions & 0 deletions pyrogram/methods/messages/send_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ async def send_document(
schedule_date: datetime = None,
protect_content: bool = None,
business_connection_id: str = None,
allow_paid_broadcast: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
Expand Down Expand Up @@ -143,6 +144,12 @@ async def send_document(
business_connection_id (``str``, *optional*):
Unique identifier of the business connection on behalf of which the message will be sent.
allow_paid_broadcast (``bool``, *optional*):
If True, you will be allowed to send up to 1000 messages per second.
Ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message.
The relevant Stars will be withdrawn from the bot's balance.
For bots only.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
Expand Down Expand Up @@ -244,6 +251,7 @@ async def progress(current, total):
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
reply_markup=await reply_markup.write(self) if reply_markup else None,
effect=effect_id,
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
Expand Down
8 changes: 8 additions & 0 deletions pyrogram/methods/messages/send_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ async def send_location(
schedule_date: datetime = None,
protect_content: bool = None,
business_connection_id: str = None,
allow_paid_broadcast: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
Expand Down Expand Up @@ -105,6 +106,12 @@ async def send_location(
business_connection_id (``str``, *optional*):
Unique identifier of the business connection on behalf of which the message will be sent.
allow_paid_broadcast (``bool``, *optional*):
If True, you will be allowed to send up to 1000 messages per second.
Ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message.
The relevant Stars will be withdrawn from the bot's balance.
For bots only.
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user.
Expand Down Expand Up @@ -141,6 +148,7 @@ async def send_location(
random_id=self.rnd_id(),
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
reply_markup=await reply_markup.write(self) if reply_markup else None,
effect=effect_id
),
Expand Down
Loading

0 comments on commit d0b982f

Please sign in to comment.