lib/Zeta/plugins/wolfram.rb in zetabot-0.0.7 vs lib/Zeta/plugins/wolfram.rb in zetabot-0.0.8
- old
+ new
@@ -17,11 +17,11 @@
def calculate(m, query)
# Rescue incase something goes wrong
begin
debug 'Query: ' + query
- url = URI.encode "http://api.wolframalpha.com/v2/query?input=#{query}&appid=#{ENV['ZETA_WOLFRAM']}&primary=true&format=plaintext"
+ url = URI.encode "http://api.wolframalpha.com/v2/query?input=#{query}&appid=#{Config.secrets[:wolfram]}&primary=true&format=plaintext"
request = open(url).read
data = Crack::XML.parse(request)
pod0 = data['queryresult']['pod'][0]['subpod']['plaintext'].strip
pod1 = data['queryresult']['pod'][1]['subpod']['plaintext'].strip
return 'Unable to get a results' if pod0.nil?
@@ -29,10 +29,10 @@
if pod1.lines.count > 2
m.user.send "# Wolfram Results #\n #{pod0}\n #{pod1}", true
elsif pod0.length > 400
m.user.send("#{pod0} #{pod1}", true)
else
- m.reply "#{pod0} #{pod1}"
+ m.reply "#{pod0} = #{pod1}"
end
rescue
m.reply 'Unable to get a results'
end
end
\ No newline at end of file