]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - rbot/utils.rb
enable in-channel usage
[user/henk/code/ruby/rbot.git] / rbot / utils.rb
index 516fb4dcbf514aae07768d8fd5db87f49cf2eb63..b22a417d13d3e1dd79868df8372528bb4f0330d4 100644 (file)
@@ -162,22 +162,22 @@ module Irc
         proxy_port = proxy_uri.port
       end
 
-      http = Net::HTTP.new(uri.host, uri.port, proxy_host, proxy_port)
-      http.open_timeout = opentimeout
-      http.read_timeout = readtimeout
+      begin
+        http = Net::HTTP.new(uri.host, uri.port, proxy_host, proxy_port)
+        http.open_timeout = opentimeout
+        http.read_timeout = readtimeout
 
-      http.start {|http|
-        begin
+        http.start {|http|
           resp = http.get(query)
           if resp.code == "200"
             return resp.body
           end
-        rescue => e
-          # cheesy for now
-          $stderr.puts "Utils.http_get exception: #{e}, while trying to get #{uristr}"
-          return nil
-        end
-      }
+        }
+      rescue => e
+        # cheesy for now
+        $stderr.puts "Utils.http_get exception: #{e}, while trying to get #{uristr}"
+        return nil
+      end
     end
 
     # This is nasty-ass. I hate writing parsers.