The Book Webhook Bot searches in several resources. Bot was based on Flask framework and working via webhook. Books are sent to Telegram.
- Programming language - Python 3.8.5.
- Webhook was built on - Flask.
- Telegram bot library - Python-telegram-bot.
- Cache is using - Redis database.
- Clone this repository
git clone https://github.com/DmitryTokyo/quotes.git
. - Create virtual environment
python3 -m venv venv
and activatesource venv/bin/activate
. - Install all dependencies
pip install -r requirements.txt
- Create
.env
file and put there following variables:TG_TOKEN
- telegram bot token. You can get it by using@BotFather
bot.DATABASE_PASSWORD
- Redis database password.DATABASE_HOST
- Redis database host.DATABASE_PORT
- Redis database port.
- Webhook method needs public IP address or domain, but in a local computer you can use
ngrok
technology. For this way you can start thengrok
server by the command./ngrok http 5000
andhttps
link assign toURL
variable in.env
file. - You need to tell your terminal the main flask application to work with by exporting the FLASK_APP and set debug mode by exporting the FLASK_ENV:
You can create
export FLASK_APP=app.py export FLASK_ENV=development
.flaskenv
instead it.
- Start the
./ngrok http 5000
and put to.env
https link. - Start the app by command
flask run
. - Set up your webhook to follow the url. You can see in your browser
webhook setup ok!!!
. - Send your bot
/start
.
Code licensed under MIT License.