Orbeo

Bot API · Rehberler

Webhook’lar

Webhook ile Orbeo her güncellemeyi gerçekleştiği anda https adresinize gönderir. Başlamak için polling daha basittir; sunucuda yaşayan bir bot için webhook daha iyidir.

Webhook’u ayarlayın

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

Yalnızca https adresleri kabul edilir. Orbeo secret_token değerini X-Telegram-Bot-Api-Secret-Token başlığında geri gönderir — başka kimsenin adresinize istek gönderememesi için bunu kontrol edin.

Minimal bir sunucu

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)

Webhook yanıtında {"method": …} ile yanıt vermek o metodu çalıştırır — tek bir hızlı yanıt için kullanışlı.

Polling mi webhook mu

Güncellemeler 24 saat bekler, kısa bir kesinti hiçbir şey kaybettirmez.

Ayrıca bakın

Python ile bot · Telegram’dan taşıma · Bot API başvurusu