Skip to content

Instantly share code, notes, and snippets.

@raa0121
Created August 2, 2012 04:48
Show Gist options
  • Save raa0121/3233678 to your computer and use it in GitHub Desktop.
Save raa0121/3233678 to your computer and use it in GitHub Desktop.
lingr-bot(non move)
if RUBY_VERSION < '1.9'
require 'rubygems'
end
require 'sinatra'
require 'json'
def sandbox(&code)
proc {
$SAFE = 2
eval &code
}.call
end
get '/' do
"Here is raa0121's sinatra app"
end
post '/' do
content_type :text
json = JSON.parse(request.body.string)
json["events"].map do |e|
if e["message"]
m = e["message"]["text"]
if /^!?\s(.*)/ =~ m
x = Thread.start do
$SAFE = 2
eval $1.to_s
end
x.value
#sandbox{$1}
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment