A Flask project to interactively check OFFICIAL COVID-19 stats for Romania and other countries.
Telegram channel: https://coronavirus.pradan.dev/channel/
Telegram bot: https://coronavirus.pradan.dev/bot/
-
Create a new telegram bot by sending the
/newbot
command to BotFather here- give it a
name
: e.g. MyExtraordinaryBot (does not need to end in "Bot") - give it a
username
: e.g. my_extraordinary_bot (this one does need to end in "bot") - write down your
token
that BotFather gives you at the end. You will need it later on
- give it a
-
Start the Flask local server:
$ TOKEN=<token_from_BotFather> python flask_app.py
-
Telegram bots need a https URL as a callback for sending update events. Details here
Ngrok is a great utility used for exposing your localhost to a publicly accessible https URL
- sign up here https://dashboard.ngrok.com/signup
- install
ngrok
and set it up using these four simple steps here: https://dashboard.ngrok.com/get-started - run it locally:
ngrok http 5000
-
Set the webhook URL for your telegram bot using the config/webhook.py script
$ python config/webhook.py --token=1234567890:ABCD-aBsadfASDFasfdb-v Current webhook url: is not set up $ python config/webhook.py --token=1234567890:ABCD-aBsadfASDFasfdb-v --set INFO:root:Current webhook url: https://5efg4d21.ngrok.io/1234567890:ABCD-aBsadfASDFasfdb-v
- replace the host and token with your own
- your telegram bot should now be pointed to your newly created public URL that is tunneling to your localhost 5000 port
-
Data source setup
The telegrambot pull all of its data from mongodb collections
Configure a MongoDB database:
-
Populate database with initial data
python config/sync_data.py --all
python config/sync_data.py --help
for the complete list of parameters
-
Make sure you've set the correct TOKEN when starting the Flask server
- the callback url contains your bot's token so if the TOKEN environment variable is not set correctly, when using the bot you will see a lot of 404s in the server console from the telegram bot trying to post callbacks (respond to commands) to an invalid URL
-
Make sure ngrok is tunneling your localhost:
- you can do this by navigating to the https URL that ngrok provided - directly into your browser
-
Make sure you've set the correct webhook URL.
> python config/webhook.py --token=1234567890:ABCD-aBsadfASDFasfdb-v Current webhook url: https://5efg4d21.ngrok.io/1234567890:ABCD-aBsadfASDFasfdb-v
- should be the ngrok provided HTTPS URL + your telegram bot token
pytest tests --cov .
- for html coverage report add
--cov-report=html
- English keys
- More data sources
- Charts and diagrams for historical data, stats based on gender, age, etc.
- Storing historical data for Global regions/countries (currently only today's statistics)
- TBD: more google cloud commands
https://github.com/afourmy/flask-gentelella
- https://datelazi.ro/
- https://stirioficiale.ro/
- https://worldometers.info/
- Johns Hopkins Covid-19 repository: https://github.com/CSSEGISandData/COVID-19
👤 Andrei Prădan
- Website: pradan.dev
- Github: andreipradan
- LinkedIn: andreipradan
Contributions, issues and feature requests are welcome!
Feel free to check the issues page
Give a ⭐️ if this project helped you!
This README was generated with ❤️ by readme-md-generator