Fonctionne sur toute Ubuntu 22.04/24.04 VPS. Coût total €3/mois — un robot n'a pas besoin de plus qu'un plan NAT.
Commandez tout plan sur notre page de plans — pour un robot, Buran NAT (€3) ça suffit. Vous obtiendrez IP, login et mot de passe par email en ~2 minutes.
ssh root@YOUR_SERVER_IP
apt update && apt upgrade -y
apt install -y python3-pip python3-venv
mkdir -p /opt/mybot && cd /opt/mybot
python3 -m venv venv
source venv/bin/activate
pip install "python-telegram-bot==21.*"
cat > bot.py <<'EOF'
from telegram.ext import ApplicationBuilder, CommandHandler
async def start(update, context):
await update.message.reply_text("Hello from Buran!")
app = ApplicationBuilder().token("YOUR_BOT_TOKEN").build()
app.add_handler(CommandHandler("start", start))
app.run_polling()
EOF
cat > /etc/systemd/system/mybot.service <<'EOF'
[Unit]
Description=My Telegram Bot
After=network-online.target
[Service]
WorkingDirectory=/opt/mybot
ExecStart=/opt/mybot/venv/bin/python bot.py
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now mybot
systemctl status mybot
C'est fait. Le bot redémarre sur le crash et le serveur redémarre. Besoin d'un chemin de mise à niveau plus tard ? Voir tous les plans.