setMyCommands
Define a lista de comandos do bot.
Retorno: Em caso de sucesso, retorna True.
Parâmetros
| Parâmetro | Tipo | Obrigatório | Descrição |
|---|---|---|---|
commands | Array of BotCommand | Sim | Array JSON de BotCommand [{"command":"start","description":"Begin"}] |
scope | BotCommandScope | Opcional | Objeto JSON BotCommandScope |
language_code | String | Opcional | Código de idioma |
Exemplo de requisição
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());
Guia passo a passo: Como criar um bot no Telegram grátis: do BotFather à primeira mensagem
Métodos relacionados
getMeRetorna informações sobre o bot.getMyCommandsRetorna a lista atual de comandos do bot.deleteMyCommandsApaga os comandos do bot.getMyNameRetorna o nome do bot.setMyNameDefine o nome do bot.getMyDescriptionRetorna a descrição do bot.setMyDescriptionDefine a descrição do bot.getMyShortDescriptionRetorna a descrição curta do bot.setMyShortDescriptionDefine a descrição curta do bot.setMyProfilePhotoDefine a foto de perfil do bot.removeMyProfilePhotoRemove a foto de perfil do bot.getUserProfilePhotosRetorna as fotos de perfil de um usuário.