Orbeo

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/getWebhookInfo

Faqat 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

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