setMyCommands
Establece la lista de comandos del bot.
Devuelve: Si la llamada tiene éxito, devuelve True.
Parámetros
| Parámetro | Tipo | Obligatorio | Descripción |
|---|---|---|---|
commands | Array of BotCommand | Sí | Array JSON de BotCommand [{"command":"start","description":"Iniciar"}] |
scope | BotCommandScope | Opcional | Objeto JSON BotCommandScope |
language_code | String | Opcional | Código de idioma |
Ejemplo de solicitud
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/setMyCommands" \
-H "Content-Type: application/json" \
-d '{"commands":[{"command":"start","description":"Start the bot"}]}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/setMyCommands",
json={
"commands": [
{
"command": "start",
"description": "Start the bot"
}
]
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/setMyCommands`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"commands": [
{
"command": "start",
"description": "Start the bot"
}
]
}),
});
console.log(await res.json());
Guía paso a paso: Cómo crear un bot en Telegram paso a paso: de BotFather a tu primer mensaje
Métodos relacionados
getMeDevuelve información del bot.getMyCommandsDevuelve la lista actual de comandos del bot.deleteMyCommandsElimina los comandos del bot.getMyNameDevuelve el nombre del bot.setMyNameEstablece el nombre del bot.getMyDescriptionDevuelve la descripción del bot.setMyDescriptionEstablece la descripción del bot.getMyShortDescriptionDevuelve la descripción corta del bot.setMyShortDescriptionEstablece la descripción corta del bot.setMyProfilePhotoEstablece la foto de perfil del bot.removeMyProfilePhotoElimina la foto de perfil del bot.getUserProfilePhotosDevuelve las fotos de perfil de un usuario.