summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Gerus <arachnist@i.am-a.cat>2015-04-14 16:31:51 +0200
committerRobert Gerus <arachnist@i.am-a.cat>2015-04-14 16:31:51 +0200
commita1d4c856abbfac8e59f3a3cc4fbb29116b1cb6a7 (patch)
tree45aa0957aa20e9a7fef3c34f1210850128ee9b1f
parentf6911da8c6afbd250587f4df14b9d9481403851f (diff)
downloadrepost-a1d4c856abbfac8e59f3a3cc4fbb29116b1cb6a7.tar.gz
repost-a1d4c856abbfac8e59f3a3cc4fbb29116b1cb6a7.tar.bz2
repost-a1d4c856abbfac8e59f3a3cc4fbb29116b1cb6a7.tar.xz
repost-a1d4c856abbfac8e59f3a3cc4fbb29116b1cb6a7.zip
migrate to em-http-request, to avoid timeouts.
-rw-r--r--plugins/commands/at.rb2
-rw-r--r--plugins/commands/cycki.rb2
-rw-r--r--plugins/commands/gentoo-bugs.rb2
-rw-r--r--plugins/commands/kotki.rb2
-rw-r--r--plugins/commands/sjp.rb2
-rw-r--r--plugins/scrape.rb6
6 files changed, 8 insertions, 8 deletions
diff --git a/plugins/commands/at.rb b/plugins/commands/at.rb
index df3d460..a8c0a80 100644
--- a/plugins/commands/at.rb
+++ b/plugins/commands/at.rb
@@ -1,4 +1,4 @@
-require 'net/http'
+require 'em-net-http'
require 'json'
require 'time'
diff --git a/plugins/commands/cycki.rb b/plugins/commands/cycki.rb
index 77fd612..88456b7 100644
--- a/plugins/commands/cycki.rb
+++ b/plugins/commands/cycki.rb
@@ -1,4 +1,4 @@
-require 'net/http'
+require 'em-net-http'
require 'nokogiri'
Client.register_command("cycki") { |args|
diff --git a/plugins/commands/gentoo-bugs.rb b/plugins/commands/gentoo-bugs.rb
index 0cc7a14..d1b5326 100644
--- a/plugins/commands/gentoo-bugs.rb
+++ b/plugins/commands/gentoo-bugs.rb
@@ -1,4 +1,4 @@
-require 'net/http'
+require 'em-net-http'
require 'nokogiri'
Client.register_command("bug") { |args|
diff --git a/plugins/commands/kotki.rb b/plugins/commands/kotki.rb
index 0c144fd..0abaedf 100644
--- a/plugins/commands/kotki.rb
+++ b/plugins/commands/kotki.rb
@@ -1,4 +1,4 @@
-require 'net/http'
+require 'em-net-http'
require 'uri'
Client.register_command("kotki") { |args|
diff --git a/plugins/commands/sjp.rb b/plugins/commands/sjp.rb
index a4dd508..1548b73 100644
--- a/plugins/commands/sjp.rb
+++ b/plugins/commands/sjp.rb
@@ -1,4 +1,4 @@
-require 'net/http'
+require 'em-net-http'
require 'nokogiri'
Client.register_command("sjp") { |args|
diff --git a/plugins/scrape.rb b/plugins/scrape.rb
index 3ceb18f..ea5a77f 100644
--- a/plugins/scrape.rb
+++ b/plugins/scrape.rb
@@ -1,4 +1,4 @@
-require 'open-uri'
+require 'em-http-request'
require 'digest/md5'
require 'data_mapper'
require 'nokogiri'
@@ -10,7 +10,7 @@ DataMapper.setup(:default, Config[:scrape][:db])
module Scrape
def self.download(uri)
ext = "." + uri.sub(/.*[.]([^.]*)/, '\1') if uri.match(/[^.]+[.][^.]+/)
- content = open(uri).read
+ content = Net::HTTP.get(uri)
md5 = Digest::MD5.hexdigest(content)
File.open(Config[:scrape][:basepath] + md5 + ext, 'w') do |file|
file.write(content)
@@ -45,7 +45,7 @@ Client.register_trigger("PRIVMSG") do |msg|
url = Digest::MD5.hexdigest(word)
end
- title = Nokogiri::HTML(open(word).read(10240)).title()
+ title = Nokogiri::HTML(Net::HTTP.get(word)).title()
title = title.gsub(/[\s]+/, " ").strip if not title.nil?
Scrape::Link.create(