diff options
-rw-r--r-- | gentoo-data.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/gentoo-data.rb b/gentoo-data.rb index 792244a..e37d376 100644 --- a/gentoo-data.rb +++ b/gentoo-data.rb @@ -311,18 +311,20 @@ class GentooPlugin < Plugin # Watch out for network problems begin - packages = @bot.httputil.get(url+cp) + resp = @bot.httputil.get_response(url+cp) + if Net::HTTPNotFound === resp + packages = '' + elsif not Net::HTTPOK === resp + m.reply "HTTP error: #{resp}" + return + else + packages = resp.body.split("\n") + end rescue ::Exception => e - m.reply e.message + m.reply "Error: #{e.message}" return end - # 404 error => nil response - packages = '' if packages.nil? - - # Only then can we split it - packages = packages.split("\n") - if packages.length == 0 m.reply "No packages have a reverse #{type} on #{cp}." elsif packages.join(' ').length > 400 |