Skip to content
This repository has been archived by the owner on May 6, 2019. It is now read-only.

Image responses #94

Merged
merged 34 commits into from
Jan 17, 2016
Merged

Image responses #94

merged 34 commits into from
Jan 17, 2016

Conversation

dustinblackman
Copy link
Contributor

Overview

This is a pretty major PR that adds support for image responses instead of text in Discord, managing League of Legends data, adds League champs and items images, and scripts to keep league data updated. It also improves dev commands.

Fixes #90 and #25

Technical Details

Image responses are simple HTML pages (written in Jade and Stylus) where a PhantomJS client sitting in the background takes screenshots and returns the buffer as an image to Discord. The PhantomJS client runs on a queue only allowing one screenshot to be taken at a time. The image generation response time on Heroku is roughly 400ms.

Both Jade and Stylus have their own folders within the web folder, both with linters that have been added to the tests.

The first feature that supports this new feature is the !lol items command, giving a simple image with the champions picture, name, position, and then all the items to go with it. The images are easier to resemble to then the names of items, making it easier for users. To keep the response time down, as well as prep incase Riot's CDN servers are ever slow/down, all the images are saved locally in the repo.

The image responses themselves aren't tested exactly, but instead the size is checked to make sure the majority of the information is filled compared to it being a nearly blank screenshot.

The express endpoints that are used by the views are limited to localhost only, a 401 is returned for anything else.

In the scripts folder you'll find scripts that help manage keep data up to date, for example the league items and champs command. I'm against adding something like gulp as simple vanilla scripts get the jobs done.

To add to that, all npm commands have been cleaned up and improved. npm run dev now gives debug information on both express and horseman (wrapper for PhantomJS). You'll also be able to access the Phantom web inspector on port 9000.

NOTE: On OSX due to a bug in PhantomJS, rendering images can go up to 3000ms. Again, this only happens on OSX and won't on Windows and Linux.

Screenshots

screen shot 2016-01-16 at 7 34 07 pm

@@ -47,17 +47,11 @@ describe('league of legends', () => {
});

describe('items', () => {
it('should return items for ekko mid', done => {
function sendMessage(channel, res) {
it('should return an image buffer larger then 70000', function(done) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

than*

dustinblackman added a commit that referenced this pull request Jan 17, 2016
@dustinblackman dustinblackman merged commit edcdea2 into master Jan 17, 2016
@dustinblackman dustinblackman deleted the image-responses branch January 17, 2016 15:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants