Bot API · Qo‘llanmalar
Vebhuklar
Vebhuk bilan Orbeo har bir yangilanishni sodir bo‘lgan zahoti https manzilingizga yuboradi. Boshlash uchun polling oddiyroq; serverda yashaydigan bot uchun vebhuk yaxshiroq.
Vebhukni o‘rnatish
curl -X POST https://orbeo.me/botapi/bot$T/setWebhook \
-H 'Content-Type: application/json' \
-d '{"url":"https://example.com/orbeo-hook","secret_token":"long-random-string"}'
curl https://orbeo.me/botapi/bot$T/getWebhookInfoFaqat https manzillari qabul qilinadi. Orbeo secret_tokenni X-Telegram-Bot-Api-Secret-Token sarlavhasida qaytaradi — uni tekshiring, shunda manzilingizga begona hech kim so‘rov yubora olmaydi.
Eng kichik server
from aiohttp import web
SECRET = "long-random-string"
async def hook(request):
if request.headers.get("X-Telegram-Bot-Api-Secret-Token") != SECRET:
return web.Response(status=403)
update = await request.json()
msg = update.get("message")
if msg and msg.get("text"):
# answer right in the webhook response — no extra request
return web.json_response({"method": "sendMessage",
"chat_id": msg["chat"]["id"],
"text": "You said: " + msg["text"]})
return web.json_response({})
app = web.Application()
app.router.add_post("/orbeo-hook", hook)
web.run_app(app, port=8080)Vebhuk javobidagi {"method": …} o‘sha metodni bajaradi — bitta tezkor javob uchun qulay.
Polling yoki vebhuk
getUpdates— 50 s gacha uzoq polling, bot uchun bitta polling (ikkinchisi 409 oladi). Ochiq manzil kerak emas.- Vebhuk — https kerak, yuklamani yaxshiroq ko‘taradi, bo‘sh turgan ulanish yo‘q.
- Polling’ga qaytish:
deleteWebhook.
Yangilanishlar 24 soat kutadi, shuning uchun qisqa uzilish hech narsani yo‘qotmaydi.
Shuningdek qarang
Python’dagi bot · Telegram’dan ko‘chish · Bot API ma’lumotnomasi