How to deploy a telegram bot written in Python to fly.io .

I am a telegram bot developer at python. Telegram bots work on long polling and webhook. Long polling is used a lot.

I was using procfile to run long polling projects on heroku

Procfile:

worker: python worker.py

Python file: worker.py

import logging

from aiogram import Bot, Dispatcher, executor, types

API_TOKEN = 'BOT TOKEN HERE'

# Configure logging
logging.basicConfig(level=logging.INFO)

# Initialize bot and dispatcher
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)


@dp.message_handler(commands=['start', 'help'])
async def send_welcome(message: types.Message):
    """
    This handler will be called when user sends `/start` or `/help` command
    """
    await message.reply("Hi!\nI'm EchoBot!\nPowered by aiogram.")


@dp.message_handler()
async def echo(message: types.Message):
    # echo message
    await message.answer(message.text)


if __name__ == '__main__':
    executor.start_polling(dp, skip_updates=True)

How do I start long polling projects in fly.io ???

1 Like