It's a telegram bot that can offer various information about the rate of currencies. Ready for use an instance of this bot you can find in Telegram under the name @StrongExchangeBot.
-
You must have installed the python 3.7 and the Postgres
-
In the Postgres create a user and a database. Don't forget set this information to settings.
-
Install the requirements
pip install -r requirments.txt
-
Keep in mind for correct work you must pass at least TELEGRAM_TOKEN to environment variables
export TELEGRAM_TOKEN=_your_token_
-
Run the test server
python strong_exchange_bot/manage.py runserver
-
For expose the locale server port outside you can use ngrok.
-
For registering the webhook you can use next command
python strong_exchange_bot/manage.py set_telegram_webhook https://example.com/
-
Build the image
docker build -f Dockerfile . --tag currency-bot
-
Run a container with the host network
docker run --rm -it --network host currency-bot
Don't forget to set the next environment variables if you use strong_exchange_bot.settings.container
settings(default in the container).
-
ALLOWED_HOSTS
- your Heroku host name -
DATABASE_URL
- must already exist from the database add-on -
SECRET_KEY
- a Django settings secret key -
TELEGRAM_SECRET_PATH
- secret path(optional) that will be added to webhook API to make sure that the Webhook request comes from Telegram. docs -
TELEGRAM_TOKEN
- token that you get from BotFather in the Telegram -
LOGLEVEL
- by default loglevel INFO, but you could set a different level
-
Login to your Heroku account
heroku login
-
Set Heroku git
heroku git:remote -a <app_name>
-
Set
container
type of deployment instead ofbuildpacks
heroku stack:set container -a <app_name>
-
Push project to Heroku
git push heroku master
-
Register webhook, using Heroku console(also you local environment with same settings and environment variables)
python3 strong_exchange_bot/manage.py set_telegram_webhook https://strong-exchange-bot.herokuapp.com/