Skip to content

Instantly share code, notes, and snippets.

@sh4869
Last active November 19, 2015 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sh4869/a7538f39e2872f73faaa to your computer and use it in GitHub Desktop.
Save sh4869/a7538f39e2872f73faaa to your computer and use it in GitHub Desktop.
診断メーカーを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