Telegram Bot API
🌐 Türkçe

setMyCommands

Kategori: Bot bilgisi · Bot API 10.3 · Resmi dokümantasyon

Botun komut listesini ayarlar.

Dönüş değeri: Başarılı olduğunda True döndürür.

Parametreler

ParametreTürZorunluAçıklama
commandsArray of BotCommandEvetJSON BotCommand dizisi [{"command":"start","description":"Begin"}]
scopeBotCommandScopeİsteğe bağlıJSON BotCommandScope nesnesi
language_codeStringİsteğe bağlıDil kodu

Parametre açıklamaları kısa özetlerdir; tam metin için resmi dokümantasyona bakın.

Örnek istek

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());

Adım adım rehber: Telegram bot nasıl yapılır? BotFather ile adım adım bot oluşturma