• This repository has been archived on 26/Aug/2022
  • Stars
    star
    247
  • Rank 164,117 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Starter pack to host your Python Telegram Bot on Heroku for free.

Starting November 28, 2022, free Heroku Dynos, Redis and PostgreSQL will no longer be available

https://blog.heroku.com/next-chapter

Since then this repository is archived. Get Github Developers student pack if you're looking for free hosting and other services. Try Docker, docker-compose and kubernetes to build, deploy, run & orchestrate your applications.

Hosting telegram bot on Heroku for free.

Easy way to host your python telegram bot on Heroku

Deploying via Heroku Toolbelt (CLI)

Install Heroku Toolbelt, then:

Clone repository

git clone https://github.com/Kylmakalle/heroku-telegram-bot.git

Edit files

  1. Edit bot.py file with your code

    1. ATTENTION! Do not collapse/delete/comment some_token = os.environ[SOME_TOKEN] style stings (you can delete redis setup line if you do not need it), do not change them with your REAL tokens, all tokens will be setted up below in this guide!

    2. More About Config Vars

    3. Also, don't do like this, it's insecure, realy.

  2. Edit requirments.txt with your code's dependencies

  3. Specify your python runtime, avaliable versions listed here

Go to command line

cd heroku-telegram-bot
heroku login
heroku create --region eu appname # create app in eu region, common regions: eu, us
heroku addons:create heroku-redis:hobby-dev -a appname # (Optionaly) installing redis
heroku buildpacks:set heroku/python # set python buildpack
git push heroku master # deploy app to heroku
heroku config:set TELEGRAM_TOKEN=123456789:AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLL # set config vars, insert your own
heroku config:set SOME_API_TOKEN=qwertyuiop1234567890
                ...
heroku ps:scale bot=1 # start bot dyno
heroku logs --tail # If for some reason it’s not working, check the logs
heroku ps:stop bot #stop bot dyno

Deploying via Heroku Dashboard (GUI)

  1. Fork this repo to your account.

  2. Edit files

  3. Go to Dashboard, login, Press New and choose Create new app.

  4. Fill in an App Name and choose Runtime Region.

  5. Connect your GitHub repo at Deploy page.

  6. Setup Automatics deploys (Optionaly).

  7. Deploy a GitHub branch.

  8. Then go to a Settings page, click Reveal Config Vars and then add your own, for example: Config Vars

  9. Finally, go to the Resources page.

    1. Install Heroku Redis add-on (Optionaly)
    2. Press on a small pen button, move slider and then click Confirm, that will start bot dyno.
    3. Simply move slider back if you need to stop bot dyno, remember to click Confirm.
    4. If for some reason it’s not working, check the logs here

    Logs

More about

Thanks to Roman Zaynetdinov for awesome and easy CLI guide.