Skip to content

Commit

Permalink
Add allow_paid_broadcast parameter to methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe authored Nov 4, 2024
1 parent beadfe9 commit a43faba
Show file tree
Hide file tree
Showing 23 changed files with 222 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/source/releases/changes-in-this-fork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Changes in this Fork
| Scheme layer used: 192 |
+------------------------+

- Added the parameter ``allow_paid_broadcast`` to the methods :meth:`~pyrogram.Client.copy_media_group`, :meth:`~pyrogram.Client.send_game`, :meth:`~pyrogram.Client.send_invoice`, :meth:`~pyrogram.Client.forward_messages`, :meth:`~pyrogram.Client.send_animation`, :meth:`~pyrogram.Client.send_audio`, :meth:`~pyrogram.Client.send_cached_media`, :meth:`~pyrogram.Client.send_contact`, :meth:`~pyrogram.Client.send_dice`, :meth:`~pyrogram.Client.send_document`, :meth:`~pyrogram.Client.send_location`, :meth:`~pyrogram.Client.send_media_group`, :meth:`~pyrogram.Client.send_message`, :meth:`~pyrogram.Client.send_paid_media`, :meth:`~pyrogram.Client.send_photo`, :meth:`~pyrogram.Client.send_poll`, :meth:`~pyrogram.Client.send_sticker`, :meth:`~pyrogram.Client.send_venue`, :meth:`~pyrogram.Client.send_video_note`, :meth:`~pyrogram.Client.send_video`, :meth:`~pyrogram.Client.send_voice` and the bound methods :meth:`~pyrogram.types.Message.reply_game`, :meth:`~pyrogram.types.Message.reply_text`, :meth:`~pyrogram.types.Message.reply_animation`, :meth:`~pyrogram.types.Message.reply_audio`, :meth:`~pyrogram.types.Message.reply_contact`, :meth:`~pyrogram.types.Message.reply_document`, :meth:`~pyrogram.types.Message.reply_location`, :meth:`~pyrogram.types.Message.reply_media_group`, :meth:`~pyrogram.types.Message.reply_photo`, :meth:`~pyrogram.types.Message.reply_poll`, :meth:`~pyrogram.types.Message.reply_sticker`, :meth:`~pyrogram.types.Message.reply_venue`, :meth:`~pyrogram.types.Message.reply_video`, :meth:`~pyrogram.types.Message.reply_video_note`, :meth:`~pyrogram.types.Message.reply_voice`, :meth:`~pyrogram.types.Message.reply_invoice`, :meth:`~pyrogram.types.Message.forward`, :meth:`~pyrogram.types.Message.copy`, :meth:`~pyrogram.types.Message.reply_cached_media`.
- Introduced the ability to add media to existing text messages using the method :meth:`~pyrogram.Client.edit_message_media`, :meth:`~pyrogram.Client.edit_cached_media`, :meth:`~pyrogram.types.Message.edit_media`, :meth:`~pyrogram.types.Message.edit_cached_media`.
- Added the class :obj:`~pyrogram.types.CopyTextButton` and the field ``copy_text`` in the class :obj:`~pyrogram.types.InlineKeyboardButton` allowing bots to send and receive inline buttons that copy arbitrary text.
- View `new and changed <https://telegramplayground.github.io/TG-APIs/TL/diff/tdlib.html?from=190&to=192>`__ `raw API methods <https://telegramplayground.github.io/TG-APIs/TL/diff/tdesktop.html?from=190&to=192>`__.

