- terms = CGI.escape(params[:words].to_s)
- feed = Net::HTTP.get 'api.wolframalpha.com',
- "/v2/query?input=#{terms}&appid=#{WOLFRAM_API_KEY}&format=plaintext"
- "&scantimeout=3.0&podtimeout=4.0&formattimeout=8.0&parsetimeout=5.0"
- "&excludepodid=SeriesRepresentations:*"
- if feed.nil? or feed.empty?
- m.reply "error connecting"
+ what = params[:words].to_s
+ terms = CGI.escape what
+ url = WOLFRAM_API_SEARCH % {
+ :terms => terms, :key => WOLFRAM_API_KEY
+ }
+
+ begin
+ feed = @bot.httputil.get(url)
+ raise unless feed
+ rescue => e
+ m.reply "error asking WolframAlfa about #{what}"