diff --git a/README.md b/README.md index 1959744fa..43676d2d1 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@

A simple, but extensible Python implementation for the Telegram Bot API.

Both synchronous and asynchronous.

-##

Supported Bot API version: Supported Bot API version +##

Supported Bot API version: Supported Bot API version

Official documentation

Official ru documentation

diff --git a/telebot/__init__.py b/telebot/__init__.py index a79c2ea50..62cae3f96 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -1670,7 +1670,8 @@ def send_message( reply_parameters: Optional[types.ReplyParameters]=None, link_preview_options : Optional[types.LinkPreviewOptions]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send text messages. @@ -1729,6 +1730,10 @@ def send_message( :param message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -1777,7 +1782,7 @@ def send_message( reply_markup=reply_markup, parse_mode=parse_mode, disable_notification=disable_notification, timeout=timeout, entities=entities, protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters, link_preview_options=link_preview_options, business_connection_id=business_connection_id, - message_effect_id=message_effect_id)) + message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)) def forward_message( @@ -1839,7 +1844,8 @@ def copy_message( timeout: Optional[int]=None, message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, - show_caption_above_media: Optional[bool]=None) -> types.MessageID: + show_caption_above_media: Optional[bool]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.MessageID: """ Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. @@ -1894,6 +1900,10 @@ def copy_message( :param show_caption_above_media: Pass True, if the caption must be shown above the message media. Supported only for animation, photo and video messages. :type show_caption_above_media: :obj:`bool` + + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` :return: On success, the MessageId of the sent message is returned. :rtype: :class:`telebot.types.MessageID` @@ -1926,7 +1936,7 @@ def copy_message( parse_mode=parse_mode, caption_entities=caption_entities, disable_notification=disable_notification, reply_markup=reply_markup, timeout=timeout, protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters, - show_caption_above_media=show_caption_above_media)) + show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast)) def delete_message(self, chat_id: Union[int, str], message_id: int, @@ -2076,7 +2086,8 @@ def send_dice( message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned. @@ -2121,6 +2132,10 @@ def send_dice( :param message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -2150,7 +2165,7 @@ def send_dice( self.token, chat_id, emoji=emoji, disable_notification=disable_notification, reply_markup=reply_markup, timeout=timeout, protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id, - message_effect_id=message_effect_id)) + message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)) @@ -2169,7 +2184,8 @@ def send_photo( reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, message_effect_id: Optional[str]=None, - show_caption_above_media: Optional[bool]=None) -> types.Message: + show_caption_above_media: Optional[bool]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send photos. On success, the sent Message is returned. @@ -2229,6 +2245,10 @@ def send_photo( :param show_caption_above_media: Pass True, if the caption must be shown above the message media. Supported only for animation, photo and video messages. :type show_caption_above_media: :obj:`bool` + + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` @@ -2262,7 +2282,7 @@ def send_photo( caption_entities=caption_entities, protect_content=protect_content, message_thread_id=message_thread_id, has_spoiler=has_spoiler, reply_parameters=reply_parameters, business_connection_id=business_connection_id, message_effect_id=message_effect_id, - show_caption_above_media=show_caption_above_media)) + show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast)) def send_audio( @@ -2282,7 +2302,8 @@ def send_audio( thumb: Optional[Union[Any, str]]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, @@ -2358,6 +2379,10 @@ def send_audio( :param message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -2393,7 +2418,7 @@ def send_audio( reply_markup=reply_markup, parse_mode=parse_mode, disable_notification=disable_notification, timeout=timeout, thumbnail=thumbnail, caption_entities=caption_entities, protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id, - message_effect_id=message_effect_id)) + message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)) def send_voice( @@ -2410,7 +2435,8 @@ def send_voice( message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A format (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. @@ -2467,6 +2493,10 @@ def send_voice( :param message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. """ parse_mode = self.parse_mode if (parse_mode is None) else parse_mode @@ -2497,7 +2527,7 @@ def send_voice( parse_mode=parse_mode, disable_notification=disable_notification, timeout=timeout, caption_entities=caption_entities, protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id, - message_effect_id=message_effect_id) + message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast) ) @@ -2519,7 +2549,8 @@ def send_document( thumb: Optional[Union[Any, str]]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send general files. @@ -2588,6 +2619,10 @@ def send_document( :param message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -2632,7 +2667,7 @@ def send_document( timeout=timeout, caption=caption, thumbnail=thumbnail, caption_entities=caption_entities, disable_content_type_detection=disable_content_type_detection, visible_file_name=visible_file_name, protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters, - business_connection_id=business_connection_id, message_effect_id=message_effect_id) + business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast) ) @@ -2650,7 +2685,8 @@ def send_sticker( emoji: Optional[str]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned. @@ -2702,6 +2738,10 @@ def send_sticker( :param message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -2736,7 +2776,7 @@ def send_sticker( reply_markup=reply_markup, disable_notification=disable_notification, timeout=timeout, protect_content=protect_content, message_thread_id=message_thread_id, emoji=emoji, reply_parameters=reply_parameters, business_connection_id=business_connection_id, - message_effect_id=message_effect_id) + message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast) ) @@ -2763,7 +2803,8 @@ def send_video( reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, message_effect_id: Optional[str]=None, - show_caption_above_media: Optional[bool]=None) -> types.Message: + show_caption_above_media: Optional[bool]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). @@ -2843,6 +2884,10 @@ def send_video( :param show_caption_above_media: Pass True, if the caption must be shown above the message media. Supported only for animation, photo and video messages. :type show_caption_above_media: :obj:`bool` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -2884,7 +2929,7 @@ def send_video( thumbnail=thumbnail, height=height, width=width, caption_entities=caption_entities, protect_content=protect_content, message_thread_id=message_thread_id, has_spoiler=has_spoiler, reply_parameters=reply_parameters, business_connection_id=business_connection_id, message_effect_id=message_effect_id, - show_caption_above_media=show_caption_above_media) + show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast) ) @@ -2909,7 +2954,8 @@ def send_animation( reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, message_effect_id: Optional[str]=None, - show_caption_above_media: Optional[bool]=None) -> types.Message: + show_caption_above_media: Optional[bool]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. @@ -2988,6 +3034,10 @@ def send_animation( :param show_caption_above_media: Pass True, if the caption must be shown above the message media. Supported only for animation, photo and video messages. :type show_caption_above_media: :obj:`bool` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -3024,7 +3074,7 @@ def send_animation( thumbnail=thumbnail, caption_entities=caption_entities, protect_content=protect_content, width=width, height=height, message_thread_id=message_thread_id, reply_parameters=reply_parameters, has_spoiler=has_spoiler, business_connection_id=business_connection_id, message_effect_id=message_effect_id, - show_caption_above_media=show_caption_above_media) + show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast) ) @@ -3043,7 +3093,8 @@ def send_video_note( thumb: Optional[Union[Any, str]]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned. @@ -3104,6 +3155,10 @@ def send_video_note( :param message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -3137,7 +3192,7 @@ def send_video_note( self.token, chat_id, data, duration=duration, length=length, reply_markup=reply_markup, disable_notification=disable_notification, timeout=timeout, thumbnail=thumbnail, protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters, - business_connection_id=business_connection_id, message_effect_id=message_effect_id) + business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast) ) def send_paid_media( @@ -3146,7 +3201,7 @@ def send_paid_media( show_caption_above_media: Optional[bool]=None, disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, reply_parameters: Optional[types.ReplyParameters]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None, business_connection_id: Optional[str]=None, - payload: Optional[str]=None + payload: Optional[str]=None, allow_paid_broadcast: Optional[bool]=None ) -> types.Message: """ Use this method to send paid media to channel chats. On success, the sent Message is returned. @@ -3192,6 +3247,10 @@ def send_paid_media( :param payload: Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes. :type payload: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -3201,7 +3260,7 @@ def send_paid_media( caption_entities=caption_entities, show_caption_above_media=show_caption_above_media, disable_notification=disable_notification, protect_content=protect_content, reply_parameters=reply_parameters, reply_markup=reply_markup, business_connection_id=business_connection_id, - payload=payload) + payload=payload, allow_paid_broadcast=allow_paid_broadcast) ) @@ -3218,7 +3277,8 @@ def send_media_group( message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> List[types.Message]: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> List[types.Message]: """ Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned. @@ -3258,6 +3318,10 @@ def send_media_group( :param message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, an array of Messages that were sent is returned. :rtype: List[types.Message] """ @@ -3291,7 +3355,7 @@ def send_media_group( result = apihelper.send_media_group( self.token, chat_id, media, disable_notification=disable_notification, timeout=timeout, protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters, - business_connection_id=business_connection_id, message_effect_id=message_effect_id) + business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast) return [types.Message.de_json(msg) for msg in result] @@ -3311,7 +3375,8 @@ def send_location( message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send point on the map. On success, the sent Message is returned. @@ -3370,6 +3435,10 @@ def send_location( :parameter message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -3400,7 +3469,7 @@ def send_location( disable_notification=disable_notification, timeout=timeout, horizontal_accuracy=horizontal_accuracy, heading=heading, proximity_alert_radius=proximity_alert_radius, protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id, - message_effect_id=message_effect_id) + message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast) ) @@ -3531,7 +3600,8 @@ def send_venue( message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send information about a venue. On success, the sent Message is returned. @@ -3597,6 +3667,10 @@ def send_venue( :param message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -3627,7 +3701,7 @@ def send_venue( foursquare_type=foursquare_type, disable_notification=disable_notification, reply_markup=reply_markup, timeout=timeout, google_place_id=google_place_id, google_place_type=google_place_type, protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id, - message_effect_id=message_effect_id) + message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast) ) @@ -3643,7 +3717,8 @@ def send_contact( protect_content: Optional[bool]=None, message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send phone contacts. On success, the sent Message is returned. @@ -3696,6 +3771,10 @@ def send_contact( :param message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -3725,7 +3804,7 @@ def send_contact( self.token, chat_id, phone_number, first_name, last_name=last_name, vcard=vcard, disable_notification=disable_notification, reply_markup=reply_markup, timeout=timeout, protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters, - business_connection_id=business_connection_id, message_effect_id=message_effect_id) + business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast) ) @@ -4890,10 +4969,11 @@ def edit_message_media( business_connection_id: Optional[str]=None, timeout: Optional[int]=None) -> Union[types.Message, bool]: """ - Use this method to edit animation, audio, document, photo, or video messages. - If a message is a part of a message album, then it can be edited only to a photo or a video. - Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded. - Use previously uploaded file via its file_id or specify a URL. + Use this method to edit animation, audio, document, photo, or video messages, or to add media to text messages. + If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. + When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. + On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. Telegram documentation: https://core.telegram.org/bots/api#editmessagemedia @@ -4982,7 +5062,8 @@ def send_game( message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Used to send the game. @@ -5024,6 +5105,10 @@ def send_game( :param message_effect_id: Unique identifier of the message effect :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :obj:`types.Message` """ @@ -5056,7 +5141,7 @@ def send_game( self.token, chat_id, game_short_name, disable_notification=disable_notification, reply_markup=reply_markup, timeout=timeout, protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id, - message_effect_id=message_effect_id) + message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast) ) @@ -5161,7 +5246,8 @@ def send_invoice( protect_content: Optional[bool]=None, message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Sends invoice. @@ -5270,6 +5356,10 @@ def send_invoice( :param message_effect_id: The identifier of a message effect, which will be applied to the sent message :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :obj:`types.Message` """ @@ -5309,7 +5399,7 @@ def send_invoice( provider_data=provider_data, timeout=timeout, protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters, max_tip_amount=max_tip_amount, suggested_tip_amounts=suggested_tip_amounts, - message_effect_id=message_effect_id) + message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast) ) def create_invoice_link(self, @@ -5441,7 +5531,8 @@ def send_poll( business_connection_id: Optional[str]=None, question_parse_mode: Optional[str] = None, question_entities: Optional[List[types.MessageEntity]] = None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send a native poll. On success, the sent Message is returned. @@ -5523,6 +5614,10 @@ def send_poll( :param message_effect_id: Unique identifier of the message effect to apply to the sent message :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :obj:`types.Message` """ @@ -5578,7 +5673,7 @@ def send_poll( protect_content=protect_content, message_thread_id=message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id, question_parse_mode=question_parse_mode, question_entities=question_entities, - message_effect_id=message_effect_id) + message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast) ) diff --git a/telebot/apihelper.py b/telebot/apihelper.py index c46b108c8..92d419c45 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -245,7 +245,7 @@ def send_message( parse_mode=None, disable_notification=None, timeout=None, entities=None, protect_content=None, message_thread_id=None, reply_parameters=None, link_preview_options=None, - business_connection_id=None, message_effect_id=None): + business_connection_id=None, message_effect_id=None, allow_paid_broadcast=None): method_url = r'sendMessage' payload = {'chat_id': str(chat_id), 'text': text} if link_preview_options is not None: @@ -270,6 +270,8 @@ def send_message( payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload, method='post') @@ -428,7 +430,7 @@ def forward_message( def copy_message(token, chat_id, from_chat_id, message_id, caption=None, parse_mode=None, caption_entities=None, disable_notification=None, reply_markup=None, timeout=None, protect_content=None, message_thread_id=None, - reply_parameters=None, show_caption_above_media=None): + reply_parameters=None, show_caption_above_media=None, allow_paid_broadcast=None): method_url = r'copyMessage' payload = {'chat_id': chat_id, 'from_chat_id': from_chat_id, 'message_id': message_id} if caption is not None: @@ -451,6 +453,8 @@ def copy_message(token, chat_id, from_chat_id, message_id, caption=None, parse_m payload['message_thread_id'] = message_thread_id if show_caption_above_media is not None: payload['show_caption_above_media'] = show_caption_above_media + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload) @@ -458,7 +462,7 @@ def send_dice( token, chat_id, emoji=None, disable_notification=None, reply_markup=None, timeout=None, protect_content=None, message_thread_id=None, reply_parameters=None, - business_connection_id=None, message_effect_id=None): + business_connection_id=None, message_effect_id=None, allow_paid_broadcast=None): method_url = r'sendDice' payload = {'chat_id': chat_id} if emoji: @@ -479,6 +483,8 @@ def send_dice( payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload) @@ -488,7 +494,7 @@ def send_photo( parse_mode=None, disable_notification=None, timeout=None, caption_entities=None, protect_content=None, message_thread_id=None, has_spoiler=None, reply_parameters=None, business_connection_id=None, - message_effect_id=None, show_caption_above_media=None): + message_effect_id=None, show_caption_above_media=None, allow_paid_broadcast=None): method_url = r'sendPhoto' payload = {'chat_id': chat_id} files = None @@ -524,13 +530,15 @@ def send_photo( payload['message_effect_id'] = message_effect_id if show_caption_above_media is not None: payload['show_caption_above_media'] = show_caption_above_media + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload, files=files, method='post') def send_paid_media( token, chat_id, star_count, media, caption=None, parse_mode=None, caption_entities=None, show_caption_above_media=None, disable_notification=None, protect_content=None, reply_parameters=None, reply_markup=None, - business_connection_id=None, payload=None): + business_connection_id=None, payload=None, allow_paid_broadcast=None): method_url = r'sendPaidMedia' media_json, files = convert_input_media_array(media) _payload = {'chat_id': chat_id, 'star_count': star_count, 'media': media_json} @@ -554,6 +562,8 @@ def send_paid_media( _payload['business_connection_id'] = business_connection_id if payload: _payload['payload'] = payload + if allow_paid_broadcast is not None: + _payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request( token, method_url, params=_payload, method='post' if files else 'get', @@ -564,7 +574,7 @@ def send_media_group( token, chat_id, media, disable_notification=None, timeout=None, protect_content=None, message_thread_id=None, reply_parameters=None, business_connection_id=None, - message_effect_id=None): + message_effect_id=None, allow_paid_broadcast=None): method_url = r'sendMediaGroup' media_json, files = convert_input_media_array(media) payload = {'chat_id': chat_id, 'media': media_json} @@ -582,6 +592,8 @@ def send_media_group( payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request( token, method_url, params=payload, method='post' if files else 'get', @@ -595,7 +607,7 @@ def send_location( timeout=None, horizontal_accuracy=None, heading=None, proximity_alert_radius=None, protect_content=None, message_thread_id=None, reply_parameters=None, business_connection_id=None, - message_effect_id=None): + message_effect_id=None, allow_paid_broadcast=None): method_url = r'sendLocation' payload = {'chat_id': chat_id, 'latitude': latitude, 'longitude': longitude} if live_period: @@ -622,6 +634,8 @@ def send_location( payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload) @@ -678,7 +692,7 @@ def send_venue( foursquare_id=None, foursquare_type=None, disable_notification=None, reply_markup=None, timeout=None, google_place_id=None, google_place_type=None, protect_content=None, message_thread_id=None, reply_parameters=None, business_connection_id=None, - message_effect_id=None): + message_effect_id=None, allow_paid_broadcast=None): method_url = r'sendVenue' payload = {'chat_id': chat_id, 'latitude': latitude, 'longitude': longitude, 'title': title, 'address': address} if foursquare_id: @@ -705,6 +719,8 @@ def send_venue( payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload) @@ -712,7 +728,7 @@ def send_contact( token, chat_id, phone_number, first_name, last_name=None, vcard=None, disable_notification=None, reply_markup=None, timeout=None, protect_content=None, message_thread_id=None, reply_parameters=None, business_connection_id=None, - message_effect_id=None): + message_effect_id=None, allow_paid_broadcast=None): method_url = r'sendContact' payload = {'chat_id': chat_id, 'phone_number': phone_number, 'first_name': first_name} if last_name: @@ -735,6 +751,8 @@ def send_contact( payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload) @@ -755,7 +773,7 @@ def send_video(token, chat_id, data, duration=None, caption=None, reply_markup=N parse_mode=None, supports_streaming=None, disable_notification=None, timeout=None, thumbnail=None, width=None, height=None, caption_entities=None, protect_content=None, message_thread_id=None, has_spoiler=None, reply_parameters=None, business_connection_id=None, - message_effect_id=None, show_caption_above_media=None): + message_effect_id=None, show_caption_above_media=None, allow_paid_broadcast=None): method_url = r'sendVideo' payload = {'chat_id': chat_id} files = None @@ -805,6 +823,8 @@ def send_video(token, chat_id, data, duration=None, caption=None, reply_markup=N payload['message_effect_id'] = message_effect_id if show_caption_above_media is not None: payload['show_caption_above_media'] = show_caption_above_media + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload, files=files, method='post') @@ -813,7 +833,8 @@ def send_animation( token, chat_id, data, duration=None, caption=None, reply_markup=None, parse_mode=None, disable_notification=None, timeout=None, thumbnail=None, caption_entities=None, protect_content=None, width=None, height=None, message_thread_id=None, reply_parameters=None, - has_spoiler=None, business_connection_id=None, message_effect_id=None, show_caption_above_media=None): + has_spoiler=None, business_connection_id=None, message_effect_id=None, show_caption_above_media=None, + allow_paid_broadcast=None): method_url = r'sendAnimation' payload = {'chat_id': chat_id} files = None @@ -861,13 +882,15 @@ def send_animation( payload['message_effect_id'] = message_effect_id if show_caption_above_media is not None: payload['show_caption_above_media'] = show_caption_above_media + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload, files=files, method='post') def send_voice(token, chat_id, voice, caption=None, duration=None, reply_markup=None, parse_mode=None, disable_notification=None, timeout=None, caption_entities=None, protect_content=None, message_thread_id=None, reply_parameters=None, business_connection_id=None, - message_effect_id=None): + message_effect_id=None, allow_paid_broadcast=None): method_url = r'sendVoice' payload = {'chat_id': chat_id} files = None @@ -899,12 +922,15 @@ def send_voice(token, chat_id, voice, caption=None, duration=None, reply_markup= payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload, files=files, method='post') def send_video_note(token, chat_id, data, duration=None, length=None, reply_markup=None, disable_notification=None, timeout=None, thumbnail=None, protect_content=None, - message_thread_id=None, reply_parameters=None,business_connection_id=None, message_effect_id=None): + message_thread_id=None, reply_parameters=None,business_connection_id=None, message_effect_id=None, + allow_paid_broadcast=None): method_url = r'sendVideoNote' payload = {'chat_id': chat_id} files = None @@ -942,13 +968,15 @@ def send_video_note(token, chat_id, data, duration=None, length=None, reply_mark payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload, files=files, method='post') def send_audio(token, chat_id, audio, caption=None, duration=None, performer=None, title=None, reply_markup=None, parse_mode=None, disable_notification=None, timeout=None, thumbnail=None, caption_entities=None, protect_content=None, message_thread_id=None, reply_parameters=None, business_connection_id=None, - message_effect_id=None): + message_effect_id=None, allow_paid_broadcast=None): method_url = r'sendAudio' payload = {'chat_id': chat_id} files = None @@ -992,6 +1020,8 @@ def send_audio(token, chat_id, audio, caption=None, duration=None, performer=Non payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload, files=files, method='post') @@ -999,7 +1029,7 @@ def send_data(token, chat_id, data, data_type, reply_markup=None, parse_mode=Non disable_notification=None, timeout=None, caption=None, thumbnail=None, caption_entities=None, disable_content_type_detection=None, visible_file_name=None, protect_content = None, message_thread_id=None, emoji=None, reply_parameters=None, business_connection_id=None, - message_effect_id=None): + message_effect_id=None, allow_paid_broadcast=None): method_url = get_method_by_type(data_type) payload = {'chat_id': chat_id} files = None @@ -1044,6 +1074,8 @@ def send_data(token, chat_id, data, data_type, reply_markup=None, parse_mode=Non payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload, files=files, method='post') @@ -1545,7 +1577,8 @@ def delete_message(token, chat_id, message_id, timeout=None): def send_game( token, chat_id, game_short_name, disable_notification=None, reply_markup=None, timeout=None, - protect_content=None, message_thread_id=None, reply_parameters=None, business_connection_id=None, message_effect_id=None): + protect_content=None, message_thread_id=None, reply_parameters=None, business_connection_id=None, message_effect_id=None, + allow_paid_broadcast=None): method_url = r'sendGame' payload = {'chat_id': chat_id, 'game_short_name': game_short_name} if disable_notification is not None: @@ -1564,6 +1597,8 @@ def send_game( payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload) @@ -1629,7 +1664,8 @@ def send_invoice( send_phone_number_to_provider = None, send_email_to_provider = None, is_flexible=None, disable_notification=None, reply_markup=None, provider_data=None, timeout=None, max_tip_amount=None, suggested_tip_amounts=None, - protect_content=None, message_thread_id=None, reply_parameters=None, message_effect_id=None): + protect_content=None, message_thread_id=None, reply_parameters=None, message_effect_id=None, + allow_paid_broadcast=None): """ Use this method to send invoices. On success, the sent Message is returned. :param token: Bot's token (you don't need to fill this) @@ -1662,6 +1698,7 @@ def send_invoice( :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param reply_parameters: A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button. :param message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only + :param allow_paid_broadcast: :return: """ method_url = r'sendInvoice' @@ -1714,6 +1751,8 @@ def send_invoice( payload['message_effect_id'] = message_effect_id if provider_token is not None: payload['provider_token'] = provider_token + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload) @@ -1974,7 +2013,8 @@ def send_poll( is_anonymous = None, type = None, allows_multiple_answers = None, correct_option_id = None, explanation = None, explanation_parse_mode=None, open_period = None, close_date = None, is_closed = None, disable_notification=False, reply_markup=None, timeout=None, explanation_entities=None, protect_content=None, message_thread_id=None, - reply_parameters=None, business_connection_id=None, question_parse_mode=None, question_entities=None, message_effect_id=None): + reply_parameters=None, business_connection_id=None, question_parse_mode=None, question_entities=None, message_effect_id=None, + allow_paid_broadcast=None): method_url = r'sendPoll' payload = { 'chat_id': str(chat_id), @@ -2025,6 +2065,8 @@ def send_poll( payload['question_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(question_entities)) if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return _make_request(token, method_url, params=payload) def create_forum_topic(token, chat_id, name, icon_color=None, icon_custom_emoji_id=None): diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index ef35d109a..75ce41346 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -3161,7 +3161,8 @@ async def send_message( reply_parameters: Optional[types.ReplyParameters]=None, link_preview_options: Optional[types.LinkPreviewOptions]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send text messages. @@ -3220,6 +3221,10 @@ async def send_message( :param message_effect_id: Unique identifier for the message effect :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -3275,7 +3280,7 @@ async def send_message( self.token, chat_id, text, reply_markup, parse_mode, disable_notification, timeout, entities, protect_content, message_thread_id, reply_parameters, link_preview_options, business_connection_id, - message_effect_id=message_effect_id)) + message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)) async def forward_message( self, chat_id: Union[int, str], from_chat_id: Union[int, str], @@ -3334,7 +3339,8 @@ async def copy_message( timeout: Optional[int]=None, message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, - show_caption_above_media: Optional[bool]=None) -> types.MessageID: + show_caption_above_media: Optional[bool]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.MessageID: """ Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, @@ -3389,6 +3395,10 @@ async def copy_message( :param show_caption_above_media: Pass True, if the caption must be shown above the message media. Supported only for animation, photo and video messages. :type show_caption_above_media: :obj:`bool` + + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` :return: On success, the MessageId of the sent message is returned. :rtype: :class:`telebot.types.MessageID` @@ -3420,7 +3430,8 @@ async def copy_message( return types.MessageID.de_json( await asyncio_helper.copy_message(self.token, chat_id, from_chat_id, message_id, caption, parse_mode, caption_entities, disable_notification, reply_markup, - timeout, protect_content, message_thread_id, reply_parameters, show_caption_above_media=show_caption_above_media)) + timeout, protect_content, message_thread_id, reply_parameters, show_caption_above_media=show_caption_above_media, + allow_paid_broadcast=allow_paid_broadcast)) async def delete_message(self, chat_id: Union[int, str], message_id: int, timeout: Optional[int]=None) -> bool: @@ -3557,7 +3568,8 @@ async def send_dice( message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned. @@ -3602,6 +3614,10 @@ async def send_dice( :param message_effect_id: Unique identifier for the message effect :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -3632,7 +3648,8 @@ async def send_dice( return types.Message.de_json( await asyncio_helper.send_dice( self.token, chat_id, emoji, disable_notification, - reply_markup, timeout, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id)) + reply_markup, timeout, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, + allow_paid_broadcast=allow_paid_broadcast)) async def send_photo( @@ -3650,7 +3667,8 @@ async def send_photo( reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, message_effect_id: Optional[str]=None, - show_caption_above_media: Optional[bool]=None) -> types.Message: + show_caption_above_media: Optional[bool]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send photos. On success, the sent Message is returned. @@ -3710,6 +3728,10 @@ async def send_photo( :param show_caption_above_media: Pass True, if the caption must be shown above the message media. Supported only for animation, photo and video messages. :type show_caption_above_media: :obj:`bool` + + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` @@ -3744,7 +3766,7 @@ async def send_photo( self.token, chat_id, photo, caption, reply_markup, parse_mode, disable_notification, timeout, caption_entities, protect_content, message_thread_id, has_spoiler, reply_parameters, business_connection_id, message_effect_id=message_effect_id, - show_caption_above_media=show_caption_above_media)) + show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast)) async def send_audio( self, chat_id: Union[int, str], audio: Union[Any, str], @@ -3763,7 +3785,8 @@ async def send_audio( thumb: Optional[Union[Any, str]]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, @@ -3839,6 +3862,10 @@ async def send_audio( :param message_effect_id: Unique identifier for the message effect :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -3875,7 +3902,7 @@ async def send_audio( await asyncio_helper.send_audio( self.token, chat_id, audio, caption, duration, performer, title, reply_markup, parse_mode, disable_notification, timeout, thumbnail, - caption_entities, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id)) + caption_entities, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)) async def send_voice( self, chat_id: Union[int, str], voice: Union[Any, str], @@ -3891,7 +3918,8 @@ async def send_voice( message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A format (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. @@ -3948,6 +3976,10 @@ async def send_voice( :param message_effect_id: Unique identifier for the message effect :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. """ parse_mode = self.parse_mode if (parse_mode is None) else parse_mode @@ -3979,7 +4011,8 @@ async def send_voice( await asyncio_helper.send_voice( self.token, chat_id, voice, caption, duration, reply_markup, parse_mode, disable_notification, timeout, caption_entities, - protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id)) + protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, + allow_paid_broadcast=allow_paid_broadcast)) async def send_document( self, chat_id: Union[int, str], document: Union[Any, str], @@ -4000,7 +4033,8 @@ async def send_document( thumb: Optional[Union[Any, str]]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send general files. @@ -4069,6 +4103,10 @@ async def send_document( :param message_effect_id: Unique identifier for the message effect :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -4117,7 +4155,7 @@ async def send_document( disable_notification = disable_notification, timeout = timeout, caption = caption, thumbnail= thumbnail, caption_entities = caption_entities, disable_content_type_detection = disable_content_type_detection, visible_file_name = visible_file_name, protect_content = protect_content, - message_thread_id = message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id, message_effect_id=message_effect_id)) + message_thread_id = message_thread_id, reply_parameters=reply_parameters, business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)) async def send_sticker( self, chat_id: Union[int, str], sticker: Union[Any, str], @@ -4132,7 +4170,8 @@ async def send_sticker( emoji: Optional[str]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned. @@ -4184,6 +4223,10 @@ async def send_sticker( :param message_effect_id: Unique identifier for the message effect :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -4222,7 +4265,7 @@ async def send_sticker( reply_markup=reply_markup, disable_notification=disable_notification, timeout=timeout, protect_content=protect_content, - message_thread_id=message_thread_id, emoji=emoji, reply_parameters=reply_parameters, business_connection_id=business_connection_id, message_effect_id=message_effect_id)) + message_thread_id=message_thread_id, emoji=emoji, reply_parameters=reply_parameters, business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)) async def send_video( self, chat_id: Union[int, str], video: Union[Any, str], @@ -4247,7 +4290,8 @@ async def send_video( reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, message_effect_id: Optional[str]=None, - show_caption_above_media: Optional[bool]=None) -> types.Message: + show_caption_above_media: Optional[bool]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). @@ -4327,6 +4371,10 @@ async def send_video( :param show_caption_above_media: Pass True, if the caption must be shown above the message media. Supported only for animation, photo and video messages. :type show_caption_above_media: :obj:`bool` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -4369,7 +4417,7 @@ async def send_video( self.token, chat_id, video, duration, caption, reply_markup, parse_mode, supports_streaming, disable_notification, timeout, thumbnail, width, height, caption_entities, protect_content, message_thread_id, has_spoiler, reply_parameters, business_connection_id, message_effect_id=message_effect_id, - show_caption_above_media=show_caption_above_media)) + show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast)) async def send_animation( self, chat_id: Union[int, str], animation: Union[Any, str], @@ -4392,7 +4440,8 @@ async def send_animation( reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, message_effect_id: Optional[str]=None, - show_caption_above_media: Optional[bool]=None) -> types.Message: + show_caption_above_media: Optional[bool]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. @@ -4471,6 +4520,10 @@ async def send_animation( :param show_caption_above_media: Pass True, if the caption must be shown above the message media. Supported only for animation, photo and video messages. :type show_caption_above_media: :obj:`bool` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -4508,7 +4561,7 @@ async def send_animation( self.token, chat_id, animation, duration, caption, reply_markup, parse_mode, disable_notification, timeout, thumbnail, caption_entities, width, height, protect_content, message_thread_id, has_spoiler, reply_parameters, business_connection_id, - message_effect_id=message_effect_id, show_caption_above_media=show_caption_above_media)) + message_effect_id=message_effect_id, show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast)) async def send_video_note( self, chat_id: Union[int, str], data: Union[Any, str], @@ -4525,7 +4578,8 @@ async def send_video_note( thumb: Optional[Union[Any, str]]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned. @@ -4586,6 +4640,10 @@ async def send_video_note( :param message_effect_id: Unique identifier of the message effect :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -4620,7 +4678,8 @@ async def send_video_note( return types.Message.de_json( await asyncio_helper.send_video_note( self.token, chat_id, data, duration, length, reply_markup, - disable_notification, timeout, thumbnail, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id)) + disable_notification, timeout, thumbnail, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, + allow_paid_broadcast=allow_paid_broadcast)) async def send_paid_media( self, chat_id: Union[int, str], star_count: int, media: List[types.InputPaidMedia], @@ -4628,7 +4687,7 @@ async def send_paid_media( show_caption_above_media: Optional[bool]=None, disable_notification: Optional[bool]=None, protect_content: Optional[bool]=None, reply_parameters: Optional[types.ReplyParameters]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None, business_connection_id: Optional[str]=None, - payload: Optional[str]=None) -> types.Message: + payload: Optional[str]=None, allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send paid media to channel chats. On success, the sent Message is returned. @@ -4673,6 +4732,10 @@ async def send_paid_media( :param payload: Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes. :type payload: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -4682,7 +4745,7 @@ async def send_paid_media( caption_entities=caption_entities, show_caption_above_media=show_caption_above_media, disable_notification=disable_notification, protect_content=protect_content, reply_parameters=reply_parameters, reply_markup=reply_markup, business_connection_id=business_connection_id, - payload=payload)) + payload=payload, allow_paid_broadcast=allow_paid_broadcast)) async def send_media_group( self, chat_id: Union[int, str], @@ -4697,7 +4760,8 @@ async def send_media_group( message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> List[types.Message]: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> List[types.Message]: """ Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned. @@ -4737,6 +4801,10 @@ async def send_media_group( :param message_effect_id: Unique identifier of the message effect :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, an array of Messages that were sent is returned. :rtype: List[types.Message] """ @@ -4770,7 +4838,8 @@ async def send_media_group( reply_parameters.allow_sending_without_reply = self.allow_sending_without_reply result = await asyncio_helper.send_media_group( - self.token, chat_id, media, disable_notification, timeout, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id) + self.token, chat_id, media, disable_notification, timeout, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, + allow_paid_broadcast=allow_paid_broadcast) return [types.Message.de_json(msg) for msg in result] async def send_location( @@ -4789,7 +4858,8 @@ async def send_location( message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send point on the map. On success, the sent Message is returned. @@ -4848,6 +4918,10 @@ async def send_location( :param message_effect_id: Unique identifier of the message effect :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -4880,7 +4954,7 @@ async def send_location( self.token, chat_id, latitude, longitude, live_period, reply_markup, disable_notification, timeout, horizontal_accuracy, heading, proximity_alert_radius, - protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id)) + protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)) async def edit_message_live_location( self, latitude: float, longitude: float, @@ -5005,7 +5079,8 @@ async def send_venue( message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send information about a venue. On success, the sent Message is returned. @@ -5071,6 +5146,10 @@ async def send_venue( :param message_effect_id: Unique identifier of the message effect :type message_effect_id: :obj:`str` + + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` @@ -5103,7 +5182,8 @@ async def send_venue( await asyncio_helper.send_venue( self.token, chat_id, latitude, longitude, title, address, foursquare_id, foursquare_type, disable_notification, reply_markup, timeout, - google_place_id, google_place_type, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id)) + google_place_id, google_place_type, protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, + allow_paid_broadcast=allow_paid_broadcast)) async def send_contact( @@ -5119,7 +5199,8 @@ async def send_contact( message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send phone contacts. On success, the sent Message is returned. @@ -5173,6 +5254,10 @@ async def send_contact( :param message_effect_id: Unique identifier of the message effect :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :class:`telebot.types.Message` """ @@ -5204,7 +5289,7 @@ async def send_contact( await asyncio_helper.send_contact( self.token, chat_id, phone_number, first_name, last_name, vcard, disable_notification, reply_markup, timeout, - protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id)) + protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)) async def send_chat_action( @@ -6320,10 +6405,11 @@ async def edit_message_media( business_connection_id: Optional[str]=None, timeout: Optional[int]=None) -> Union[types.Message, bool]: """ - Use this method to edit animation, audio, document, photo, or video messages. - If a message is a part of a message album, then it can be edited only to a photo or a video. - Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded. - Use previously uploaded file via its file_id or specify a URL. + Use this method to edit animation, audio, document, photo, or video messages, or to add media to text messages. + If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. + When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. + On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. Telegram documentation: https://core.telegram.org/bots/api#editmessagemedia @@ -6406,7 +6492,8 @@ async def send_game( message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, business_connection_id: Optional[str]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Used to send the game. @@ -6448,6 +6535,10 @@ async def send_game( :param message_effect_id: Identifier of the message effect. :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :obj:`types.Message` """ @@ -6478,7 +6569,7 @@ async def send_game( result = await asyncio_helper.send_game( self.token, chat_id, game_short_name, disable_notification, reply_markup, timeout, - protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id) + protect_content, message_thread_id, reply_parameters, business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast) return types.Message.de_json(result) async def set_game_score( @@ -6577,7 +6668,8 @@ async def send_invoice( protect_content: Optional[bool]=None, message_thread_id: Optional[int]=None, reply_parameters: Optional[types.ReplyParameters]=None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Sends invoice. @@ -6686,6 +6778,10 @@ async def send_invoice( :param message_effect_id: The identifier of a message effect to be applied to the message :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :obj:`types.Message` """ @@ -6720,7 +6816,7 @@ async def send_invoice( send_phone_number_to_provider, send_email_to_provider, is_flexible, disable_notification, reply_markup, provider_data, timeout, max_tip_amount, suggested_tip_amounts, protect_content, message_thread_id, reply_parameters, - message_effect_id=message_effect_id) + message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast) return types.Message.de_json(result) @@ -6851,7 +6947,8 @@ async def send_poll( business_connection_id: Optional[str]=None, question_parse_mode: Optional[str] = None, question_entities: Optional[List[types.MessageEntity]] = None, - message_effect_id: Optional[str]=None) -> types.Message: + message_effect_id: Optional[str]=None, + allow_paid_broadcast: Optional[bool]=None) -> types.Message: """ Use this method to send a native poll. On success, the sent Message is returned. @@ -6937,6 +7034,10 @@ async def send_poll( :param message_effect_id: Identifier of the message effect to apply to the sent message :type message_effect_id: :obj:`str` + :param allow_paid_broadcast: Pass True to allow 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 + :type allow_paid_broadcast: :obj:`bool` + :return: On success, the sent Message is returned. :rtype: :obj:`types.Message` """ @@ -6989,7 +7090,7 @@ async def send_poll( disable_notification, reply_markup, timeout, explanation_entities, protect_content, message_thread_id, reply_parameters, business_connection_id, question_parse_mode=question_parse_mode, question_entities=question_entities, - message_effect_id=message_effect_id)) + message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast)) async def stop_poll( self, chat_id: Union[int, str], message_id: int, diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index 0bd447f18..b21b7f9f0 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -283,7 +283,8 @@ async def send_message( reply_markup=None, parse_mode=None, disable_notification=None, timeout=None, entities=None, protect_content=None, - message_thread_id=None, reply_parameters=None, link_preview_options=None, business_connection_id=None, message_effect_id=None): + message_thread_id=None, reply_parameters=None, link_preview_options=None, business_connection_id=None, message_effect_id=None, + allow_paid_broadcast=None): method_name = 'sendMessage' params = {'chat_id': str(chat_id), 'text': text} if link_preview_options is not None: @@ -308,6 +309,8 @@ async def send_message( params['business_connection_id'] = business_connection_id if message_effect_id: params['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + params['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_name, params=params, method='post') @@ -418,7 +421,8 @@ async def forward_message( async def copy_message(token, chat_id, from_chat_id, message_id, caption=None, parse_mode=None, caption_entities=None, disable_notification=None, - reply_markup=None, timeout=None, protect_content=None, message_thread_id=None, reply_parameters=None, show_caption_above_media=None): + reply_markup=None, timeout=None, protect_content=None, message_thread_id=None, reply_parameters=None, show_caption_above_media=None, + allow_paid_broadcast=None): method_url = r'copyMessage' payload = {'chat_id': chat_id, 'from_chat_id': from_chat_id, 'message_id': message_id} if caption is not None: @@ -441,6 +445,8 @@ async def copy_message(token, chat_id, from_chat_id, message_id, caption=None, p payload['message_thread_id'] = message_thread_id if show_caption_above_media is not None: payload['show_caption_above_media'] = show_caption_above_media + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_url, params=payload) @@ -448,7 +454,7 @@ async def send_dice( token, chat_id, emoji=None, disable_notification=None, reply_markup=None, timeout=None, protect_content=None, - message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None): + message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None, allow_paid_broadcast=None): method_url = r'sendDice' payload = {'chat_id': chat_id} if emoji: @@ -469,6 +475,8 @@ async def send_dice( payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_url, params=payload) @@ -478,7 +486,7 @@ async def send_photo( parse_mode=None, disable_notification=None, timeout=None, caption_entities=None, protect_content=None, message_thread_id=None, has_spoiler=None,reply_parameters=None, - business_connection_id=None, message_effect_id=None, show_caption_above_media=None): + business_connection_id=None, message_effect_id=None, show_caption_above_media=None, allow_paid_broadcast=None): method_url = r'sendPhoto' payload = {'chat_id': chat_id} files = None @@ -514,13 +522,15 @@ async def send_photo( payload['message_effect_id'] = message_effect_id if show_caption_above_media is not None: payload['show_caption_above_media'] = show_caption_above_media + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_url, params=payload, files=files, method='post') async def send_paid_media( token, chat_id, star_count, media, caption=None, parse_mode=None, caption_entities=None, show_caption_above_media=None, disable_notification=None, protect_content=None, reply_parameters=None, reply_markup=None, - business_connection_id=None, payload=None): + business_connection_id=None, payload=None, allow_paid_broadcast=None): method_url = r'sendPaidMedia' media_json, files = convert_input_media_array(media) _payload = {'chat_id': chat_id, 'star_count': star_count, 'media': media_json} @@ -545,6 +555,8 @@ async def send_paid_media( _payload['business_connection_id'] = business_connection_id if payload: _payload['payload'] = payload + if allow_paid_broadcast is not None: + _payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request( token, method_url, params=_payload, @@ -554,7 +566,8 @@ async def send_paid_media( async def send_media_group( token, chat_id, media, disable_notification=None, - timeout=None, protect_content=None, message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None): + timeout=None, protect_content=None, message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None, + allow_paid_broadcast=None): method_url = r'sendMediaGroup' media_json, files = await convert_input_media_array(media) payload = {'chat_id': chat_id, 'media': media_json} @@ -572,6 +585,8 @@ async def send_media_group( payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request( token, method_url, params=payload, method='post' if files else 'get', @@ -584,7 +599,7 @@ async def send_location( reply_markup=None, disable_notification=None, timeout=None, horizontal_accuracy=None, heading=None, proximity_alert_radius=None, protect_content=None, message_thread_id=None,reply_parameters=None, business_connection_id=None, - message_effect_id=None): + message_effect_id=None, allow_paid_broadcast=None): method_url = r'sendLocation' payload = {'chat_id': chat_id, 'latitude': latitude, 'longitude': longitude} if live_period: @@ -611,6 +626,8 @@ async def send_location( payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_url, params=payload) @@ -668,7 +685,7 @@ async def send_venue( reply_markup=None, timeout=None, google_place_id=None, google_place_type=None, protect_content=None, message_thread_id=None,reply_parameters=None, business_connection_id=None, - message_effect_id=None): + message_effect_id=None, allow_paid_broadcast=None): method_url = r'sendVenue' payload = {'chat_id': chat_id, 'latitude': latitude, 'longitude': longitude, 'title': title, 'address': address} if foursquare_id: @@ -695,13 +712,16 @@ async def send_venue( payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_url, params=payload) async def send_contact( token, chat_id, phone_number, first_name, last_name=None, vcard=None, disable_notification=None, reply_markup=None, timeout=None, - protect_content=None, message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None): + protect_content=None, message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None, + allow_paid_broadcast=None): method_url = r'sendContact' payload = {'chat_id': chat_id, 'phone_number': phone_number, 'first_name': first_name} if last_name: @@ -724,6 +744,8 @@ async def send_contact( payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_url, params=payload) @@ -743,7 +765,7 @@ async def send_video(token, chat_id, data, duration=None, caption=None, reply_m parse_mode=None, supports_streaming=None, disable_notification=None, timeout=None, thumbnail=None, width=None, height=None, caption_entities=None, protect_content=None, message_thread_id=None, has_spoiler=None,reply_parameters=None, business_connection_id=None, - message_effect_id=None, show_caption_above_media=None): + message_effect_id=None, show_caption_above_media=None, allow_paid_broadcast=None): method_url = r'sendVideo' payload = {'chat_id': chat_id} files = None @@ -793,6 +815,8 @@ async def send_video(token, chat_id, data, duration=None, caption=None, reply_m payload['message_effect_id'] = message_effect_id if show_caption_above_media is not None: payload['show_caption_above_media'] = show_caption_above_media + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_url, params=payload, files=files, method='post') @@ -800,7 +824,8 @@ async def send_animation( token, chat_id, data, duration=None, caption=None, reply_markup=None, parse_mode=None, disable_notification=None, timeout=None, thumbnail=None, caption_entities=None, width=None, height=None, protect_content=None, message_thread_id=None, - has_spoiler=None,reply_parameters=None, business_connection_id=None, message_effect_id=None, show_caption_above_media=None): + has_spoiler=None,reply_parameters=None, business_connection_id=None, message_effect_id=None, show_caption_above_media=None, + allow_paid_broadcast=None): method_url = r'sendAnimation' payload = {'chat_id': chat_id} files = None @@ -848,12 +873,15 @@ async def send_animation( payload['message_effect_id'] = message_effect_id if show_caption_above_media is not None: payload['show_caption_above_media'] = show_caption_above_media + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_url, params=payload, files=files, method='post') async def send_voice(token, chat_id, voice, caption=None, duration=None, reply_markup=None, parse_mode=None, disable_notification=None, timeout=None, caption_entities=None, - protect_content=None, message_thread_id=None,reply_parameters=None,business_connection_id=None, message_effect_id=None): + protect_content=None, message_thread_id=None,reply_parameters=None,business_connection_id=None, message_effect_id=None, + allow_paid_broadcast=None): method_url = r'sendVoice' payload = {'chat_id': chat_id} files = None @@ -885,12 +913,14 @@ async def send_voice(token, chat_id, voice, caption=None, duration=None, reply_ payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_url, params=payload, files=files, method='post') async def send_video_note(token, chat_id, data, duration=None, length=None, reply_markup=None, disable_notification=None, timeout=None, thumbnail=None, protect_content=None, - message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None): + message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None, allow_paid_broadcast=None): method_url = r'sendVideoNote' payload = {'chat_id': chat_id} files = None @@ -928,13 +958,15 @@ async def send_video_note(token, chat_id, data, duration=None, length=None, rep payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_url, params=payload, files=files, method='post') async def send_audio(token, chat_id, audio, caption=None, duration=None, performer=None, title=None, reply_markup=None, parse_mode=None, disable_notification=None, timeout=None, thumbnail=None, caption_entities=None, protect_content=None, message_thread_id=None,reply_parameters=None, business_connection_id=None, - message_effect_id=None): + message_effect_id=None, allow_paid_broadcast=None): method_url = r'sendAudio' payload = {'chat_id': chat_id} files = None @@ -978,13 +1010,16 @@ async def send_audio(token, chat_id, audio, caption=None, duration=None, perform payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_url, params=payload, files=files, method='post') async def send_data(token, chat_id, data, data_type, reply_markup=None, parse_mode=None, disable_notification=None, timeout=None, caption=None, thumbnail=None, caption_entities=None, disable_content_type_detection=None, visible_file_name=None, protect_content=None, - message_thread_id=None, emoji=None,reply_parameters=None, business_connection_id=None, message_effect_id=None): + message_thread_id=None, emoji=None,reply_parameters=None, business_connection_id=None, message_effect_id=None, + allow_paid_broadcast=None): method_url = await get_method_by_type(data_type) payload = {'chat_id': chat_id} files = None @@ -1029,6 +1064,8 @@ async def send_data(token, chat_id, data, data_type, reply_markup=None, parse_m payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_url, params=payload, files=files, method='post') @@ -1528,7 +1565,8 @@ async def delete_message(token, chat_id, message_id, timeout=None): async def send_game( token, chat_id, game_short_name, disable_notification=None, reply_markup=None, timeout=None, - protect_content=None, message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None): + protect_content=None, message_thread_id=None,reply_parameters=None, business_connection_id=None, message_effect_id=None, + allow_paid_broadcast=None): method_url = r'sendGame' payload = {'chat_id': chat_id, 'game_short_name': game_short_name} if disable_notification is not None: @@ -1547,6 +1585,8 @@ async def send_game( payload['business_connection_id'] = business_connection_id if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_url, params=payload) @@ -1612,7 +1652,7 @@ async def send_invoice( send_phone_number_to_provider = None, send_email_to_provider = None, is_flexible=None, disable_notification=None, reply_markup=None, provider_data=None, timeout=None, max_tip_amount=None, suggested_tip_amounts=None, - protect_content=None, message_thread_id=None, reply_parameters=None, message_effect_id=None): + protect_content=None, message_thread_id=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None): """ Use this method to send invoices. On success, the sent Message is returned. :param token: Bot's token (you don't need to fill this) @@ -1646,6 +1686,7 @@ async def send_invoice( :param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only :param reply_parameters: A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button. :param message_effect_id: Unique identifier of the message effect to be added to the message; for private chats only + :param allow_paid_broadcast: :return: """ method_url = r'sendInvoice' @@ -1698,6 +1739,8 @@ async def send_invoice( payload['message_effect_id'] = message_effect_id if provider_token is not None: payload['provider_token'] = provider_token + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_url, params=payload) @@ -1954,7 +1997,8 @@ async def send_poll( explanation = None, explanation_parse_mode=None, open_period = None, close_date = None, is_closed = None, disable_notification=False, reply_markup=None, timeout=None, explanation_entities=None, protect_content=None, message_thread_id=None, - reply_parameters=None,business_connection_id=None, question_parse_mode=None, question_entities=None, message_effect_id=None): + reply_parameters=None,business_connection_id=None, question_parse_mode=None, question_entities=None, message_effect_id=None, + allow_paid_broadcast=None): method_url = r'sendPoll' payload = { 'chat_id': str(chat_id), @@ -2006,6 +2050,8 @@ async def send_poll( payload['question_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(question_entities)) if message_effect_id: payload['message_effect_id'] = message_effect_id + if allow_paid_broadcast is not None: + payload['allow_paid_broadcast'] = allow_paid_broadcast return await _process_request(token, method_url, params=payload) diff --git a/telebot/types.py b/telebot/types.py index 7efc260cf..a4b676c03 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -1639,11 +1639,10 @@ class MessageEntity(Dictionaryable, JsonSerializable, JsonDeserializable): Telegram Documentation: https://core.telegram.org/bots/api#messageentity - :param type: Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD), - “bot_command” (/start@jobs_bot),“url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), - “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), - “spoiler” (spoiler message), “blockquote” (block quotation), “expandable_blockquote” (collapsed-by-default block quotation), - “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), + :param type: Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag or #hashtag@chatusername), “cashtag” ($USD or $USD@chatusername), + “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), + “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “blockquote” (block quotation), + “expandable_blockquote” (collapsed-by-default block quotation), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames), “custom_emoji” (for inline custom emoji stickers) :type type: :obj:`str` @@ -2932,6 +2931,9 @@ class InlineKeyboardButton(Dictionaryable, JsonSerializable, JsonDeserializable) the first row and can only be used in invoice messages. :type pay: :obj:`bool` + :param copy_text: Optional. Description of the button that copies the specified text to the clipboard. + :type copy_text: :class:`telebot.types.CopyTextButton` + :return: Instance of the class :rtype: :class:`telebot.types.InlineKeyboardButton` """ @@ -2945,13 +2947,15 @@ def de_json(cls, json_string): obj['web_app'] = WebAppInfo.de_json(obj.get('web_app')) if 'switch_inline_query_chosen_chat' in obj: obj['switch_inline_query_chosen_chat'] = SwitchInlineQueryChosenChat.de_json(obj.get('switch_inline_query_chosen_chat')) + if 'copy_text' in obj: + obj['copy_text'] = CopyTextButton.de_json(obj.get('copy_text')) return cls(**obj) def __init__(self, text: str, url: Optional[str]=None, callback_data: Optional[str]=None, web_app: Optional[WebAppInfo]=None, switch_inline_query: Optional[str]=None, switch_inline_query_current_chat: Optional[str]=None, switch_inline_query_chosen_chat: Optional[SwitchInlineQueryChosenChat]=None, callback_game=None, pay: Optional[bool]=None, - login_url: Optional[LoginUrl]=None, **kwargs): + login_url: Optional[LoginUrl]=None, copy_text: Optional[CopyTextButton]=None, **kwargs): self.text: str = text self.url: Optional[str] = url self.callback_data: Optional[str] = callback_data @@ -2962,6 +2966,7 @@ def __init__(self, text: str, url: Optional[str]=None, callback_data: Optional[s self.callback_game = callback_game # Not Implemented self.pay: Optional[bool] = pay self.login_url: Optional[LoginUrl] = login_url + self.copy_text: Optional[CopyTextButton] = copy_text def to_json(self): return json.dumps(self.to_dict()) @@ -2986,6 +2991,8 @@ def to_dict(self): json_dict['login_url'] = self.login_url.to_dict() if self.switch_inline_query_chosen_chat is not None: json_dict['switch_inline_query_chosen_chat'] = self.switch_inline_query_chosen_chat.to_dict() + if self.copy_text is not None: + json_dict['copy_text'] = self.copy_text.to_dict() return json_dict @@ -10386,6 +10393,8 @@ def de_json(cls, json_string): return TransactionPartnerUser.de_json(obj) elif obj["type"] == "telegram_ads": return TransactionPartnerTelegramAds.de_json(obj) + elif obj["type"] == "telegram_api": + return TransactionPartnerTelegramApi.de_json(obj) elif obj["type"] == "other": return TransactionPartnerOther.de_json(obj) @@ -10421,6 +10430,33 @@ def de_json(cls, json_string): return cls(**obj) +class TransactionPartnerTelegramApi(TransactionPartner): + """ + Describes a transaction with payment for paid broadcasting. + + Telegram documentation: https://core.telegram.org/bots/api#transactionpartnertelegramapi + + :param type: Type of the transaction partner, always “telegram_api” + :type type: :obj:`str` + + :param request_count: The number of successful requests that exceeded regular limits and were therefore billed + :type request_count: :obj:`int` + + :return: Instance of the class + :rtype: :class:`TransactionPartnerTelegramApi` + """ + + def __init__(self, type, request_count, **kwargs): + self.type: str = type + self.request_count: int = request_count + + @classmethod + def de_json(cls, json_string): + if json_string is None: return None + obj = cls.check_json(json_string) + return cls(**obj) + + # noinspection PyShadowingBuiltins class TransactionPartnerUser(TransactionPartner): """ @@ -10910,3 +10946,33 @@ def de_json(cls, json_string): obj['from_user'] = User.de_json(obj['from_user']) return cls(**obj) + +class CopyTextButton(JsonSerializable, JsonDeserializable): + """ + This object represents an inline keyboard button that copies specified text to the clipboard. + + Telegram documentation: https://core.telegram.org/bots/api#copytextbutton + + :param text: The text to be copied to the clipboard; 1-256 characters + :type text: :obj:`str` + + :return: Instance of the class + :rtype: :class:`CopyTextButton` + """ + def __init__(self, text: str, **kwargs): + self.text: str = text + + def to_json(self): + return json.dumps(self.to_dict()) + + def to_dict(self): + data = { + 'text': self.text + } + return data + + @classmethod + def de_json(cls, json_string): + if json_string is None: return None + obj = cls.check_json(json_string) + return cls(**obj)