Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2008,6 +2008,51 @@ def copy_message(
video_start_timestamp=video_start_timestamp, direct_messages_topic_id=direct_messages_topic_id,
suggested_post_parameters=suggested_post_parameters
))


def approve_suggested_post(self, chat_id: Union[int, str], message_id: int, send_date: Optional[int]=None) -> bool:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

chat_id: Union[int, str] - Integer only.

chat_id Integer Yes Unique identifier for the target direct messages chat

"""
Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can_post_messages' administrator right in the corresponding channel chat. Returns True on success.

Telegram documentation: https://core.telegram.org/bots/api#approvesuggestedpost

:param chat_id: Unique identifier for the target direct messages chat
Comment thread
Badiboy marked this conversation as resolved.
:type chat_id: :obj:`int` or :obj:`str`

:param message_id: Identifier of a suggested post message to approve
:type message_id: :obj:`int`

:param send_date: Point in time (Unix timestamp) when the post is expected to be published; omit if the date has already been specified when the suggested post was created.
If specified, then the date must be not more than 2678400 seconds (30 days) in the future
:type send_date: :obj:`int`

:return: Returns True on success.
:rtype: :obj:`bool`
"""
return apihelper.approve_suggested_post(self.token, chat_id, message_id,
send_date=send_date)

def decline_suggested_post(self, chat_id: Union[int, str], message_id: int, comment: Optional[str]=None) -> bool:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same for chat/int here.

"""
Use this method to decline a suggested post in a direct messages chat. The bot must have
the 'can_manage_direct_messages' administrator right in the corresponding channel chat. Returns True on success.

Telegram documentation: https://core.telegram.org/bots/api#declinesuggestedpost

:param chat_id: Unique identifier for the target direct messages chat
:type chat_id: :obj:`int` or :obj:`str`

:param message_id: Identifier of a suggested post message to decline
:type message_id: :obj:`int`

:param comment: Comment for the creator of the suggested post; 0-128 characters
:type comment: :obj:`str`

:return: Returns True on success.
:rtype: :obj:`bool`
"""
return apihelper.decline_suggested_post(self.token, chat_id, message_id,
comment=comment)

def delete_message(self, chat_id: Union[int, str], message_id: int,
timeout: Optional[int]=None) -> bool:
Expand Down
14 changes: 14 additions & 0 deletions telebot/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,20 @@ def edit_message_reply_markup(
payload['timeout'] = timeout
return _make_request(token, method_url, params=payload, method='post')

def approve_suggested_post(token, chat_id, message_id, send_date=None):
method_url = r'approveSuggestedPost'
payload = {'chat_id': chat_id, 'message_id': message_id}
if send_date is not None:
payload['send_date'] = send_date
return _make_request(token, method_url, params=payload, method='post')

def decline_suggested_post(token, chat_id, message_id, comment=None):
method_url = r'declineSuggestedPost'
payload = {'chat_id': chat_id, 'message_id': message_id}
if comment is not None:
payload['comment'] = comment
return _make_request(token, method_url, params=payload, method='post')


def delete_message(token, chat_id, message_id, timeout=None):
method_url = r'deleteMessage'
Expand Down
44 changes: 44 additions & 0 deletions telebot/async_telebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3536,6 +3536,50 @@ async def copy_message(
direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters
)
)

async def approve_suggested_post(self, chat_id: Union[int, str], message_id: int, send_date: Optional[int]=None) -> bool:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

chat/int

"""
Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can_post_messages' administrator right in the corresponding channel chat. Returns True on success.

Telegram documentation: https://core.telegram.org/bots/api#approvesuggestedpost

:param chat_id: Unique identifier for the target direct messages chat
:type chat_id: :obj:`int` or :obj:`str`

:param message_id: Identifier of a suggested post message to approve
:type message_id: :obj:`int`

:param send_date: Point in time (Unix timestamp) when the post is expected to be published; omit if the date has already been specified when the suggested post was created.
If specified, then the date must be not more than 2678400 seconds (30 days) in the future
:type send_date: :obj:`int`

:return: Returns True on success.
:rtype: :obj:`bool`
"""
return await asyncio_helper.approve_suggested_post(self.token, chat_id, message_id,
send_date=send_date)

async def decline_suggested_post(self, chat_id: Union[int, str], message_id: int, comment: Optional[str]=None) -> bool:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

chat/int

"""
Use this method to decline a suggested post in a direct messages chat. The bot must have
the 'can_manage_direct_messages' administrator right in the corresponding channel chat. Returns True on success.

Telegram documentation: https://core.telegram.org/bots/api#declinesuggestedpost

:param chat_id: Unique identifier for the target direct messages chat
:type chat_id: :obj:`int` or :obj:`str`

:param message_id: Identifier of a suggested post message to decline
:type message_id: :obj:`int`

:param comment: Comment for the creator of the suggested post; 0-128 characters
:type comment: :obj:`str`

:return: Returns True on success.
:rtype: :obj:`bool`
"""
return await asyncio_helper.decline_suggested_post(self.token, chat_id, message_id,
comment=comment)

async def delete_message(self, chat_id: Union[int, str], message_id: int,
timeout: Optional[int]=None) -> bool:
Expand Down
15 changes: 15 additions & 0 deletions telebot/asyncio_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,21 @@ async def edit_message_reply_markup(
payload['timeout'] = timeout
return await _process_request(token, method_url, params=payload, method='post')


async def approve_suggested_post(token, chat_id, message_id, send_date=None):
method_url = r'approveSuggestedPost'
payload = {'chat_id': chat_id, 'message_id': message_id}
if send_date is not None:
payload['send_date'] = send_date
return await _process_request(token, method_url, params=payload, method='post')


async def decline_suggested_post(token, chat_id, message_id, comment=None):
method_url = r'declineSuggestedPost'
payload = {'chat_id': chat_id, 'message_id': message_id}
if comment is not None:
payload['comment'] = comment
return await _process_request(token, method_url, params=payload, method='post')

async def delete_message(token, chat_id, message_id, timeout=None):
method_url = r'deleteMessage'
Expand Down