/discloud

The weather on your Discord server

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

Features

Real-time weather

The discloud bot is displaying real-time weather at the configured location directly on its Discord profile :

bot_profile

Users can also obtain the current weather at any location, using the command !weather [location], for example !weather San Francisco,CA:

weather

Weather forecast

Users can obtain the weather forecast for any location using the command !forecast [location], for example !forecast Los Angeles,CA :

forecast

If the [location] argument is not provided, the bot's configured location (for the real-time weather) will be used.

Setup

Prerequisites

  1. Obtain your (free) Open Weather Map API key
  2. (Optional) Obtain your (free) Weather Underground API key
  3. Create a (dedicated) Discord bot account and save its Token
  4. Add the bot account to your Discord server

Docker (recommended)

  1. 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)
  1. Run the docker_run.sh script to start the bot

  2. 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

Debian 8+

  1. Install Git: sudo apt-get install git-all
  2. Clone the discloud Git repository: sudo git clone github.com/mbouchenoire/discloud.git /etc
  3. Configure the bot's environment variables export SOME_ENV_VARIABLE="value"
  4. Run the bot using Python:
    1. install pip : sudo apt-get install -y python3-pip
    2. install the bot dependencies sudo pip3 install -r requirements.txt
    3. run the Python script sudo python3 discloud/__ini__.py &

Advanced configuration

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.