1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

has_spoiler parameter

Added the parameter has_spoiler to the methods sendPhoto, sendVideo, and sendAnimation.
This commit is contained in:
coder2020official 2022-12-30 19:20:23 +04:00
parent f0a1cefdda
commit 4d11e97c25
4 changed files with 56 additions and 18 deletions

View File

@ -1763,7 +1763,8 @@ class TeleBot:
allow_sending_without_reply: Optional[bool]=None, allow_sending_without_reply: Optional[bool]=None,
reply_markup: Optional[REPLY_MARKUP_TYPES]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None,
timeout: Optional[int]=None, timeout: Optional[int]=None,
message_thread_id: Optional[int]=None) -> types.Message: message_thread_id: Optional[int]=None,
has_spoiler: Optional[bool]=None) -> types.Message:
""" """
Use this method to send photos. On success, the sent Message is returned. Use this method to send photos. On success, the sent Message is returned.
@ -1808,6 +1809,9 @@ class TeleBot:
:param message_thread_id: Identifier of a message thread, in which the message will be sent :param message_thread_id: Identifier of a message thread, in which the message will be sent
:type message_thread_id: :obj:`int` :type message_thread_id: :obj:`int`
:param has_spoiler: Pass True, if the photo should be sent as a spoiler
:type has_spoiler: :obj:`bool`
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message` :rtype: :class:`telebot.types.Message`
@ -1821,7 +1825,7 @@ class TeleBot:
apihelper.send_photo( apihelper.send_photo(
self.token, chat_id, photo, caption, reply_to_message_id, reply_markup, self.token, chat_id, photo, caption, reply_to_message_id, reply_markup,
parse_mode, disable_notification, timeout, caption_entities, parse_mode, disable_notification, timeout, caption_entities,
allow_sending_without_reply, protect_content, message_thread_id)) allow_sending_without_reply, protect_content, message_thread_id, has_spoiler))
# TODO: Rewrite this method like in API. # TODO: Rewrite this method like in API.
def send_audio( def send_audio(
@ -2171,7 +2175,8 @@ class TeleBot:
reply_markup: Optional[REPLY_MARKUP_TYPES]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None,
timeout: Optional[int]=None, timeout: Optional[int]=None,
data: Optional[Union[Any, str]]=None, data: Optional[Union[Any, str]]=None,
message_thread_id: Optional[int]=None) -> types.Message: message_thread_id: Optional[int]=None,
has_spoiler: Optional[bool]=None) -> types.Message:
""" """
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
@ -2233,6 +2238,9 @@ class TeleBot:
:param message_thread_id: Identifier of a message thread, in which the video will be sent :param message_thread_id: Identifier of a message thread, in which the video will be sent
:type message_thread_id: :obj:`int` :type message_thread_id: :obj:`int`
:param has_spoiler: Pass True, if the video should be sent as a spoiler
:type has_spoiler: :obj:`bool`
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message` :rtype: :class:`telebot.types.Message`
""" """
@ -2249,7 +2257,7 @@ class TeleBot:
apihelper.send_video( apihelper.send_video(
self.token, chat_id, video, duration, caption, reply_to_message_id, reply_markup, self.token, chat_id, video, duration, caption, reply_to_message_id, reply_markup,
parse_mode, supports_streaming, disable_notification, timeout, thumb, width, height, parse_mode, supports_streaming, disable_notification, timeout, thumb, width, height,
caption_entities, allow_sending_without_reply, protect_content, message_thread_id)) caption_entities, allow_sending_without_reply, protect_content, message_thread_id, has_spoiler))
def send_animation( def send_animation(
self, chat_id: Union[int, str], animation: Union[Any, str], self, chat_id: Union[int, str], animation: Union[Any, str],
@ -2266,7 +2274,8 @@ class TeleBot:
allow_sending_without_reply: Optional[bool]=None, allow_sending_without_reply: Optional[bool]=None,
reply_markup: Optional[REPLY_MARKUP_TYPES]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None,
timeout: Optional[int]=None, timeout: Optional[int]=None,
message_thread_id: Optional[int]=None) -> types.Message: message_thread_id: Optional[int]=None,
has_spoiler: Optional[bool]=None) -> types.Message:
""" """
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). 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. 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.
@ -2327,6 +2336,9 @@ class TeleBot:
:param message_thread_id: Identifier of a message thread, in which the video will be sent :param message_thread_id: Identifier of a message thread, in which the video will be sent
:type message_thread_id: :obj:`int` :type message_thread_id: :obj:`int`
:param has_spoiler: Pass True, if the animation should be sent as a spoiler
:type has_spoiler: :obj:`bool`
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message` :rtype: :class:`telebot.types.Message`
""" """
@ -2339,7 +2351,7 @@ class TeleBot:
apihelper.send_animation( apihelper.send_animation(
self.token, chat_id, animation, duration, caption, reply_to_message_id, self.token, chat_id, animation, duration, caption, reply_to_message_id,
reply_markup, parse_mode, disable_notification, timeout, thumb, reply_markup, parse_mode, disable_notification, timeout, thumb,
caption_entities, allow_sending_without_reply, protect_content, width, height, message_thread_id)) caption_entities, allow_sending_without_reply, protect_content, width, height, message_thread_id, has_spoiler))
# TODO: Rewrite this method like in API. # TODO: Rewrite this method like in API.
def send_video_note( def send_video_note(

View File

@ -459,7 +459,7 @@ def send_photo(
caption=None, reply_to_message_id=None, reply_markup=None, caption=None, reply_to_message_id=None, reply_markup=None,
parse_mode=None, disable_notification=None, timeout=None, parse_mode=None, disable_notification=None, timeout=None,
caption_entities=None, allow_sending_without_reply=None, protect_content=None, caption_entities=None, allow_sending_without_reply=None, protect_content=None,
message_thread_id=None): message_thread_id=None, has_spoiler=None):
method_url = r'sendPhoto' method_url = r'sendPhoto'
payload = {'chat_id': chat_id} payload = {'chat_id': chat_id}
files = None files = None
@ -489,6 +489,8 @@ def send_photo(
payload['protect_content'] = protect_content payload['protect_content'] = protect_content
if message_thread_id is not None: if message_thread_id is not None:
payload['message_thread_id'] = message_thread_id payload['message_thread_id'] = message_thread_id
if has_spoiler is not None:
payload['has_spoiler'] = has_spoiler
return _make_request(token, method_url, params=payload, files=files, method='post') return _make_request(token, method_url, params=payload, files=files, method='post')
@ -666,7 +668,7 @@ def send_chat_action(token, chat_id, action, timeout=None):
def send_video(token, chat_id, data, duration=None, caption=None, reply_to_message_id=None, reply_markup=None, def send_video(token, chat_id, data, duration=None, caption=None, reply_to_message_id=None, reply_markup=None,
parse_mode=None, supports_streaming=None, disable_notification=None, timeout=None, parse_mode=None, supports_streaming=None, disable_notification=None, timeout=None,
thumb=None, width=None, height=None, caption_entities=None, allow_sending_without_reply=None, protect_content=None, thumb=None, width=None, height=None, caption_entities=None, allow_sending_without_reply=None, protect_content=None,
message_thread_id=None): message_thread_id=None, has_spoiler=None):
method_url = r'sendVideo' method_url = r'sendVideo'
payload = {'chat_id': chat_id} payload = {'chat_id': chat_id}
files = None files = None
@ -710,13 +712,16 @@ def send_video(token, chat_id, data, duration=None, caption=None, reply_to_messa
payload['protect_content'] = protect_content payload['protect_content'] = protect_content
if message_thread_id: if message_thread_id:
payload['message_thread_id'] = message_thread_id payload['message_thread_id'] = message_thread_id
if has_spoiler is not None:
payload['has_spoiler'] = has_spoiler
return _make_request(token, method_url, params=payload, files=files, method='post') return _make_request(token, method_url, params=payload, files=files, method='post')
def send_animation( def send_animation(
token, chat_id, data, duration=None, caption=None, reply_to_message_id=None, reply_markup=None, token, chat_id, data, duration=None, caption=None, reply_to_message_id=None, reply_markup=None,
parse_mode=None, disable_notification=None, timeout=None, thumb=None, caption_entities=None, parse_mode=None, disable_notification=None, timeout=None, thumb=None, caption_entities=None,
allow_sending_without_reply=None, protect_content=None, width=None, height=None, message_thread_id=None): allow_sending_without_reply=None, protect_content=None, width=None, height=None, message_thread_id=None,
has_spoiler=None):
method_url = r'sendAnimation' method_url = r'sendAnimation'
payload = {'chat_id': chat_id} payload = {'chat_id': chat_id}
files = None files = None
@ -758,6 +763,8 @@ def send_animation(
payload['height'] = height payload['height'] = height
if message_thread_id: if message_thread_id:
payload['message_thread_id'] = message_thread_id payload['message_thread_id'] = message_thread_id
if has_spoiler is not None:
payload['has_spoiler'] = has_spoiler
return _make_request(token, method_url, params=payload, files=files, method='post') return _make_request(token, method_url, params=payload, files=files, method='post')

View File

@ -2627,7 +2627,8 @@ class AsyncTeleBot:
allow_sending_without_reply: Optional[bool]=None, allow_sending_without_reply: Optional[bool]=None,
reply_markup: Optional[REPLY_MARKUP_TYPES]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None,
timeout: Optional[int]=None, timeout: Optional[int]=None,
message_thread_id: Optional[int]=None) -> types.Message: message_thread_id: Optional[int]=None,
has_spoiler: Optional[bool]=None) -> types.Message:
""" """
Use this method to send photos. On success, the sent Message is returned. Use this method to send photos. On success, the sent Message is returned.
@ -2672,6 +2673,9 @@ class AsyncTeleBot:
:param message_thread_id: Identifier of a message thread, in which the message will be sent :param message_thread_id: Identifier of a message thread, in which the message will be sent
:type message_thread_id: :obj:`int` :type message_thread_id: :obj:`int`
:param has_spoiler: Pass True, if the photo should be sent as a spoiler
:type has_spoiler: :obj:`bool`
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message` :rtype: :class:`telebot.types.Message`
@ -2685,7 +2689,7 @@ class AsyncTeleBot:
await asyncio_helper.send_photo( await asyncio_helper.send_photo(
self.token, chat_id, photo, caption, reply_to_message_id, reply_markup, self.token, chat_id, photo, caption, reply_to_message_id, reply_markup,
parse_mode, disable_notification, timeout, caption_entities, parse_mode, disable_notification, timeout, caption_entities,
allow_sending_without_reply, protect_content, message_thread_id)) allow_sending_without_reply, protect_content, message_thread_id, has_spoiler))
async def send_audio( async def send_audio(
self, chat_id: Union[int, str], audio: Union[Any, str], self, chat_id: Union[int, str], audio: Union[Any, str],
@ -3031,7 +3035,8 @@ class AsyncTeleBot:
reply_markup: Optional[REPLY_MARKUP_TYPES]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None,
timeout: Optional[int]=None, timeout: Optional[int]=None,
data: Optional[Union[Any, str]]=None, data: Optional[Union[Any, str]]=None,
message_thread_id: Optional[int]=None) -> types.Message: message_thread_id: Optional[int]=None,
has_spoiler: Optional[bool]=None) -> types.Message:
""" """
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
@ -3093,6 +3098,9 @@ class AsyncTeleBot:
:param message_thread_id: Identifier of a message thread, in which the video will be sent :param message_thread_id: Identifier of a message thread, in which the video will be sent
:type message_thread_id: :obj:`int` :type message_thread_id: :obj:`int`
:param has_spoiler: Pass True, if the video should be sent as a spoiler
:type has_spoiler: :obj:`bool`
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message` :rtype: :class:`telebot.types.Message`
""" """
@ -3110,7 +3118,7 @@ class AsyncTeleBot:
await asyncio_helper.send_video( await asyncio_helper.send_video(
self.token, chat_id, video, duration, caption, reply_to_message_id, reply_markup, self.token, chat_id, video, duration, caption, reply_to_message_id, reply_markup,
parse_mode, supports_streaming, disable_notification, timeout, thumb, width, height, parse_mode, supports_streaming, disable_notification, timeout, thumb, width, height,
caption_entities, allow_sending_without_reply, protect_content, message_thread_id)) caption_entities, allow_sending_without_reply, protect_content, message_thread_id, has_spoiler))
async def send_animation( async def send_animation(
self, chat_id: Union[int, str], animation: Union[Any, str], self, chat_id: Union[int, str], animation: Union[Any, str],
@ -3127,7 +3135,8 @@ class AsyncTeleBot:
allow_sending_without_reply: Optional[bool]=None, allow_sending_without_reply: Optional[bool]=None,
reply_markup: Optional[REPLY_MARKUP_TYPES]=None, reply_markup: Optional[REPLY_MARKUP_TYPES]=None,
timeout: Optional[int]=None, timeout: Optional[int]=None,
message_thread_id: Optional[int]=None) -> types.Message: message_thread_id: Optional[int]=None,
has_spoiler: Optional[bool]=None) -> types.Message:
""" """
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). 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. 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.
@ -3188,6 +3197,9 @@ class AsyncTeleBot:
:param message_thread_id: Identifier of a message thread, in which the video will be sent :param message_thread_id: Identifier of a message thread, in which the video will be sent
:type message_thread_id: :obj:`int` :type message_thread_id: :obj:`int`
:param has_spoiler: Pass True, if the animation should be sent as a spoiler
:type has_spoiler: :obj:`bool`
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
:rtype: :class:`telebot.types.Message` :rtype: :class:`telebot.types.Message`
""" """
@ -3200,7 +3212,7 @@ class AsyncTeleBot:
await asyncio_helper.send_animation( await asyncio_helper.send_animation(
self.token, chat_id, animation, duration, caption, reply_to_message_id, self.token, chat_id, animation, duration, caption, reply_to_message_id,
reply_markup, parse_mode, disable_notification, timeout, thumb, reply_markup, parse_mode, disable_notification, timeout, thumb,
caption_entities, allow_sending_without_reply, width, height, protect_content, message_thread_id)) caption_entities, allow_sending_without_reply, width, height, protect_content, message_thread_id, has_spoiler))
async def send_video_note( async def send_video_note(
self, chat_id: Union[int, str], data: Union[Any, str], self, chat_id: Union[int, str], data: Union[Any, str],

View File

@ -453,7 +453,7 @@ async def send_photo(
caption=None, reply_to_message_id=None, reply_markup=None, caption=None, reply_to_message_id=None, reply_markup=None,
parse_mode=None, disable_notification=None, timeout=None, parse_mode=None, disable_notification=None, timeout=None,
caption_entities=None, allow_sending_without_reply=None, protect_content=None, caption_entities=None, allow_sending_without_reply=None, protect_content=None,
message_thread_id=None): message_thread_id=None, has_spoiler=None):
method_url = r'sendPhoto' method_url = r'sendPhoto'
payload = {'chat_id': chat_id} payload = {'chat_id': chat_id}
files = None files = None
@ -483,6 +483,8 @@ async def send_photo(
payload['protect_content'] = protect_content payload['protect_content'] = protect_content
if message_thread_id: if message_thread_id:
payload['message_thread_id'] = message_thread_id payload['message_thread_id'] = message_thread_id
if has_spoiler is not None:
payload['has_spoiler'] = has_spoiler
return await _process_request(token, method_url, params=payload, files=files, method='post') return await _process_request(token, method_url, params=payload, files=files, method='post')
@ -658,7 +660,7 @@ async def send_chat_action(token, chat_id, action, timeout=None):
async def send_video(token, chat_id, data, duration=None, caption=None, reply_to_message_id=None, reply_markup=None, async def send_video(token, chat_id, data, duration=None, caption=None, reply_to_message_id=None, reply_markup=None,
parse_mode=None, supports_streaming=None, disable_notification=None, timeout=None, parse_mode=None, supports_streaming=None, disable_notification=None, timeout=None,
thumb=None, width=None, height=None, caption_entities=None, allow_sending_without_reply=None, thumb=None, width=None, height=None, caption_entities=None, allow_sending_without_reply=None,
protect_content=None, message_thread_id=None): protect_content=None, message_thread_id=None, has_spoiler=None):
method_url = r'sendVideo' method_url = r'sendVideo'
payload = {'chat_id': chat_id} payload = {'chat_id': chat_id}
files = None files = None
@ -702,13 +704,16 @@ async def send_video(token, chat_id, data, duration=None, caption=None, reply_to
payload['protect_content'] = protect_content payload['protect_content'] = protect_content
if message_thread_id: if message_thread_id:
payload['message_thread_id'] = message_thread_id payload['message_thread_id'] = message_thread_id
if has_spoiler is not None:
payload['has_spoiler'] = has_spoiler
return await _process_request(token, method_url, params=payload, files=files, method='post') return await _process_request(token, method_url, params=payload, files=files, method='post')
async def send_animation( async def send_animation(
token, chat_id, data, duration=None, caption=None, reply_to_message_id=None, reply_markup=None, token, chat_id, data, duration=None, caption=None, reply_to_message_id=None, reply_markup=None,
parse_mode=None, disable_notification=None, timeout=None, thumb=None, caption_entities=None, parse_mode=None, disable_notification=None, timeout=None, thumb=None, caption_entities=None,
allow_sending_without_reply=None, width=None, height=None, protect_content=None, message_thread_id=None): allow_sending_without_reply=None, width=None, height=None, protect_content=None, message_thread_id=None,
has_spoiler=None):
method_url = r'sendAnimation' method_url = r'sendAnimation'
payload = {'chat_id': chat_id} payload = {'chat_id': chat_id}
files = None files = None
@ -750,6 +755,8 @@ async def send_animation(
payload['protect_content'] = protect_content payload['protect_content'] = protect_content
if message_thread_id: if message_thread_id:
payload['message_thread_id'] = message_thread_id payload['message_thread_id'] = message_thread_id
if has_spoiler is not None:
payload['has_spoiler'] = has_spoiler
return await _process_request(token, method_url, params=payload, files=files, method='post') return await _process_request(token, method_url, params=payload, files=files, method='post')