Orbeo

Bot API · Guides

Un bot en Python en 10 minutes

Un bot aiogram 3 complet pour Orbeo : il répond à /start, met en forme le texte, affiche des boutons, gère les clics et répète tout le reste. Si vous avez déjà écrit un bot Telegram, c’est le même code avec une seule ligne différente.

1. Obtenir un jeton

  1. Installez Orbeo et ouvrez Réglages → Mes bots → Créer un bot.
  2. Choisissez un identifiant qui se termine par bot, par exemple hello_bot.
  3. Copiez le jeton — il n’est affiché qu’une fois. Si vous le perdez, générez-en un nouveau ; l’ancien cesse de fonctionner.

2. Installer aiogram

pip install aiogram

aiogram 3 nécessite Python 3.9 ou plus récent.

3. Le bot

import asyncio
from aiogram import Bot, Dispatcher, F
from aiogram.client.session.aiohttp import AiohttpSession
from aiogram.client.telegram import TelegramAPIServer
from aiogram.filters import CommandStart
from aiogram.types import Message, CallbackQuery, InlineKeyboardMarkup, InlineKeyboardButton

TOKEN = "123:yourtoken"   # Orbeo: Settings -> My bots
bot = Bot(TOKEN, session=AiohttpSession(
    api=TelegramAPIServer.from_base("https://orbeo.me/botapi")))
dp = Dispatcher()

@dp.message(CommandStart())
async def start(message: Message):
    kb = InlineKeyboardMarkup(inline_keyboard=[[
        InlineKeyboardButton(text="👍", callback_data="like"),
        InlineKeyboardButton(text="Orbeo", url="https://orbeo.me"),
    ]])
    await message.answer("<b>Hi!</b> Send me anything.", parse_mode="HTML", reply_markup=kb)

@dp.callback_query(F.data == "like")
async def like(call: CallbackQuery):
    await call.answer("Thanks!")

@dp.message()
async def echo(message: Message):
    await message.copy_to(message.chat.id)

asyncio.run(dp.start_polling(bot))

La seule partie propre à Orbeo est la session TelegramAPIServer.from_base("https://orbeo.me/botapi"). Tout le reste, c’est de l’aiogram ordinaire.

4. Le lancer

python bot.py

Trouvez votre bot dans la recherche Orbeo par son identifiant et envoyez /start — vous recevez le message d’accueil et deux boutons. Le bouton 👍 affiche une courte notification « Thanks! ».

Autres bibliothèques

python-telegram-bot 21+ :

app = (Application.builder().token(TOKEN)
       .base_url("https://orbeo.me/botapi/bot")
       .base_file_url("https://orbeo.me/botapi/file/bot").build())

Telegraf (Node.js) — la barre oblique finale est obligatoire :

new Telegraf(TOKEN, { telegram: { apiRoot: 'https://orbeo.me/botapi/' } });

Et ensuite