Skip to content

Instantly share code, notes, and snippets.

@sh4869 sh4869/shindan.coffee
Last active Nov 19, 2015

Embed
What would you like to do?
診断メーカーをhubotでやる
# Description:
# Shindan From Hubot
#
# Dependencies:
# "request"
# "cheerio"
#
# Configuration:
# None
#
# Commands:
# hubot shindan sindanid usename - shindan
#
# Author:
# sh4869
request = require 'request'
cheerio = require 'cheerio'
module.exports = (robot) ->
robot.respond /shindan ([^\s]*) ([^\s]*)/i, (msg) ->
url = "https://shindanmaker.com/" + msg.match[1]
username = msg.match[2]
options =
headers: {'content-type' : 'application/x-www-form-urlencoded'}
url: url
timeout: 2000
body: "u=" + username + "&from="
request.post options, (error, response, body) ->
$ = cheerio.load body
if $("title").text().replace(/\s/,"") == "エラー"
result = "そんな診断ないよ"
else
result = $("textarea").text()
msg.send(result)
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.