Last active
November 19, 2015 13:35
-
-
Save sh4869/a7538f39e2872f73faaa to your computer and use it in GitHub Desktop.
診断メーカーをhubotでやる
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: | |
# 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