Skip to content

Instantly share code, notes, and snippets.

@avram
Last active August 29, 2015 14:11
Show Gist options
  • Save avram/3bd0467fc67317fa3654 to your computer and use it in GitHub Desktop.
Save avram/3bd0467fc67317fa3654 to your computer and use it in GitHub Desktop.
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