Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/caarmen/weather-slack-profile-photo

Set your Slack profile photo to one based on weather conditiosn
https://github.com/caarmen/weather-slack-profile-photo

Last synced: 11 days ago
JSON representation

Set your Slack profile photo to one based on weather conditiosn

Awesome Lists containing this project

README

        

# Slack profile photo weather updater

This project updates your slack profile photo with a photo based on the weather.

## Configuration
You need to provide:
* Two profile photos, with 500x500 resolution, and with a transparent background, for daytime and nighttime. By default, place them in `profile_photos/jdoe_day.png` and `profile_photos/jdoe_night.png`, for a slack configuration with name "jdoe".
* Environment variables:
- Copy the `config.toml.template` file to `config.toml`.
- Edit the variables:
- `[weatherprovider]` section:
- `name`: the name of the provider. Valid values are `weatherstack` and `weatherapi`.
- `api_access_key`: the api key for your account on [weatherstack.com](https://weatherstack.com/) or [weatherapi.com](https://www.weatherapi.com/).
- `[[slack]]` sections:
- `name`: a name for your slack configuration.
- `workspace`: the slack workspace where you want to change your profile photo
- `token`, `cookie_d`: see below.
- `[wspp]` section:
- `latitude`, `longitude`: the location for the weather conditions that will be used to fill in the background in your profile photo.

### Retrieving the slack token and cookie values
* Log into slack in a browser on a computer.
* Enable developer tools in the browser, and open the network tab.
* Manually change your profile photo to any photo you want.
* Inspect the request in the developer tools network tab on the `/api/users.setPhoto` endpoint.
- Copy the value of the `token` parameter into `token` in your `config.toml` file.
- For the `cookie_d` env var, look at the `cookie` header, and extract the value of the `d=` part of the cookie.

### Optional parameters
* `profile_photos_dir`: The directory containing your profile photos with the transparent background. it should contain a `jdoe_day.png` for daytime, and a `jdoe_night.png` for nighttime, for a slack configuration with `name` "jdoe". the default location is in `profile_photos/` in the project.
* `polling_interval_s`: The frequency in seconds to update the profile photo. The default value is `7200`.

## Running the program
* Follow the setup described just above

### Locally
* Setup a python environment
* Run `python -m wspp.main`

### With Docker

Retrieve the docker image:
```
docker pull ghcr.io/caarmen/weather-slack-profile-photo:latest
```

Run the docker image. Indicate the host paths to your `config.toml` file and `profile_photos` folder.
```
docker run --detach -v `pwd`/config.toml:/app/config.toml -v `pwd`/profile_photos/:/app/profile_photos/ ghcr.io/caarmen/weather-slack-profile-photo
```

## Image credits
* The night background photo is from [Alexey Elfimov](https://commons.wikimedia.org/wiki/File:%D0%A1%D0%B2%D0%B5%D1%82_%D0%BE%D1%82_%D0%B4%D0%B5%D1%80%D0%B5%D0%B2%D0%BD%D0%B8_-_panoramio.jpg), licensed under the Creative Commons Attribution 3.0 Unported license
* The weather background images were generated by Bing
* The sample profile photos were generated from the Bitmoji app.