Last active
August 29, 2015 14:11
-
-
Save avram/3bd0467fc67317fa3654 to your computer and use it in GitHub Desktop.
reviews.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"dependencies": { | |
"cheerio": "0.18.0", | |
"request": "2.50.0" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# Description: | |
# Integrates hubot with Google Play reviews | |
# | |
# Dependencies: | |
# None | |
# | |
# Configuration: | |
# None | |
# | |
# Commands: | |
# slots review | |
# | |
# Author: | |
# avram | |
### | |
cheerio = require 'cheerio' | |
request = require 'request' | |
packages = | |
slots: 'com.scopely.slotsvacation' | |
dice: 'com.withbuddies.dice.free' | |
module.exports = (robot) -> | |
robot.hear /(\w+) review/i, (msg) -> | |
if msg.match[1] of packages | |
request "https://play.google.com/store/apps/details?id=#{packages[msg.match[1]]}", (err, resp, body) -> | |
$ = cheerio.load(body) | |
reviews = [] | |
$('div.featured-review div.quoted-review').each () -> | |
reviews.push $(this).text() | |
index = Math.floor(Math.random() * reviews.length) | |
msg.send reviews[index] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment