Created
July 4, 2016 15:33
-
-
Save wearethefoos/1208d019fc173da4f6cd01e9093ca6cb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# Translate erb (html) into a slim version | |
# | |
# Commands | |
# learnbot erb2slim <your code here> | |
# | |
# Authors: | |
# Aeshta and Rosiene | |
module.exports = (robot) -> | |
robot.respond /(html|erb)2slim (.*)/ , (msg) -> | |
code = msg.match[2] | |
open_erb2slim msg, code | |
open_erb2slim = (msg, code) -> | |
data = "" | |
msg.http("http://erb2slim.com/convert.json") | |
.query | |
raw_text: code | |
conversion_type: "slim" | |
.post( (err, req)-> | |
req.addListener "response", (res)-> | |
output = res | |
output.on 'data', (d)-> | |
data = d.toString('utf-8') | |
output.on 'end', ()-> | |
parsedData = JSON.parse(data) | |
if parsedData.error | |
msg.send "Error: #{parsedData.error}" | |
return | |
msg.send "```\n" + parsedData.converted_txt + "\n```" | |
)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment