Skip to content

Instantly share code, notes, and snippets.

@Akanoa
Last active December 24, 2015 16:27
Show Gist options
  • Save Akanoa/4a17c15b96e8a1cea460 to your computer and use it in GitHub Desktop.
Save Akanoa/4a17c15b96e8a1cea460 to your computer and use it in GitHub Desktop.
Converts LateX language into human readable characters
require 'sinatra'
require 'sinatra'
require "cgi"
require 'json'
require 'tex2png'
def upload(path)
`curl -F file=@#{path} -F token=xoxp-xxxxxxxxx-xxxxxxxxx https://slack.com/api/files.upload`
end
get '/' do
"Yolo\n"
end
post '/' do
data = CGI::parse request.body.read
content_type :json
puts data['text']
message = data['text'][0]
converter = Tex2png::Converter.new(message)
result = upload(converter.png.path)
result = JSON.parse(result)['file']['url']
{:text => "#{result}"}.to_json
end
@Akanoa
Copy link
Author

Akanoa commented Dec 24, 2015

Used with outgoing Slack Webhook https://api.slack.com/outgoing-webhooks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment