Use this method to change the list of the bot's commands. See the `Telegram docs `_ for more details about bot commands. .. seealso:: :meth:`get_my_commands`, :meth:`delete_my_commands` Args: com
(
self,
commands: Sequence[BotCommand | tuple[str, str]],
scope: BotCommandScope | None = None,
language_code: str | None = 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: JSONDict | None = None,
)
| 8078 | return BotCommand.de_list(result, self) |
| 8079 | |
| 8080 | async def set_my_commands( |
| 8081 | self, |
| 8082 | commands: Sequence[BotCommand | tuple[str, str]], |
| 8083 | scope: BotCommandScope | None = None, |
| 8084 | language_code: str | None = None, |
| 8085 | *, |
| 8086 | read_timeout: ODVInput[float] = DEFAULT_NONE, |
| 8087 | write_timeout: ODVInput[float] = DEFAULT_NONE, |
| 8088 | connect_timeout: ODVInput[float] = DEFAULT_NONE, |
| 8089 | pool_timeout: ODVInput[float] = DEFAULT_NONE, |
| 8090 | api_kwargs: JSONDict | None = None, |
| 8091 | ) -> bool: |
| 8092 | """ |
| 8093 | Use this method to change the list of the bot's commands. See the |
| 8094 | `Telegram docs <https://core.telegram.org/bots/features#commands>`_ for more details about |
| 8095 | bot commands. |
| 8096 | |
| 8097 | .. seealso:: :meth:`get_my_commands`, :meth:`delete_my_commands` |
| 8098 | |
| 8099 | Args: |
| 8100 | commands (Sequence[:class:`BotCommand` | (:obj:`str`, :obj:`str`)]): A sequence |
| 8101 | of bot commands to be set as the list of the bot's commands. At most |
| 8102 | :tg-const:`telegram.constants.BotCommandLimit.MAX_COMMAND_NUMBER` commands can be |
| 8103 | specified. |
| 8104 | |
| 8105 | Note: |
| 8106 | If you pass in a sequence of :obj:`tuple`, the order of elements in each |
| 8107 | :obj:`tuple` must correspond to the order of positional arguments to create a |
| 8108 | :class:`BotCommand` instance. |
| 8109 | |
| 8110 | .. versionchanged:: 20.0 |
| 8111 | |sequenceargs| |
| 8112 | scope (:class:`telegram.BotCommandScope`, optional): An object, |
| 8113 | describing scope of users for which the commands are relevant. Defaults to |
| 8114 | :class:`telegram.BotCommandScopeDefault`. |
| 8115 | |
| 8116 | .. versionadded:: 13.7 |
| 8117 | |
| 8118 | language_code (:obj:`str`, optional): A two-letter ISO 639-1 language code. If empty, |
| 8119 | commands will be applied to all users from the given scope, for whose language |
| 8120 | there are no dedicated commands. |
| 8121 | |
| 8122 | .. versionadded:: 13.7 |
| 8123 | |
| 8124 | Returns: |
| 8125 | :obj:`bool`: On success, :obj:`True` is returned. |
| 8126 | """ |
| 8127 | cmds = [c if isinstance(c, BotCommand) else BotCommand(c[0], c[1]) for c in commands] |
| 8128 | data: JSONDict = {"commands": cmds, "scope": scope, "language_code": language_code} |
| 8129 | |
| 8130 | return await self._post( |
| 8131 | "setMyCommands", |
| 8132 | data, |
| 8133 | read_timeout=read_timeout, |
| 8134 | write_timeout=write_timeout, |
| 8135 | connect_timeout=connect_timeout, |
| 8136 | pool_timeout=pool_timeout, |
| 8137 | api_kwargs=api_kwargs, |