lib/Zeta/plugins/wolfram.rb in zetabot-2.0.3 vs lib/Zeta/plugins/wolfram.rb in zetabot-2.0.4

- old
+ new

@@ -1,6 +1,7 @@ require 'crack' +require 'cgi' module Plugins class Wolfram include Cinch::Plugin include Cinch::Helpers @@ -16,12 +17,12 @@ match /calc (.+)/, method: :calculate 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=#{Config.secrets[:wolfram]}&primary=true&format=plaintext" + debug 'Query: ' + Cgi.escape(query) + url = "http://api.wolframalpha.com/v2/query?input=#{CGI.escape(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? @@ -35,11 +36,9 @@ end rescue m.reply 'Unable to get a results' end end - - #### end end # AutoLoad Bot.config.plugins.plugins.push Plugins::Wolfram \ No newline at end of file