+------------------------+
Expand All @@ -41,7 +44,6 @@ Changes in this Fork
- Added :meth:`~pyrogram.types.Message.star` bound method to the :obj:`~pyrogram.types.Message`.
- Added the field ``alternative_videos`` to the :obj:`~pyrogram.types.Message`.
- Added the fields ``connected_website`` and ``write_access_allowed`` to the :obj:`~pyrogram.types.Message`.
- Add ``copy_text`` to :obj:`~pyrogram.types.InlineKeyboardButton`.
- Fix ``chat`` being None in some cases in the :obj:`~pyrogram.types.Message`.
- Fix deleting messages does not return the count in some cases.
- View `new and changed <https://telegramplayground.github.io/TG-APIs/TL/diff/tdlib.html?from=187&to=189>`__ `raw API methods <https://telegramplayground.github.io/TG-APIs/TL/diff/tdesktop.html?from=187&to=189>`__.
Expand Down
5 changes: 5 additions & 0 deletions pyrogram/methods/bots/send_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async def send_game(
game_short_name: str,
disable_notification: bool = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
message_thread_id: int = None,
business_connection_id: str = None,
send_as: Union[int, str] = None,
Expand Down Expand Up @@ -65,6 +66,9 @@ async def send_game(
protect_content (``bool``, *optional*):
Pass True if the content of the message must be protected from forwarding and saving; for bots only.
allow_paid_broadcast (``bool``, *optional*):
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only
message_thread_id (``int``, *optional*):
If the message is in a thread, ID of the original message.
Expand Down Expand Up @@ -129,6 +133,7 @@ async def send_game(
random_id=self.rnd_id(),
send_as=await self.resolve_peer(send_as) if send_as else None,
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
effect=message_effect_id,
reply_markup=await reply_markup.write(self) if reply_markup else None
)
Expand Down
5 changes: 5 additions & 0 deletions pyrogram/methods/business/send_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ async def send_invoice(
is_flexible: bool = None,
disable_notification: bool = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
message_effect_id: int = None,
reply_parameters: "types.ReplyParameters" = None,
send_as: Union[int, str] = None,
Expand Down Expand Up @@ -147,6 +148,9 @@ async def send_invoice(
protect_content (``bool``, *optional*):
Pass True if the content of the message must be protected from forwarding and saving; for bots only.
allow_paid_broadcast (``bool``, *optional*):
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only
message_effect_id (``int`` ``64-bit``, *optional*):
Unique identifier of the message effect to be added to the message; for private chats only.
Expand Down Expand Up @@ -224,6 +228,7 @@ async def send_invoice(
random_id=self.rnd_id(),
send_as=await self.resolve_peer(send_as) if send_as else None,
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
15 changes: 15 additions & 0 deletions pyrogram/methods/messages/copy_media_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ async def copy_media_group(
message_thread_id: int = None,
send_as: Union[int, str] = None,
schedule_date: datetime = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
message_effect_id: int = None,
reply_to_message_id: int = None
) -> List["types.Message"]:
"""Copy a media group by providing one of the message ids.
Expand Down Expand Up @@ -87,6 +90,15 @@ async def copy_media_group(
schedule_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the message will be automatically sent.
protect_content (``bool``, *optional*):
Pass True if the content of the message must be protected from forwarding and saving; for bots only.
allow_paid_broadcast (``bool``, *optional*):
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only
message_effect_id (``int`` ``64-bit``, *optional*):
Unique identifier of the message effect to be added to the message; for private chats only.
Returns:
List of :obj:`~pyrogram.types.Message`: On success, a list of copied messages is returned.
Expand Down Expand Up @@ -167,6 +179,9 @@ async def copy_media_group(
reply_to=reply_to,
send_as=await self.resolve_peer(send_as) if send_as else None,
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
effect=message_effect_id,
invert_media=any(show_caption_above_media)
),
sleep_threshold=60
Expand Down
5 changes: 5 additions & 0 deletions pyrogram/methods/messages/forward_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ async def forward_messages(
message_thread_id: int = None,
disable_notification: bool = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
drop_author: bool = None,
drop_media_captions: bool = None,
send_as: Union[int, str] = None,
Expand Down Expand Up @@ -66,6 +67,9 @@ async def forward_messages(
protect_content (``bool``, *optional*):
Pass True if the content of the message must be protected from forwarding and saving; for bots only.
allow_paid_broadcast (``bool``, *optional*):
Pass True to allow the message to ignore regular broadcast limits for a fee; for bots only
drop_author (``bool``, *optional*):
Whether to forward messages without quoting the original author.
Expand Down Expand Up @@ -109,6 +113,7 @@ async def forward_messages(
drop_author=drop_author,
drop_media_captions=drop_media_captions,
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
random_id=[self.rnd_id() for _ in message_ids],
send_as=await self.resolve_peer(send_as) if send_as else None,
schedule_date=utils.datetime_to_timestamp(schedule_date),
Expand Down
5 changes: 5 additions & 0 deletions pyrogram/methods/messages/send_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ async def send_animation(
message_effect_id: int = None,
schedule_date: datetime = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
ttl_seconds: int = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
Expand Down Expand Up @@ -151,6 +152,9 @@ async def send_animation(
protect_content (``bool``, *optional*):
Pass True if the content of the message must be protected from forwarding and saving; for bots only.
allow_paid_broadcast (``bool``, *optional*):
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only
ttl_seconds (``int``, *optional*):
The message will be self-destructed in the specified time after its content was opened.
The message's self-destruct time, in seconds; must be between 0 and 60 in private chats.
Expand Down Expand Up @@ -293,6 +297,7 @@ async def progress(current, total):
send_as=await self.resolve_peer(send_as) if send_as else None,
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=message_effect_id,
invert_media=show_caption_above_media,
Expand Down
5 changes: 5 additions & 0 deletions pyrogram/methods/messages/send_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ async def send_audio(
message_effect_id: int = None,
schedule_date: datetime = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
Expand Down Expand Up @@ -139,6 +140,9 @@ async def send_audio(
protect_content (``bool``, *optional*):
Pass True if the content of the message must be protected from forwarding and saving; for bots only.
allow_paid_broadcast (``bool``, *optional*):
Pass True to allow the message to ignore regular broadcast limits for a small fee; 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 @@ -262,6 +266,7 @@ async def progress(current, total):
send_as=await self.resolve_peer(send_as) if send_as else None,
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=message_effect_id,
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
Expand Down
5 changes: 5 additions & 0 deletions pyrogram/methods/messages/send_cached_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async def send_cached_media(
send_as: Union[int, str] = None,
schedule_date: datetime = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
has_spoiler: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
Expand Down Expand Up @@ -112,6 +113,9 @@ async def send_cached_media(
protect_content (``bool``, *optional*):
Pass True if the content of the message must be protected from forwarding and saving; for bots only.
allow_paid_broadcast (``bool``, *optional*):
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only
has_spoiler (``bool``, *optional*):
True, if the message media is covered by a spoiler animation.
Expand Down Expand Up @@ -155,6 +159,7 @@ async def send_cached_media(
send_as=await self.resolve_peer(send_as) if send_as else None,
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=message_effect_id,
invert_media=show_caption_above_media,
Expand Down
5 changes: 5 additions & 0 deletions pyrogram/methods/messages/send_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ async def send_contact(
send_as: Union[int, str] = None,
schedule_date: datetime = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
message_effect_id: int = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
Expand Down Expand Up @@ -98,6 +99,9 @@ async def send_contact(
protect_content (``bool``, *optional*):
Pass True if the content of the message must be protected from forwarding and saving; for bots only.
allow_paid_broadcast (``bool``, *optional*):
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only
message_effect_id (``int`` ``64-bit``, *optional*):
Unique identifier of the message effect to be added to the message; for private chats only.
Expand Down Expand Up @@ -147,6 +151,7 @@ async def send_contact(
send_as=await self.resolve_peer(send_as) if send_as else None,
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=message_effect_id
)
Expand Down
5 changes: 5 additions & 0 deletions pyrogram/methods/messages/send_dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ async def send_dice(
send_as: Union[int, str] = None,
schedule_date: datetime = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
message_effect_id: int = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
Expand Down Expand Up @@ -90,6 +91,9 @@ async def send_dice(
protect_content (``bool``, *optional*):
Pass True if the content of the message must be protected from forwarding and saving; for bots only.
allow_paid_broadcast (``bool``, *optional*):
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only
message_effect_id (``int`` ``64-bit``, *optional*):
Unique identifier of the message effect to be added to the message; for private chats only.
Expand Down Expand Up @@ -140,6 +144,7 @@ async def send_dice(
send_as=await self.resolve_peer(send_as) if send_as else None,
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=message_effect_id,
message=""
Expand Down
5 changes: 5 additions & 0 deletions pyrogram/methods/messages/send_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ async def send_document(
message_effect_id: int = None,
schedule_date: datetime = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
"types.ReplyKeyboardMarkup",
Expand Down Expand Up @@ -133,6 +134,9 @@ async def send_document(
protect_content (``bool``, *optional*):
Pass True if the content of the message must be protected from forwarding and saving; for bots only.
allow_paid_broadcast (``bool``, *optional*):
Pass True to allow the message to ignore regular broadcast limits for a small fee; 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 @@ -254,6 +258,7 @@ async def progress(current, total):
send_as=await self.resolve_peer(send_as) if send_as else None,
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=message_effect_id,
**await utils.parse_text_entities(self, caption, parse_mode, caption_entities)
Expand Down
5 changes: 5 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(
send_as: Union[int, str] = None,
schedule_date: datetime = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
message_effect_id: int = None,
reply_markup: Union[
"types.InlineKeyboardMarkup",
Expand Down Expand Up @@ -96,6 +97,9 @@ async def send_location(
protect_content (``bool``, *optional*):
Pass True if the content of the message must be protected from forwarding and saving; for bots only.
allow_paid_broadcast (``bool``, *optional*):
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only
message_effect_id (``int`` ``64-bit``, *optional*):
Unique identifier of the message effect to be added to the message; for private chats only.
Expand Down Expand Up @@ -146,6 +150,7 @@ async def send_location(
send_as=await self.resolve_peer(send_as) if send_as else None,
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=message_effect_id
)
Expand Down
5 changes: 5 additions & 0 deletions pyrogram/methods/messages/send_media_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ async def send_media_group(
send_as: Union[int, str] = None,
schedule_date: datetime = None,
protect_content: bool = None,
allow_paid_broadcast: bool = None,
message_effect_id: int = None,
reply_to_message_id: int = None
) -> List["types.Message"]:
Expand Down Expand Up @@ -90,6 +91,9 @@ async def send_media_group(
protect_content (``bool``, *optional*):
Pass True if the content of the message must be protected from forwarding and saving; for bots only.
allow_paid_broadcast (``bool``, *optional*):
Pass True to allow the message to ignore regular broadcast limits for a small fee; for bots only
message_effect_id (``int`` ``64-bit``, *optional*):
Unique identifier of the message effect to be added to the message; for private chats only.
Expand Down Expand Up @@ -459,6 +463,7 @@ async def send_media_group(
send_as=await self.resolve_peer(send_as) if send_as else None,
schedule_date=utils.datetime_to_timestamp(schedule_date),
noforwards=protect_content,
allow_paid_floodskip=allow_paid_broadcast,
effect=message_effect_id,
invert_media=any(show_caption_above_media)
)
Expand Down
Loading

1 comment on commit a43faba

@KSKOP69
Copy link

@KSKOP69 KSKOP69 commented on a43faba Nov 4, 2024

Choose a reason for hiding this comment

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

docs ?

Please sign in to comment.