Bot profili
setMyCommands
Ilovada ko'rsatiladigan buyruqlar ro'yxatini o'rnatadi.
POST
https://api.zamin.app/bot<TOKEN>/setMyCommandsGET ham ishlaydi. Parametrlar: query, JSON, form yoki multipart — batafsil.
Buyruqlar ro'yxatini butunlay almashtiradi. Ro'yxat bot profilida va chatdagi buyruqlar menyusida ko'rinadi. Barcha foydalanuvchilar va tillar uchun bitta ro'yxat: Telegram'dagi scope va language_code e'tiborga olinmaydi.
Parametrlar
| Parametr | Turi | Majburiy | Cheklov | Izoh |
|---|---|---|---|---|
commands | Array of BotCommand | Majburiy | ≤100 ta | command: 1–32 belgi, faqat a-z 0-9 _ (kichik harf, / belgisisiz). description: 1–256 belgi. |
Javob
Natija (result): true
JSON
{"ok": true, "result": true}Xatolar
| Kod | Tavsif | Sabab va yechim |
|---|---|---|
| 400 | Bad Request: commands.0.command: command must be 1-32 characters: a-z, 0-9, _ | Buyruq nomida katta harf, / yoki boshqa belgi bor. |
| 400 | Bad Request: commands.0.description: … | Tavsif bo'sh yoki 256 belgidan uzun. |
| 400 | Bad Request: commands: … | Massiv emas yoki 100 tadan ko'p. |
Istalgan metodda bo'lishi mumkin: 401 Unauthorized, 403 Forbidden: bot is suspended, 429 Too Many Requests, 400 Bad Request: <maydon>: … — xato kodlari.
Misol
Python
import os
import requests
TOKEN = os.environ["ZAMIN_BOT_TOKEN"]
API = f"https://api.zamin.app/bot{TOKEN}"
commands = [
{"command": "start", "description": "Boshlash"},
{"command": "help", "description": "Yordam"},
{"command": "ob_havo", "description": "Bugungi ob-havo"},
]
r = requests.post(f"{API}/setMyCommands", json={"commands": commands}, timeout=15)
print(r.json())curl
curl -s -X POST "https://api.zamin.app/bot$ZAMIN_BOT_TOKEN/setMyCommands" \
-H "Content-Type: application/json" \
-d '{
"commands": [
{"command": "start", "description": "Boshlash"},
{"command": "help", "description": "Yordam"}
]
}'