8000 API 9.1 `InputChecklist[Task]` classes and `bot.send/edit_checklist` by aelkheir · Pull Request #4857 · python-telegram-bot/python-telegram-bot · GitHub
[go: up one dir, main page]

Skip to content

API 9.1 InputChecklist[Task] classes and bot.send/edit_checklist #4857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: api-9.1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions changes/unreleased/4857.a8HRuiDRkKzrdkn9EiZxNs.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
other = "API 9.1 `InputChecklist[Task]` classes and `bot.send/edit_checklist`"
[[pull_requests]]
uid = "4857"
author_uid = "aelkheir"
closes_threads = []
2 changes: 2 additions & 0 deletions docs/source/inclusions/bot_methods.rst
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@
- Used for transferring owned unique gifts to another user.
* - :meth:`~telegram.Bot.transfer_business_account_stars`
- Used for transfering Stars from the business account balance to the bot's balance.
* - :meth:`~telegram.Bot.send_checklist`
- Used for sending a checklist on behalf of the business account.


.. raw:: html
Expand Down
2 changes: 2 additions & 0 deletions docs/source/telegram.at-tree.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ Available Types
telegram.inaccessiblemessage
telegram.inlinekeyboardbutton
telegram.inlinekeyboardmarkup
telegram.inputchecklist
telegram.inputchecklisttask
telegram.inputfile
telegram.inputmedia
telegram.inputmediaanimation
Expand Down
6 changes: 6 additions & 0 deletions docs/source/telegram.inputchecklist.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
InputChecklist
==============

.. autoclass:: telegram.InputChecklist
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/source/telegram.inputchecklisttask.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
InputChecklistTask
==================

.. autoclass:: telegram.InputChecklistTask
:members:
:show-inheritance:
3 changes: 3 additions & 0 deletions src/telegram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@
"InlineQueryResultVideo",
"InlineQueryResultVoice",
"InlineQueryResultsButton",
"InputChecklist",
"InputChecklistTask",
"InputContactMessageContent",
"InputFile",
"InputInvoiceMessageContent",
Expand Down Expand Up @@ -304,6 +306,7 @@
"warnings",
)

