Telegram bot that shows the weather forecast. The working version is available at @OpenWeatherSmartBot
- City search by name or coordinates
- 24-hour weather and forecast display
- Updating weather forecast every 3 hours
git clone https://github.com/rin-gil/OpenWeatherBot.git
cd OpenWeatherBot
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
mv .env.dist .env
- Register a new bot with @BotFather and copy the received token
- Paste the bot's token into the .env file
- Register an account at OpenWeatherMap
- Create API key and copy it to .env file
- Paste your Telegram id into the .env file
- Find out your id, for example, by writing bot @getmyid_bot
- Launch the bot via the bot.py file
python bot.py
- Since version 1.1.0 the bot added localization for English, Ukrainian and Russian
- To add a translation in your language, do the following:
-
go to the folder with the bot
-
activate the virtual environment:
source venv/bin/activate
-
create a translation file for your language, where {language} is the ISO 639-1 language code
pybabel init --input-file=tgbot/locales/tgbot.pot --output-dir=tgbot/locales --domain=tgbot --locale={language}
-
translate the lines in the file locales/{language}/LC_MESSAGES/tgbot.po
-
compile the translation with the command:
pybabel compile --directory=tgbot/locales --domain=tgbot
-
restart the bot
-
- If you change the lines to be translated in the code, you will need to completely recreate and compile the
translation files for all localizations:
-
extract strings to be translated from the code:
pybabel extract --input-dirs=./tgbot --output-file=tgbot/locales/tgbot.pot --sort-by-file --project=OpenWeatherBot
-
create translation files for all localizations:
pybabel init --input-file=tgbot/locales/tgbot.pot --output-dir=tgbot/locales --domain=tgbot --locale={language}
-
compile translations:
pybabel compile --directory=tgbot/locales --domain=tgbot
-
- You can read more about this in the example from the documentation of aiogram
- The source code of Open Weather Bot is available under the MIT license
- Weather data provided by OpenWeather
- Weather icons by www.wishforge.games on freeicons.io