Cat Weather Bot is a Telegram bot that receives a location sented by the user and returns the temperature and apparent temperature that location.
Project description
cat-weather-bot
Cat Weather Bot is a Telegram bot that receives a location sented by the user and returns the temperature and apparent temperature that location. It presents an image of a kitten and a phrase based on the indicated temperature. The project is intended for Python studies. Its main purpose is to be used to apply new concepts and techniques learned in language studies and enhance the use of what has already been learned. However, you can use it for your entertainment and/or as a basis for other projects!
The bot uses the Telegram API to communicate within the chat (it can be used by calling the bot privately or adding it to a group) and the Open Weather API, which provides the temperature based on the coordinates captured within Telegram when the location is sent. The Open Weather API has a free subscription sufficient for our bot, but it is possible to switch to a paid subscription to obtain more data beyond temperature.
How to use
Search in Telegram App the bot @Cat_WeatherBot or add bot in Chat Groups. Send your location or other location and waiting result.
Authorization with API Keys
A token is required for each of the APIs mentioned for the bot's usage. You will find more details in the official documentation for each API below:
Telegram Bot: https://core.telegram.org/bots/features#botfather
Open Weather API: https://openweathermap.org/current
Enviroment variables
Get tokens using official documentation mentions and use in application with enviroment variables
CATWB_TELEGRAM_TOKEN=""
CATWB_OPEN_WEATHER_TOKEN=""
Install with docker
docker run -e CATWB_TELEGRAM_TOKEN="telegram_token" \
-e CATWB_OPEN_WEATHER_TOKEN="open_weather_token" \
icarohenrique/cat-weather-bot:latest
Install using pip
pip install cat-weather-bot
CATWB_TELEGRAM_TOKEN="telegram_token" \
CATWB_OPEN_WEATHER_TOKEN="open_weather_token" \
cat-weather-bot
You cat set enviroment variables in bash or zsh:
bash:
echo "
export CATWB_TELEGRAM_TOKEN="telegram_token"
export CATWB_OPEN_WEATHER_TOKEN="open_weather_token" >> ~/.bashrc
source ~/.bashrc
zsh:
echo "
export CATWB_TELEGRAM_TOKEN="telegram_token"
export CATWB_OPEN_WEATHER_TOKEN="open_weather_token" >> ~/.zshrc
source ~/.zshrc
Install locally
To use and test the bot locally, it is recommended to create a virtual environment with venv and activate the environment to start installing dependencies:
Linux, MacOS
python -m venv .venv
source .venv/bin/activate
Windows
python -m venv .venv
source .venv/scripts/activate
Now, create a .env file based on .env-sample. Edit the file by inserting the API tokens for each service and finish by installing the project's dependencies with pip:
cp .env-sample .env
vi .env
make install #or pip install -e '.[dev]'
cat-weather-bot
As we use Dynaconf in conjunction with dotenv, the variables will be automatically loaded based on the .env file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cat_weather_bot-0.2.1-py3-none-any.whl.
File metadata
- Download URL: cat_weather_bot-0.2.1-py3-none-any.whl
- Upload date:
- Size: 6.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d487c3a16c9062ee444486dd7fabab4c8753845d540d5853c1e56683a1dfcc4
|
|
| MD5 |
8f431dab7d594325e7b9f9cfc9f394f4
|
|
| BLAKE2b-256 |
3efec5588081753690737284ff1c0188f32a2be36f25f6b7b75922d69f0b70e2
|