from telegram._inputchecklist import InputChecklist, InputChecklistTask
from telegram._payment.stars.staramount import StarAmount
from telegram._payment.stars.startransactions import StarTransaction, StarTransactions
from telegram._payment.stars.transactionpartner import (
Expand Down
83 changes: 83 additions & 0 deletions src/telegram/_bot.py
F438
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
from telegram._gifts import AcceptedGiftTypes, Gift, Gifts
from telegram._inline.inlinequeryresultsbutton import InlineQueryResultsButton
from telegram._inline.preparedinlinemessage import PreparedInlineMessage
from telegram._inputchecklist import InputChecklist
from telegram._menubutton import MenuButton
from telegram._message import Message
from telegram._messageid import MessageId
Expand Down Expand Up @@ -7555,6 +7556,86 @@ async def stop_poll(
)
return Poll.de_json(result, self)

async def send_checklist(
self,
business_connection_id: str,
chat_id: Union[int, str],
checklist: InputChecklist,
disable_notification: ODVInput[bool] = DEFAULT_NONE,
protect_content: ODVInput[bool] = DEFAULT_NONE,
message_effect_id: Optional[str] = None,
reply_parameters: Optional["ReplyParameters"] = None,
reply_markup: Optional[ReplyMarkup] = None,
*,
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
reply_to_message_id: Optional[int] = None,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: Optional[JSONDict] = None,
) -> Message:
"""
Use this method to send a checklist on behalf of a connected business account.

.. versionadded:: NEXT.VERSION

Args:
business_connection_id (:obj:`str`):
|business_id_str|.
chat_id (:obj:`int` | :obj:`str`):
Unique identifier for the target chat.
checklist (:class:`telegram.InputChecklist`):
The checklist to send.
disable_notification (:obj:`bool`, optional):
|disable_notification|
protect_content (:obj:`bool`, optional):
|protect_content|
message_effect_id (:obj:`str`, optional):
|message_effect_id|
reply_parameters (:class:`telegram.ReplyParameters`, optional):
|reply_parameters|
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional):
An object for an inline keyboard

Keyword Args:
allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
parameter for
reply_to_message_id (:obj:`int`, optional): |reply_to_msg_id|
Mutually exclusive with :paramref:`reply_parameters`, which this is a convenience
parameter for

Returns:
:class:`telegram.Message`: On success, the sent Message is returned.

Raises:
:class:`telegram.error.TelegramError`

"""
data: JSONDict = {
"chat_id": chat_id,
"checklist": checklist,
}

return await self._send_message(
"sendChecklist",
data,
disable_notification=disable_notification,
reply_markup=reply_markup,
protect_content=protect_content,
reply_parameters=reply_parameters,
message_effect_id=message_effect_id,
business_connection_id=business_connection_id,
allow_sending_without_reply=allow_sending_without_reply,
reply_to_message_id=reply_to_message_id,
read_timeout=read_timeout,
write_timeout=write_timeout,
connect_timeout=connect_timeout,
pool_timeout=pool_timeout,
api_kwargs=api_kwargs,
)

async def send_dice(
self,
chat_id: Union[int, str],
Expand Down Expand Up @@ -11274,6 +11355,8 @@ def to_dict(self, recursive: bool = True) -> JSONDict: # noqa: ARG002
"""Alias for :meth:`send_poll`"""
stopPoll = stop_poll
"""Alias for :meth:`stop_poll`"""
sendChecklist = send_checklist
"""Alias for :meth:`send_checklist`"""
sendDice = send_dice
"""Alias for :meth:`send_dice`"""
getMyCommands = get_my_commands
Expand Down
49 changes: 49 additions & 0 deletions src/telegram/_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
Document,
Gift,
InlineKeyboardMarkup,
InputChecklist,
InputMediaAudio,
InputMediaDocument,
InputMediaPhoto,
Expand Down Expand Up @@ -1471,6 +1472,54 @@ async def send_document(
allow_paid_broadcast=allow_paid_broadcast,
)

async def send_checklist(
self,
business_connection_id: str,
checklist: "InputChecklist",
disable_notification: ODVInput[bool] = DEFAULT_NONE,
reply_markup: Optional[ReplyMarkup] = None,
protect_content: ODVInput[bool] = DEFAULT_NONE,
reply_parameters: Optional["ReplyParameters"] = None,
message_effect_id: Optional[str] = None,
*,
reply_to_message_id: Optional[int] = None,
allow_sending_without_reply: ODVInput[bool] = DEFAULT_NONE,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: Optional[JSONDict] = None,
) -> "Message":
"""Shortcut for::

await bot.send_checklist(chat_id=update.effective_chat.id, *args, **kwargs)

For the documentation of the arguments, please see :meth:`telegram.Bot.send_checklist`.

.. versionadded:: NEXT.VERSION

Returns:
:class:`telegram.Message`: On success, instance representing the message posted.

"""
return await self.get_bot().send_checklist(
chat_id=self.id,
business_connection_id=business_connection_id,
checklist=checklist,
disable_notification=disable_notification,
protect_content=protect_content,
message_effect_id=message_effect_id,
reply_parameters=reply_parameters,
reply_markup=reply_markup,
reply_to_message_id=reply_to_message_id,
allow_sending_without_reply=allow_sending_without_reply,
read_timeout=read_timeout,
write_timeout=write_timeout,
connect_timeout=connect_timeout,
pool_timeout=pool_timeout,
api_kwargs=api_kwargs,
)

async def send_dice(
self,
disable_notification: ODVInput[bool] = DEFAULT_NONE,
Expand Down
Loading
0