At work we use Slack for day-to-day business and shenanigans. We are also a bunch of avid League of Legends players. My idea was to combine the two and add LoL-stats straight in to our #gaming-channel!
- Koa.js - Node API
- Highland.js - Data manipulation
- Docker - Running the service
Three environment variables need to be setup before starting.
LOL_GLOBAL=https://global.api.pvp.net/api/lol/static-data/{region}
LOL_BASE=https://eune.api.pvp.net/api/lol/{region}
RIOT_API_KEY=[YOUR-API-KEY]
$ git clone https://github.com/believer/lol-slack.git
$ cd lol-slack
$ npm install
$ npm start
This starts one POST
route at http://localhost:3000/lol. So to test it post a JSON object on the form of for example:
{
"text": "wins <summonerName>"
}
Slack have provided a great way for testing the message formatting right here. Each command also have a direct TRY IT link with a typical message and the response has a URL directly to the Slack formatting. This is how the message will look in the chat, instead of just looking at the JSON that the API reponds with ;)
The service responds to slash commands, i.e. /lol
as a message. The available commands are listed below.
- region = eune, euw, na and so on
default: eune
- platform = eun1, euw1, na1 and so on
default: eun1
Displays the current champions who are free to play.
Display the help message only to the user who requested the help. (Also responds if provided command does not exist)
Displays statistics from a summoner's latest game.
Displays division and stats for a summoner.
Displays total mastery score of a summoner.
Displays ranked matches from the last 24 hours.
Displays the current status of the servers in a region.
Displays the teams of a summoner.
Displays the top three champions for a given summoner name.
Display the number of wins of a summoner.