Skip to content

Instantly share code, notes, and snippets.

@avram avram/reviews.coffee
Last active Aug 29, 2015

Embed
What would you like to do?
reviews.coffee
"dependencies": {
"cheerio": "0.18.0",
"request": "2.50.0"
}
###
# 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
You can’t perform that action at this time.