The discloud bot is displaying real-time weather at the configured location directly on its Discord profile :
Users can also obtain the current weather at any location, using the command !weather [location]
, for example !weather San Francisco,CA
:
Users can obtain the weather forecast for any location using the command !forecast [location]
, for example !forecast Los Angeles,CA
:
If the [location]
argument is not provided, the bot's configured location (for the real-time weather) will be used.
- Obtain your (free) Open Weather Map API key
- (Optional) Obtain your (free) Weather Underground API key
- Create a (dedicated) Discord bot account and save its Token
- Add the bot account to your Discord server
- Create the following
docker_run.sh
file and configure the required environment variables obtained through the prerequisites:
#!/bin/bash
docker run -dit \
--name discloud \
-e OPEN_WEATHER_MAP_API_KEY="" \
-e DISCORD_BOT_TOKEN="" \
-e HOME_FULL_NAME="London,UK" \
--restart=always \
mbouchenoire/discloud[:arm] # use the :arm tag if the bot is running on an ARM architecture (e.g. Raspberry Pi)
-
Run the
docker_run.sh
script to start the bot -
In order to update the bot once its container is running, you can use the following script:
#!/bin/bash
# use the :arm tag if the bot is running on an ARM architecture (e.g. Raspberry Pi)
docker pull mbouchenoire/discloud[:arm]
docker stop discloud
docker rm discloud
sh docker_run.sh
- Install Git:
sudo apt-get install git-all
- Clone the discloud Git repository:
sudo git clone github.com/mbouchenoire/discloud.git /etc
- Configure the bot's environment variables
export SOME_ENV_VARIABLE="value"
- Run the bot using Python:
- install pip :
sudo apt-get install -y python3-pip
- install the bot dependencies
sudo pip3 install -r requirements.txt
- run the Python script
sudo python3 discloud/__ini__.py &
- install pip :
The discloud bot depends on multiple environment variables that can be configured:
Environment variable | Value | Comment |
---|---|---|
OPEN_WEATHER_MAP_API_KEY |
See here | Required |
WEATHER_UNDERGROUND_API_KEY |
See here, improve the weather accuracy if provided, but limited to 10 requests per minute. Open Weather Map will be used when the limit is reached | Recommended |
DISCORD_BOT_TOKEN |
See here | Required |
HOME_FULL_NAME |
The full name of the home location, in order to handle different locations with the same name (e.g. Paris,fr ) |
Required |
HOME_DISPLAY_NAME |
The location shorthandle (e.g. Paris ) |
Optional (default: HOME_FULL_NAME ) |
MEASUREMENT_SYSTEM |
[metric | imperial ] |
Optional (default: metric ) |
MORNING_FORECAST_TIME |
from 00:00 to 23:59 , you can explicitly set it to an empty value if you don't want periodic morning forecasts |
Optional (default: 8:00 ), the timezone of your Docker container will be used |
EVENING_FORECAST_TIME |
from 00:00 to 23:59 , you can explicitly set it to an empty value if you don't want periodic evening forecasts |
Optional (default: 20:00 ), the timezone of your Docker container will be used |
PERIODIC_FORECAST_CHANNELS |
The channel names where the periodic forecasts will be broadcasted, separated by a comma ',' | Optional (default: general,weather ) |
LANGUAGE |
[en | ru | jp | de | es | fr ], The language in which the bot will respond to commands |
Optional (default: en ) |
CONCURRENCY_PRIORITY |
[always | auto | never ], defines the responding behavior of this discloud instance when multiple discloud instances are running on the same Discord server. The auto value gives priority to the discloud bot with the lowest discord ID |
Optional (default: auto ) |
LOGGING_LEVEL |
[critical | error | info | debug ] |
Optional (default: info ) |
You can directly add these environment variables inside the docker-compose.yml
file, in the services.discloud.environment
section.