This repository is a template for creating Telegram bot and deploy it to Heroku. You have to follow a few simple steps to deploy it to Heroku. This bot is based on Django and DRF so you can modify it as a regular django app.
- Create your telegram bot and obtain token.
- Create your repo from this template.
- Go and register on https://www.heroku.com/
- Create an app
- Go to settings, click reveal config vars
- Add a variable with the key TOKEN and the value of your bot token
- Go to deploy, in the deployment method section click GitHub, connect your account
- Connect the repository you forked on step 2
- Click "deploy branch" and enable Automatic Deploys
- Click open app in the top right corner, then change the URL to look like this:
https://YOUR_APP.herokuapp.com/YOUR_TOKEN
. It will set the webhook for your bot. - Now, you can text your bot and it will echo your message if everything has been set up correctly
- Edit the bot/bot.py file to create your own bot.
- Push changes to your repo to update your bot.
- Install PyCharm Community:
sudo snap install pycharm-community --classic
. - Install packages:
sudo apt install postgresql libpq-dev python3-pip
. - Create your own repository from this template if you have not done so already.
- Clone your repo using PyCharm.
- Create virtualenv in PyCharm.
- Install the requirements.
- Open botnet/settings.py and change the values of USER and PASSWORD ("jiklopo" and "kartop") in the database settings.
- Configure database (";" in the end is important):
- Open terminal
- Start psql:
sudo -u postgres psql
- Create database:
CREATE DATABASE telebot;
- Connect to the db:
\c telebot
- Create User:
CREATE USER YOUR_USER WITH PASSWORD 'YOUR_PASSWORD';
Don't forget to replace YOUR_USER and YOUR_PASSWORD to the values from step 4 - Exit:
\q
- Create Configuration. Select manage.py file for the Script path, Parameters: runserver and create Environment variable TOKEN with the value of your bot token.
- Now you can start your project using the play button.