診断メーカーを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